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";
111 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
112 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
114 const float RENDER_FRAME_INTERVAL = 16.66f;
116 const unsigned int DEFAULT_FONT_SIZE = 1152u;
117 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
121 const int KEY_C_CODE = 54;
122 const int KEY_V_CODE = 55;
123 const int KEY_X_CODE = 53;
124 const int KEY_WHITE_SPACE_CODE = 65;
126 const int KEY_SHIFT_MODIFIER = 257;
127 const int KEY_CONTROL_MODIFIER = 258;
129 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
130 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
131 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
133 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
135 static bool gAnchorClickedCallBackCalled;
136 static bool gAnchorClickedCallBackNotCalled;
137 static bool gTextChangedCallBackCalled;
138 static bool gInputStyleChangedCallbackCalled;
139 static bool gMaxCharactersCallBackCalled;
140 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
142 struct CallbackFunctor
144 CallbackFunctor(bool* callbackFlag)
145 : mCallbackFlag( callbackFlag )
151 *mCallbackFlag = true;
156 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
158 tet_infoline(" TestAnchorClickedCallback");
160 gAnchorClickedCallBackNotCalled = false;
162 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
164 gAnchorClickedCallBackCalled = true;
168 static void TestTextChangedCallback( TextEditor control )
170 tet_infoline(" TestTextChangedCallback");
172 gTextChangedCallBackCalled = true;
175 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
177 tet_infoline(" TestInputStyleChangedCallback");
179 gInputStyleChangedCallbackCalled = true;
180 gInputStyleMask = mask;
183 static void TestMaxLengthReachedCallback( TextEditor control )
185 tet_infoline(" TestMaxLengthReachedCallback");
187 gMaxCharactersCallBackCalled = true;
190 // Generate a KeyEvent to send to Core.
191 Integration::KeyEvent GenerateKey( const std::string& keyName,
192 const std::string& logicalKey,
193 const std::string& keyString,
196 unsigned long timeStamp,
197 const Integration::KeyEvent::State& keyState,
198 const std::string& compose = "",
199 const std::string& deviceName = DEFAULT_DEVICE_NAME,
200 const Device::Class::Type& deviceClass = Device::Class::NONE,
201 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
203 return Integration::KeyEvent( keyName,
216 Dali::Integration::Point GetPointDownInside( Vector2& pos )
218 Dali::Integration::Point point;
219 point.SetState( PointState::DOWN );
220 point.SetScreenPosition( pos );
224 Dali::Integration::Point GetPointUpInside( Vector2& pos )
226 Dali::Integration::Point point;
227 point.SetState( PointState::UP );
228 point.SetScreenPosition( pos );
232 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
234 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
236 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
238 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
240 Property::Value* valueSet = NULL;
241 if ( valueGet.first.type == Property::Key::INDEX )
243 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
247 // Get Key is a string so searching Set Map for a string key
248 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
251 if( NULL != valueSet )
253 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
255 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
258 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
260 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
263 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
265 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
268 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
270 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
273 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
275 Vector2 vector2Get = valueGet.second.Get<Vector2>();
276 Vector2 vector2Set = valueSet->Get<Vector2>();
277 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
280 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
282 Vector4 vector4Get = valueGet.second.Get<Vector4>();
283 Vector4 vector4Set = valueSet->Get<Vector4>();
284 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 );
290 if ( valueGet.first.type == Property::Key::INDEX )
292 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
296 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
306 class ScrollStateChangeCallback : public Dali::ConnectionTracker
309 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
310 : mStartedCalled( startedCalled ),
311 mFinishedCalled( finishedCalled )
315 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
317 if( type == TextEditor::Scroll::STARTED )
319 mStartedCalled = true;
321 else if( type == TextEditor::Scroll::FINISHED )
323 mFinishedCalled = true;
327 bool& mStartedCalled;
328 bool& mFinishedCalled;
333 int UtcDaliToolkitTextEditorConstructorP(void)
335 ToolkitTestApplication application;
336 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
337 TextEditor textEditor;
338 DALI_TEST_CHECK( !textEditor );
342 int UtcDaliToolkitTextEditorNewP(void)
344 ToolkitTestApplication application;
345 tet_infoline(" UtcDaliToolkitTextEditorNewP");
346 TextEditor textEditor = TextEditor::New();
347 DALI_TEST_CHECK( textEditor );
351 int UtcDaliToolkitTextEditorDownCastP(void)
353 ToolkitTestApplication application;
354 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
355 TextEditor textEditor1 = TextEditor::New();
356 BaseHandle object( textEditor1 );
358 TextEditor textEditor2 = TextEditor::DownCast( object );
359 DALI_TEST_CHECK( textEditor2 );
361 TextEditor textEditor3 = DownCast< TextEditor >( object );
362 DALI_TEST_CHECK( textEditor3 );
366 int UtcDaliToolkitTextEditorDownCastN(void)
368 ToolkitTestApplication application;
369 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
370 BaseHandle uninitializedObject;
371 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
372 DALI_TEST_CHECK( !textEditor1 );
374 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
375 DALI_TEST_CHECK( !textEditor2 );
379 int UtcDaliToolkitTextEditorCopyConstructorP(void)
381 ToolkitTestApplication application;
382 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
383 TextEditor textEditor = TextEditor::New();
384 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
386 TextEditor copy( textEditor );
387 DALI_TEST_CHECK( copy );
388 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
392 int UtcDaliTextEditorMoveConstructor(void)
394 ToolkitTestApplication application;
396 TextEditor textEditor = TextEditor::New();
397 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
398 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
400 TextEditor moved = std::move( textEditor );
401 DALI_TEST_CHECK( moved );
402 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
403 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
404 DALI_TEST_CHECK( !textEditor );
409 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
411 ToolkitTestApplication application;
412 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
413 TextEditor textEditor = TextEditor::New();
414 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
416 TextEditor copy = textEditor;
417 DALI_TEST_CHECK( copy );
418 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
422 int UtcDaliTextEditorMoveAssignment(void)
424 ToolkitTestApplication application;
426 TextEditor textEditor = TextEditor::New();
427 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
428 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
431 moved = std::move( textEditor );
432 DALI_TEST_CHECK( moved );
433 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
434 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
435 DALI_TEST_CHECK( !textEditor );
440 int UtcDaliTextEditorNewP(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextEditorNewP");
444 TextEditor textEditor = TextEditor::New();
445 DALI_TEST_CHECK( textEditor );
449 // Positive test case for a method
450 int UtcDaliTextEditorGetPropertyP(void)
452 ToolkitTestApplication application;
453 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
454 TextEditor editor = TextEditor::New();
455 DALI_TEST_CHECK( editor );
457 // Check Property Indices are correct
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
522 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
525 Property::Map imageMap;
526 imageMap[mapKey] =mapValue;
528 editor.SetProperty( property , imageMap );
529 Property::Value propValue = editor.GetProperty( property );
530 Property::Map* resultMap = propValue.GetMap();
532 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
540 // Positive test case for a method
541 int UtcDaliTextEditorSetPropertyP(void)
543 ToolkitTestApplication application;
544 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
545 TextEditor editor = TextEditor::New();
546 DALI_TEST_CHECK( editor );
547 application.GetScene().Add( editor );
549 // Note - we can't check the defaults since the stylesheets are platform-specific
551 // Check the render backend property.
552 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
553 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
555 // Check text property.
556 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
557 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
559 // Check text's color property
560 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
561 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
563 // Check font properties.
564 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
565 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
567 Property::Map fontStyleMapSet;
568 Property::Map fontStyleMapGet;
569 Property::Value* slantValue = NULL;
571 fontStyleMapSet.Insert( "weight", "bold" );
572 fontStyleMapSet.Insert( "width", "condensed" );
573 fontStyleMapSet.Insert( "slant", "italic" );
575 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
576 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
577 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
578 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
580 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
581 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
583 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
584 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
585 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
588 fontStyleMapSet.Clear();
589 fontStyleMapSet.Insert( "weight", "normal" );
590 fontStyleMapSet.Insert( "slant", "oblique" );
591 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
592 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
593 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
594 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
596 fontStyleMapSet.Clear();
597 fontStyleMapSet.Insert( "slant", "roman" );
598 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
599 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
601 // Replace 'roman' for 'normal'.
602 slantValue = fontStyleMapGet.Find( "slant" );
603 if( NULL != slantValue )
605 if( "normal" == slantValue->Get<std::string>() )
607 fontStyleMapGet["slant"] = "roman";
610 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
611 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
613 fontStyleMapSet.Clear();
615 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
616 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
617 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
618 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
620 // Check that the Alignment properties can be correctly set
621 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
622 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
624 // Check scroll properties.
625 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
626 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
627 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
628 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
630 // Check cursor properties
631 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
632 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
633 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
634 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
636 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
637 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
638 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
639 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
640 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
641 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
642 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
643 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
645 // Check handle images
646 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
647 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
648 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
649 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
650 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
652 // Check handle images
653 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
654 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
655 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
656 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
657 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
658 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
660 // Check the highlight color
661 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
662 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
664 // Decoration bounding box
665 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
666 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
668 // Check the enable markup property.
669 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
670 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
671 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
673 // Check input color property.
674 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
675 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
677 // Check input font properties.
678 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
679 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
681 fontStyleMapSet.Clear();
682 fontStyleMapSet.Insert( "weight", "bold" );
683 fontStyleMapSet.Insert( "width", "condensed" );
684 fontStyleMapSet.Insert( "slant", "italic" );
686 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
687 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
688 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
689 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
691 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
692 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
694 // Reset input font style.
695 fontStyleMapSet.Clear();
696 fontStyleMapSet.Insert( "weight", "normal" );
697 fontStyleMapSet.Insert( "slant", "oblique" );
699 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
700 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
701 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
702 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
704 fontStyleMapSet.Clear();
705 fontStyleMapSet.Insert( "slant", "roman" );
707 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
708 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
710 // Replace 'roman' for 'normal'.
711 slantValue = fontStyleMapGet.Find( "slant" );
712 if( NULL != slantValue )
714 if( "normal" == slantValue->Get<std::string>() )
716 fontStyleMapGet["slant"] = "roman";
719 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
720 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
722 fontStyleMapSet.Clear();
724 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
725 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
726 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
727 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
729 // Check the line spacing property
730 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
731 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
732 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
734 // Check the input line spacing property
735 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
737 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
739 // Check the underline property
741 Property::Map underlineMapSet;
742 Property::Map underlineMapGet;
744 underlineMapSet.Insert( "enable", true );
745 underlineMapSet.Insert( "color", Color::RED );
746 underlineMapSet.Insert( "height", 1 );
748 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
750 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
751 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
752 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
754 // Check the input underline property
755 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
756 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
758 // Check the shadow property
759 Property::Map shadowMapSet;
760 Property::Map shadowMapGet;
762 shadowMapSet.Insert( "color", Color::GREEN );
763 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
764 shadowMapSet.Insert( "blurRadius", 3.0f );
766 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
768 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
769 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
770 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
772 // Check the input shadow property
773 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
774 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
776 // Check the emboss property
777 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
778 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
780 // Check the input emboss property
781 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
782 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
784 // Check the outline property
786 // Test string type first
787 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
788 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
789 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
791 // Then test the property map type
792 Property::Map outlineMapSet;
793 Property::Map outlineMapGet;
795 outlineMapSet["color"] = Color::RED;
796 outlineMapSet["width"] = 2.0f;
798 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
800 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
801 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
802 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
804 // Check the input outline property
805 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
806 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
808 // Check the smooth scroll property
809 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
810 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
811 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
813 // Check the smooth scroll duration property
814 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
815 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
817 // Check the scroll bar property
818 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
819 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
820 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
822 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
823 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
824 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
825 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
827 // Check the pixel size of font
828 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
829 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
831 // Check placeholder text properties.
832 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
833 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
835 // Check placeholder text's color property.
836 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
837 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
839 // Check the enable selection property
840 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
841 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
843 // Check the placeholder property with pixel size
844 Property::Map placeholderPixelSizeMapSet;
845 Property::Map placeholderPixelSizeMapGet;
846 Property::Map placeholderFontstyleMap;
847 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
848 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
849 placeholderPixelSizeMapSet["color"] = Color::BLUE;
850 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
851 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
853 placeholderFontstyleMap.Insert( "weight", "bold" );
854 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
855 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
857 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
858 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
860 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
861 Property::Map placeholderConversionMap;
862 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
863 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
864 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
865 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
866 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
867 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
869 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
871 // Check the placeholder property with point size
872 Property::Map placeholderMapSet;
873 Property::Map placeholderMapGet;
874 placeholderMapSet["text"] = "Setting Placeholder Text";
875 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
876 placeholderMapSet["color"] = Color::RED;
877 placeholderMapSet["fontFamily"] = "Arial";
878 placeholderMapSet["pointSize"] = 12.0f;
879 // Check the placeholder font style property
880 placeholderFontstyleMap.Clear();
882 placeholderFontstyleMap.Insert( "weight", "bold" );
883 placeholderFontstyleMap.Insert( "width", "condensed" );
884 placeholderFontstyleMap.Insert( "slant", "italic" );
885 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
886 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
888 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
889 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
891 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
892 placeholderConversionMap.Clear();
893 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
894 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
895 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
896 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
897 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
898 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
899 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
902 placeholderFontstyleMap.Clear();
903 placeholderFontstyleMap.Insert( "weight", "normal" );
904 placeholderFontstyleMap.Insert( "slant", "oblique" );
905 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
906 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
908 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
909 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
910 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
911 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
913 placeholderFontstyleMap.Clear();
914 placeholderFontstyleMap.Insert( "slant", "roman" );
915 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
916 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
918 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
920 placeholderFontstyleMap.Clear();
921 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
923 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
924 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
925 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
926 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
927 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
929 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
930 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
932 // Check handle color
933 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
934 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
936 // Test the ENABLE_GRAB_HANDLE_POPUP property
937 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
938 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
940 // Check the input method setting
941 Property::Map propertyMap;
942 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
943 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
944 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
945 int inputVariation = 1;
946 propertyMap["PANEL_LAYOUT"] = panelLayout;
947 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
948 propertyMap["BUTTON_ACTION"] = buttonAction;
949 propertyMap["VARIATION"] = inputVariation;
950 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
952 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
954 DALI_TEST_CHECK( value.Get( map ) );
957 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
958 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
961 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
962 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
965 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
966 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
969 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
970 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
972 application.SendNotification();
973 application.Render();
978 // Positive Atlas Text Renderer test
979 int utcDaliTextEditorAtlasRenderP(void)
981 ToolkitTestApplication application;
982 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
983 StyleManager styleManager = StyleManager::Get();
984 styleManager.ApplyDefaultTheme();
985 TextEditor editor = TextEditor::New();
986 DALI_TEST_CHECK( editor );
988 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
990 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
992 application.GetScene().Add( editor );
996 // Render some text with the shared atlas backend
997 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
998 application.SendNotification();
999 application.Render();
1003 tet_result(TET_FAIL);
1008 // Positive test for the anchorClicked signal.
1009 int utcDaliTextEditorAnchorClickedP(void)
1011 ToolkitTestApplication application;
1012 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1013 TextEditor editor = TextEditor::New();
1014 DALI_TEST_CHECK(editor);
1016 application.GetScene().Add(editor);
1018 // connect to the anchor clicked signal.
1019 ConnectionTracker* testTracker = new ConnectionTracker();
1020 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1021 bool anchorClickedSignal = false;
1022 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1024 gAnchorClickedCallBackCalled = false;
1025 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1026 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1027 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1028 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1029 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1031 application.SendNotification();
1032 application.Render();
1033 editor.SetKeyInputFocus();
1035 // Create a tap event to touch the text editor.
1036 TestGenerateTap(application, 5.0f, 5.0f);
1037 application.SendNotification();
1038 application.Render();
1040 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1041 DALI_TEST_CHECK(anchorClickedSignal);
1043 gAnchorClickedCallBackNotCalled = true;
1044 // Tap the outside of anchor, callback should not be called.
1045 TestGenerateTap(application, 150.f, 100.f);
1046 application.SendNotification();
1047 application.Render();
1049 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1054 // Positive test for the textChanged signal.
1055 int utcDaliTextEditorTextChangedP(void)
1057 ToolkitTestApplication application;
1058 tet_infoline(" utcDaliTextEditorTextChangedP");
1059 TextEditor editor = TextEditor::New();
1060 DALI_TEST_CHECK( editor );
1062 application.GetScene().Add( editor );
1064 // connect to the text changed signal.
1065 ConnectionTracker* testTracker = new ConnectionTracker();
1066 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1067 bool textChangedSignal = false;
1068 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1070 gTextChangedCallBackCalled = false;
1071 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1072 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1073 DALI_TEST_CHECK( textChangedSignal );
1075 application.SendNotification();
1076 editor.SetKeyInputFocus();
1078 gTextChangedCallBackCalled = false;
1079 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1080 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1083 editor.SetProperty( TextField::Property::TEXT, "" );
1085 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1086 gTextChangedCallBackCalled = false;
1087 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1088 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1090 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1091 gTextChangedCallBackCalled = false;
1092 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1093 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1098 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1100 ToolkitTestApplication application;
1101 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1102 TextEditor editor = TextEditor::New();
1103 DALI_TEST_CHECK( editor );
1106 application.GetScene().Add( editor );
1108 // connect to the text changed signal.
1109 ConnectionTracker* testTracker = new ConnectionTracker();
1110 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1111 bool textChangedSignal = false;
1112 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1115 // get InputMethodContext
1117 InputMethodContext::EventData imfEvent;
1118 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1120 editor.SetKeyInputFocus();
1121 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1124 gTextChangedCallBackCalled = false;
1125 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1126 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1127 application.SendNotification();
1128 application.Render();
1129 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1130 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1132 gTextChangedCallBackCalled = false;
1133 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1134 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1135 application.SendNotification();
1136 application.Render();
1137 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1138 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1140 gTextChangedCallBackCalled = false;
1141 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1142 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1143 application.SendNotification();
1144 application.Render();
1145 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1146 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1148 gTextChangedCallBackCalled = false;
1149 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1150 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1151 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1153 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1154 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1155 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1157 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1158 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1159 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1161 application.SendNotification();
1162 application.Render();
1163 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1164 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1170 int utcDaliTextEditorInputStyleChanged01(void)
1172 // The text-editor emits signals when the input style changes. These changes of style are
1173 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1174 // can't be emitted during the size negotiation as the callbacks may update the UI.
1175 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1176 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1177 ToolkitTestApplication application;
1178 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1182 char* pathNamePtr = get_current_dir_name();
1183 const std::string pathName( pathNamePtr );
1184 free( pathNamePtr );
1186 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1187 fontClient.SetDpi( 93u, 93u );
1189 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1190 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1192 TextEditor editor = TextEditor::New();
1193 DALI_TEST_CHECK( editor );
1196 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1197 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1198 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1200 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1201 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1203 // connect to the text changed signal.
1204 ConnectionTracker* testTracker = new ConnectionTracker();
1205 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1206 bool inputStyleChangedSignal = false;
1207 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1209 application.GetScene().Add( editor );
1211 // Render and notify
1212 application.SendNotification();
1213 application.Render();
1215 // Executes the idle callbacks added by the text control on the change of input style.
1216 application.RunIdles();
1218 gInputStyleChangedCallbackCalled = false;
1219 gInputStyleMask = TextEditor::InputStyle::NONE;
1220 inputStyleChangedSignal = false;
1222 // Create a tap event to touch the text editor.
1223 TestGenerateTap( application, 18.0f, 25.0f );
1225 // Render and notify
1226 application.SendNotification();
1227 application.Render();
1229 // Executes the idle callbacks added by the text control on the change of input style.
1230 application.RunIdles();
1232 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1233 if( gInputStyleChangedCallbackCalled )
1235 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1237 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1238 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1240 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1241 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1243 DALI_TEST_CHECK( inputStyleChangedSignal );
1245 gInputStyleChangedCallbackCalled = false;
1246 gInputStyleMask = TextEditor::InputStyle::NONE;
1247 inputStyleChangedSignal = false;
1249 // Create a tap event to touch the text editor.
1250 TestGenerateTap( application, 30.0f, 25.0f );
1252 // Render and notify
1253 application.SendNotification();
1254 application.Render();
1256 // Executes the idle callbacks added by the text control on the change of input style.
1257 application.RunIdles();
1259 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1260 DALI_TEST_CHECK( !inputStyleChangedSignal );
1262 gInputStyleChangedCallbackCalled = false;
1263 gInputStyleMask = TextEditor::InputStyle::NONE;
1264 inputStyleChangedSignal = false;
1266 // Create a tap event to touch the text editor.
1267 TestGenerateTap( application, 43.0f, 25.0f );
1269 // Render and notify
1270 application.SendNotification();
1271 application.Render();
1273 // Executes the idle callbacks added by the text control on the change of input style.
1274 application.RunIdles();
1276 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1277 if( gInputStyleChangedCallbackCalled )
1279 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1281 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1282 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1284 DALI_TEST_CHECK( inputStyleChangedSignal );
1286 gInputStyleChangedCallbackCalled = false;
1287 gInputStyleMask = TextEditor::InputStyle::NONE;
1288 inputStyleChangedSignal = false;
1290 // Create a tap event to touch the text editor.
1291 TestGenerateTap( application, 88.0f, 25.0f );
1293 // Render and notify
1294 application.SendNotification();
1295 application.Render();
1297 // Executes the idle callbacks added by the text control on the change of input style.
1298 application.RunIdles();
1300 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1301 if( gInputStyleChangedCallbackCalled )
1303 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1305 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1306 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1308 Property::Map fontStyleMapSet;
1309 Property::Map fontStyleMapGet;
1311 fontStyleMapSet.Insert( "weight", "bold" );
1313 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1314 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1315 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1317 DALI_TEST_CHECK( inputStyleChangedSignal );
1319 gInputStyleChangedCallbackCalled = false;
1320 gInputStyleMask = TextEditor::InputStyle::NONE;
1321 inputStyleChangedSignal = false;
1323 // Create a tap event to touch the text editor.
1324 TestGenerateTap( application, 115.0f, 25.0f );
1326 // Render and notify
1327 application.SendNotification();
1328 application.Render();
1330 // Executes the idle callbacks added by the text control on the change of input style.
1331 application.RunIdles();
1333 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1334 DALI_TEST_CHECK( !inputStyleChangedSignal );
1336 gInputStyleChangedCallbackCalled = false;
1337 gInputStyleMask = TextEditor::InputStyle::NONE;
1338 inputStyleChangedSignal = false;
1340 // Create a tap event to touch the text editor.
1341 TestGenerateTap( application, 164.0f, 25.0f );
1343 // Render and notify
1344 application.SendNotification();
1345 application.Render();
1347 // Executes the idle callbacks added by the text control on the change of input style.
1348 application.RunIdles();
1350 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1351 if( gInputStyleChangedCallbackCalled )
1353 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1355 Property::Map fontStyleMapSet;
1356 Property::Map fontStyleMapGet;
1358 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1359 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1360 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1362 DALI_TEST_CHECK( inputStyleChangedSignal );
1364 gInputStyleChangedCallbackCalled = false;
1365 gInputStyleMask = TextEditor::InputStyle::NONE;
1366 inputStyleChangedSignal = false;
1368 // Create a tap event to touch the text editor.
1369 TestGenerateTap( application, 191.0f, 25.0f );
1371 // Render and notify
1372 application.SendNotification();
1373 application.Render();
1375 // Executes the idle callbacks added by the text control on the change of input style.
1376 application.RunIdles();
1378 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1379 DALI_TEST_CHECK( !inputStyleChangedSignal );
1384 int utcDaliTextEditorInputStyleChanged02(void)
1386 // The text-editor emits signals when the input style changes. These changes of style are
1387 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1388 // can't be emitted during the size negotiation as the callbacks may update the UI.
1389 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1390 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1391 ToolkitTestApplication application;
1392 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1396 char* pathNamePtr = get_current_dir_name();
1397 const std::string pathName( pathNamePtr );
1398 free( pathNamePtr );
1400 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1401 fontClient.SetDpi( 93u, 93u );
1403 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1404 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1406 TextEditor editor = TextEditor::New();
1407 DALI_TEST_CHECK( editor );
1410 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1411 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1412 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1414 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1415 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>" );
1417 // connect to the text changed signal.
1418 ConnectionTracker* testTracker = new ConnectionTracker();
1419 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1420 bool inputStyleChangedSignal = false;
1421 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1423 application.GetScene().Add( editor );
1425 // Render and notify
1426 application.SendNotification();
1427 application.Render();
1429 // Executes the idle callbacks added by the text control on the change of input style.
1430 application.RunIdles();
1432 gInputStyleChangedCallbackCalled = false;
1433 gInputStyleMask = TextEditor::InputStyle::NONE;
1434 inputStyleChangedSignal = false;
1436 // Create a tap event to touch the text editor.
1437 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1438 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1440 // Render and notify
1441 application.SendNotification();
1442 application.Render();
1444 // Executes the idle callbacks added by the text control on the change of input style.
1445 application.RunIdles();
1447 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1448 if( gInputStyleChangedCallbackCalled )
1450 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1451 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1452 TextEditor::InputStyle::POINT_SIZE |
1453 TextEditor::InputStyle::COLOR ),
1456 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1457 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1459 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1460 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1462 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1463 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1465 DALI_TEST_CHECK( inputStyleChangedSignal );
1467 gInputStyleChangedCallbackCalled = false;
1468 gInputStyleMask = TextEditor::InputStyle::NONE;
1469 inputStyleChangedSignal = false;
1471 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1473 // Render and notify
1474 application.SendNotification();
1475 application.Render();
1477 // Executes the idle callbacks added by the text control on the change of input style.
1478 application.RunIdles();
1480 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1481 if( gInputStyleChangedCallbackCalled )
1483 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1484 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1487 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1488 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1490 DALI_TEST_CHECK( inputStyleChangedSignal );
1492 gInputStyleChangedCallbackCalled = false;
1493 gInputStyleMask = TextEditor::InputStyle::NONE;
1494 inputStyleChangedSignal = false;
1496 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1498 // Render and notify
1499 application.SendNotification();
1500 application.Render();
1502 // Executes the idle callbacks added by the text control on the change of input style.
1503 application.RunIdles();
1505 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1506 DALI_TEST_CHECK( !inputStyleChangedSignal );
1508 gInputStyleChangedCallbackCalled = false;
1509 gInputStyleMask = TextEditor::InputStyle::NONE;
1510 inputStyleChangedSignal = false;
1512 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1514 // Render and notify
1515 application.SendNotification();
1516 application.Render();
1518 // Executes the idle callbacks added by the text control on the change of input style.
1519 application.RunIdles();
1521 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1522 if( gInputStyleChangedCallbackCalled )
1524 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1525 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1528 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1529 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1531 DALI_TEST_CHECK( inputStyleChangedSignal );
1533 gInputStyleChangedCallbackCalled = false;
1534 gInputStyleMask = TextEditor::InputStyle::NONE;
1535 inputStyleChangedSignal = false;
1537 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1539 Property::Map fontStyleMapSet;
1540 fontStyleMapSet.Insert( "weight", "thin" );
1541 fontStyleMapSet.Insert( "width", "condensed" );
1542 fontStyleMapSet.Insert( "slant", "italic" );
1544 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1545 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1546 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1548 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1549 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1550 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1551 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1553 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 // Executes the idle callbacks added by the text control on the change of input style.
1560 application.RunIdles();
1562 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1563 DALI_TEST_CHECK( !inputStyleChangedSignal );
1565 // Create a tap event to touch the text editor.
1566 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1568 // Render and notify
1569 application.SendNotification();
1570 application.Render();
1572 // Executes the idle callbacks added by the text control on the change of input style.
1573 application.RunIdles();
1575 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1576 if( gInputStyleChangedCallbackCalled )
1578 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1579 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1580 TextEditor::InputStyle::POINT_SIZE |
1581 TextEditor::InputStyle::FONT_STYLE |
1582 TextEditor::InputStyle::LINE_SPACING |
1583 TextEditor::InputStyle::UNDERLINE |
1584 TextEditor::InputStyle::SHADOW |
1585 TextEditor::InputStyle::EMBOSS |
1586 TextEditor::InputStyle::OUTLINE ),
1589 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1590 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1592 DALI_TEST_CHECK( inputStyleChangedSignal );
1594 gInputStyleChangedCallbackCalled = false;
1595 gInputStyleMask = TextEditor::InputStyle::NONE;
1596 inputStyleChangedSignal = false;
1598 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1600 fontStyleMapSet.Clear();
1601 fontStyleMapSet.Insert( "weight", "black" );
1602 fontStyleMapSet.Insert( "width", "expanded" );
1603 fontStyleMapSet.Insert( "slant", "oblique" );
1605 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1607 // Create a tap event to touch the text editor.
1608 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1610 // Render and notify
1611 application.SendNotification();
1612 application.Render();
1614 // Executes the idle callbacks added by the text control on the change of input style.
1615 application.RunIdles();
1617 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1618 if( gInputStyleChangedCallbackCalled )
1620 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1621 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1622 TextEditor::InputStyle::POINT_SIZE |
1623 TextEditor::InputStyle::FONT_STYLE ),
1626 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1627 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1629 DALI_TEST_CHECK( inputStyleChangedSignal );
1634 int utcDaliTextEditorEvent01(void)
1636 ToolkitTestApplication application;
1637 tet_infoline(" utcDaliTextEditorEvent01");
1639 // Creates a tap event. After creating a tap event the text editor should
1640 // have the focus and add text with key events should be possible.
1642 TextEditor editor = TextEditor::New();
1643 DALI_TEST_CHECK( editor );
1645 application.GetScene().Add( editor );
1647 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1648 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1649 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1651 // Avoid a crash when core load gl resources.
1652 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1654 // Render and notify
1655 application.SendNotification();
1656 application.Render();
1658 // Add a key event but as the text editor has not the focus it should do nothing.
1659 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1667 // Create a tap event to touch the text editor.
1668 TestGenerateTap( application, 150.0f, 25.0f );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 // Now the text editor has the focus, so it can handle the key events.
1675 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1676 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1682 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1684 // Create a second text editor and send key events to it.
1685 TextEditor editor2 = TextEditor::New();
1687 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1688 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1689 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1690 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1692 application.GetScene().Add( editor2 );
1694 // Render and notify
1695 application.SendNotification();
1696 application.Render();
1698 // Create a tap event on the second text editor.
1699 TestGenerateTap( application, 150.0f, 125.0f );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 // The second text editor has the focus. It should handle the key events.
1706 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1707 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 // Check the text has been added to the second text editor.
1714 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1719 int utcDaliTextEditorEvent02(void)
1721 ToolkitTestApplication application;
1722 tet_infoline(" utcDaliTextEditorEvent02");
1724 // Checks if the right number of actors are created.
1726 TextEditor editor = TextEditor::New();
1727 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1728 DALI_TEST_CHECK( editor );
1730 application.GetScene().Add( editor );
1732 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1733 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1734 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1736 // Avoid a crash when core load gl resources.
1737 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 // Check there are the expected number of children (the stencil).
1744 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1746 Actor stencil = editor.GetChildAt( 0u );
1748 // Create a tap event to touch the text editor.
1749 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1755 Actor layer = editor.GetChildAt( 1u );
1756 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1757 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1759 // Now the text editor has the focus, so it can handle the key events.
1760 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1761 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1763 // Render and notify
1764 application.SendNotification();
1765 application.Render();
1767 // Checks the cursor and the renderer have been created.
1768 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1769 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1771 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1772 DALI_TEST_CHECK( cursor );
1774 // The stencil actor has a container with all the actors which contain the text renderers.
1775 Actor container = stencil.GetChildAt( 0u );
1776 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1778 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1779 DALI_TEST_CHECK( renderer );
1782 // Move the cursor and check the position changes.
1783 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1785 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1786 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1794 DALI_TEST_CHECK( position2.x < position1.x );
1796 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1797 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1799 // Render and notify
1800 application.SendNotification();
1801 application.Render();
1803 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1805 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1807 // Send some taps and check the cursor positions.
1809 // Try to tap at the beginning.
1810 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1816 // Cursor position should be the same than position1.
1817 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1819 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1821 // Tap away from the start position.
1822 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1824 // Render and notify
1825 application.SendNotification();
1826 application.Render();
1828 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1830 DALI_TEST_CHECK( position5.x > position4.x );
1832 // Remove all the text.
1833 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1834 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1835 editor.SetProperty( TextEditor::Property::TEXT, "" );
1837 // Render and notify
1838 application.SendNotification();
1839 application.Render();
1841 // Cursor position should be the same than position2.
1842 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1844 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1846 // Should not be a renderer.
1847 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1852 int utcDaliTextEditorEvent03(void)
1854 ToolkitTestApplication application;
1855 tet_infoline(" utcDaliTextEditorEvent03");
1857 // Checks if the highlight actor is created.
1859 TextEditor editor = TextEditor::New();
1860 DALI_TEST_CHECK( editor );
1862 application.GetScene().Add( editor );
1864 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1865 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1866 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1867 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1868 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1870 // Avoid a crash when core load gl resources.
1871 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1877 // Send some taps and check text controller with clipboard window
1878 Dali::Clipboard clipboard = Clipboard::Get();
1879 clipboard.ShowClipboard();
1880 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1881 clipboard.HideClipboard();
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 // Tap first to get the focus.
1888 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1890 // Render and notify
1891 application.SendNotification();
1892 application.Render();
1894 // Double tap to select a word.
1895 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1897 // Render and notify
1898 application.SendNotification();
1899 application.Render();
1901 // The stencil actor should have two actors: the renderer and the highlight actor.
1902 Actor stencil = editor.GetChildAt( 0u );
1904 // Highlight needs to be drawn before text, so should come first in child order
1905 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1906 DALI_TEST_CHECK( highlight );
1908 // The stencil actor has a container with all the actors which contain the text renderers.
1909 Actor container = stencil.GetChildAt( 1u );
1910 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1912 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1913 DALI_TEST_CHECK( renderer );
1916 // Double tap out of bounds
1917 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1918 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1920 // Render and notify
1921 application.SendNotification();
1922 application.Render();
1924 // The stencil actor should have one actors: the renderer actor.
1925 stencil = editor.GetChildAt( 0u );
1927 // The stencil actor has a container with all the actors which contain the text renderers.
1928 container = stencil.GetChildAt( 0u );
1929 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1931 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1932 DALI_TEST_CHECK( renderer );
1936 TestGenerateLongPress(application, 1.0f, 25.0f);
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1943 TestGenerateMiniPan(application);
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1952 int utcDaliTextEditorEvent04(void)
1954 ToolkitTestApplication application;
1955 tet_infoline(" utcDaliTextEditorEvent04");
1957 // Checks if the highlight actor is created.
1959 TextEditor editor = TextEditor::New();
1960 DALI_TEST_CHECK( editor );
1962 application.GetScene().Add( editor );
1964 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1965 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1966 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1967 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1968 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1970 // Avoid a crash when core load gl resources.
1971 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1973 // Render and notify
1974 application.SendNotification();
1975 application.Render();
1977 // Tap on the text editor
1978 TestGenerateTap( application, 3.0f, 25.0f );
1980 // Render and notify
1981 application.SendNotification();
1982 application.Render();
1984 // Move at the end of the text.
1985 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1986 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 for( unsigned int index = 0u; index < 10u; ++index )
1994 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1995 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1997 // Render and notify
1998 application.SendNotification();
1999 application.Render();
2003 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2005 // Render and notify
2006 application.SendNotification();
2007 application.Render();
2009 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2011 // Add some key events
2012 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2013 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2015 // Render and notify
2016 application.SendNotification();
2017 application.Render();
2019 for( unsigned int index = 0u; index < 10u; ++index )
2021 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2022 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2024 // Render and notify
2025 application.SendNotification();
2026 application.Render();
2030 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2032 // Render and notify
2033 application.SendNotification();
2034 application.Render();
2036 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2041 int utcDaliTextEditorEvent05(void)
2043 ToolkitTestApplication application;
2044 tet_infoline(" utcDaliTextEditorEvent05");
2046 // Checks if the highlight actor is created.
2048 TextEditor editor = TextEditor::New();
2049 DALI_TEST_CHECK( editor );
2051 application.GetScene().Add( editor );
2053 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2054 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2055 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2056 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2057 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2058 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2059 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2060 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2061 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2062 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2064 // Avoid a crash when core load gl resources.
2065 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2067 // Render and notify
2068 application.SendNotification();
2069 application.Render();
2071 // Tap on the text editor
2072 TestGenerateTap( application, 3.0f, 25.0f );
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2078 // Move at the end of the text.
2079 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082 // Render and notify
2083 application.SendNotification();
2084 application.Render();
2086 for( unsigned int index = 0u; index < 10u; ++index )
2089 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 // Render and notify
2092 application.SendNotification();
2093 application.Render();
2095 // Modify duration after scroll is enabled
2096 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2098 // Continuous scroll left to increase coverage
2099 for( unsigned int index = 0u; index < 10u; ++index )
2101 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2103 // Render and notify
2104 application.SendNotification();
2105 application.Render();
2107 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2108 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2109 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2110 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2111 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2113 // Press Escape to increase coverage
2114 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2115 application.SendNotification();
2116 application.Render();
2118 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2123 int utcDaliTextEditorEvent06(void)
2125 ToolkitTestApplication application;
2126 tet_infoline(" utcDaliTextEditorEvent06");
2128 // Checks if the highlight actor is created.
2130 TextEditor editor = TextEditor::New();
2131 DALI_TEST_CHECK( editor );
2133 application.GetScene().Add( editor );
2135 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2136 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2137 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2138 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2139 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2141 // Avoid a crash when core load gl resources.
2142 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 // Tap on the text editor
2149 TestGenerateTap( application, 3.0f, 25.0f );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 // Move to seconds line of the text.
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 float layoutHeight = editor.GetHeightForWidth( 100.f );
2165 // Add another script characters ( glyph height is defferent )
2166 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2167 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169 // Delete characters
2170 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2171 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2173 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2182 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2183 application.SendNotification();
2184 application.Render();
2186 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2187 application.SendNotification();
2188 application.Render();
2190 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 application.SendNotification();
2192 application.Render();
2194 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2195 application.SendNotification();
2196 application.Render();
2198 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2199 application.SendNotification();
2200 application.Render();
2202 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.SendNotification();
2204 application.Render();
2206 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2207 application.SendNotification();
2208 application.Render();
2213 int utcDaliTextEditorEvent07(void)
2215 ToolkitTestApplication application;
2216 tet_infoline(" utcDaliTextEditorEvent07");
2218 // Checks if the highlight actor is created.
2220 TextEditor editor = TextEditor::New();
2221 DALI_TEST_CHECK( editor );
2223 application.GetScene().Add( editor );
2225 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2226 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2227 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2228 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2229 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2231 // Avoid a crash when core load gl resources.
2232 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2234 // Render and notify
2235 application.SendNotification();
2236 application.Render();
2238 // Tap on the text editor
2239 TestGenerateTap( application, 3.0f, 25.0f );
2241 // Render and notify
2242 application.SendNotification();
2243 application.Render();
2245 // Move to second line of the text.
2246 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2248 // Render and notify
2249 application.SendNotification();
2250 application.Render();
2252 // Select some text in the right of the current cursor position
2253 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2258 // Render and notify
2259 application.SendNotification();
2260 application.Render();
2262 // Cut the selected text
2263 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 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 ) );
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2270 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2272 // Select some text in the left of the current cursor position
2273 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2274 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 // Copy the selected text
2283 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284 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 ) );
2286 // Render and notify
2287 application.SendNotification();
2288 application.Render();
2290 // Move the cursor to the third line
2291 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2294 // Render and notify
2295 application.SendNotification();
2296 application.Render();
2298 // Paste the selected text at the current cursor position
2299 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2300 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 ) );
2302 // Render and notify
2303 application.SendNotification();
2304 application.Render();
2306 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2309 // Disable Shift Selection
2310 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2312 // Test to select some text in the right of the current cursor position
2313 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2322 // Cut the selected text
2323 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 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 ) );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2330 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2331 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2333 // Test to select some text in the left of the current cursor position
2334 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2337 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
2343 // Copy the selected text
2344 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 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 ) );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2352 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2355 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 ) );
2357 // Render and notify
2358 application.SendNotification();
2359 application.Render();
2361 // replace text with "c"
2362 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364 // Render and notify
2365 application.SendNotification();
2366 application.Render();
2369 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2372 DevelTextEditor::SelectWholeText(editor);
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2378 // Copy the selected text using logical keys
2379 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 // Render and notify
2383 application.SendNotification();
2384 application.Render();
2387 DevelTextEditor::SelectNone(editor);
2389 // Render and notify
2390 application.SendNotification();
2391 application.Render();
2393 // Paste the selected using logical keys
2394 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2398 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2400 // select all using logical keys
2401 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2402 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // cut text using logical keys
2409 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2410 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2417 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2422 int utcDaliTextEditorEvent08(void)
2424 ToolkitTestApplication application;
2425 tet_infoline(" utcDaliTextEditorEvent08");
2427 // Checks if the highlight actor is released correctly.
2429 TextEditor editor = TextEditor::New();
2430 DALI_TEST_CHECK( editor );
2432 application.GetScene().Add( editor );
2434 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2435 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2436 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2437 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2438 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2440 // Avoid a crash when core load gl resources.
2441 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2443 // Render and notify
2444 application.SendNotification();
2445 application.Render();
2447 // Tap on the text editor
2448 TestGenerateTap( application, 3.0f, 25.0f );
2450 // Render and notify
2451 application.SendNotification();
2452 application.Render();
2454 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2455 // Test to select some text in the left of the current cursor position
2456 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2458 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 // Test to the left selection handle position and the right selection handle position
2466 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2468 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 // Test to select full text in the left of the current cursor position
2476 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2477 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2478 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2479 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2481 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2483 // Render and notify
2484 application.SendNotification();
2485 application.Render();
2487 // Test to release the current full text selection
2488 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2489 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2491 // Render and notify
2492 application.SendNotification();
2493 application.Render();
2495 // Test to move the current cursor position correctly
2496 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2498 // Render and notify
2499 application.SendNotification();
2500 application.Render();
2503 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2511 // Test to select some text in the right of the current cursor position
2512 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2513 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2514 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2520 // Test the cursor position with right arrow key
2521 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2528 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2536 // Test to select some text in the left of the current cursor position
2537 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2539 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2540 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2541 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2543 // Render and notify
2544 application.SendNotification();
2545 application.Render();
2547 // Test the cursor position with left arrow key
2548 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2550 // Render and notify
2551 application.SendNotification();
2552 application.Render();
2555 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2561 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2563 // Test to select some text in the right of the current cursor position
2564 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2566 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2567 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2569 // Render and notify
2570 application.SendNotification();
2571 application.Render();
2573 // Test the cursor position with left arrow key
2574 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2581 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 // Render and notify
2584 application.SendNotification();
2585 application.Render();
2587 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2589 // Test to select some text in the left of the current cursor position
2590 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2591 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2592 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2593 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2595 // Render and notify
2596 application.SendNotification();
2597 application.Render();
2599 // Test the cursor position with right arrow key
2600 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2602 // Render and notify
2603 application.SendNotification();
2604 application.Render();
2607 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2609 // Render and notify
2610 application.SendNotification();
2611 application.Render();
2613 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2618 int utcDaliTextEditorHandles(void)
2620 ToolkitTestApplication application;
2621 tet_infoline(" utcDaliTextEditorHandles");
2623 TextEditor editor = TextEditor::New();
2624 DALI_TEST_CHECK( editor );
2626 application.GetScene().Add( editor );
2628 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2629 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2630 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2631 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2633 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2634 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2635 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2636 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2638 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2639 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2640 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2642 // Avoid a crash when core load gl resources.
2643 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2645 // Render and notify
2646 application.SendNotification();
2647 application.Render();
2649 // Tap first to get the focus.
2650 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2656 // Tap to create the grab handle.
2657 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2659 // Render and notify
2660 application.SendNotification();
2661 application.Render();
2663 // Get the active layer where the text's decoration is added.
2664 Actor activeLayer = editor.GetChildAt( 1u );
2666 // Get the handle's actor.
2667 Actor handle = activeLayer.GetChildAt( 1u );
2668 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2670 // Render and notify
2671 application.SendNotification();
2672 application.Render();
2674 // Touch the grab handle to set it as pressed.
2675 Vector2 touchPos( 10.0f, 50.0f );
2676 Dali::Integration::TouchEvent event;
2677 event = Dali::Integration::TouchEvent();
2678 event.AddPoint( GetPointDownInside( touchPos ) );
2679 application.ProcessEvent( event );
2681 // Render and notify
2682 application.SendNotification();
2683 application.Render();
2685 // Pan the grab handle
2686 uint32_t time = 100;
2687 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2688 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2689 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2690 application.SendNotification();
2691 application.Render();
2694 // Release the grab handle.
2695 event = Dali::Integration::TouchEvent();
2696 event.AddPoint( GetPointUpInside( touchPos ) );
2697 application.ProcessEvent( event );
2699 // Render and notify
2700 application.SendNotification();
2701 application.Render();
2703 // Tap first to get the focus.
2704 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2706 // Render and notify
2707 application.SendNotification();
2708 application.Render();
2710 // Double tap to select a word and create the selection handles.
2711 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2713 // Render and notify
2714 application.SendNotification();
2715 application.Render();
2717 touchPos = Vector2( 10.0f, 50.0f );
2719 // Touch the left selection handle to set it as pressed.
2720 event = Dali::Integration::TouchEvent();
2721 event.AddPoint( GetPointDownInside( touchPos ) );
2722 application.ProcessEvent( event );
2724 // Render and notify
2725 application.SendNotification();
2726 application.Render();
2728 // Release the left selection handle.
2729 event = Dali::Integration::TouchEvent();
2730 event.AddPoint( GetPointUpInside( touchPos ) );
2731 application.ProcessEvent( event );
2733 // Render and notify
2734 application.SendNotification();
2735 application.Render();
2740 int utcDaliTextEditorUnderPropertyStringP(void)
2742 ToolkitTestApplication application;
2743 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2744 TextEditor editor = TextEditor::New();
2745 DALI_TEST_CHECK( editor );
2747 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2749 application.GetScene().Add( editor );
2751 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2752 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2754 tet_infoline("Set underline settings with a map");
2755 // Check the input underline property
2756 Property::Map underlineMapSet;
2757 Property::Map underlineMapGet;
2758 underlineMapSet.Insert( "enable", true );
2759 underlineMapSet.Insert( "color", Color::BLUE );
2760 underlineMapSet.Insert( "height", 2 );
2762 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2763 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2764 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2765 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2767 tet_infoline("Set underline settings with a string");
2768 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2769 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2772 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2774 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2775 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2776 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2777 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2779 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2784 int utcDaliTextEditorShadowPropertyStringP(void)
2786 ToolkitTestApplication application;
2787 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2789 TextEditor editor = TextEditor::New();
2791 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2793 application.GetScene().Add( editor );
2795 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2797 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2801 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2806 int utcDaliTextEditorFontStylePropertyStringP(void)
2808 ToolkitTestApplication application;
2809 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2811 TextEditor editor = TextEditor::New();
2813 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2815 application.GetScene().Add( editor );
2817 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2819 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2823 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2828 int utcDaliTextEditorGetPropertyLinecountP(void)
2830 ToolkitTestApplication application;
2832 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2836 TextEditor editor = TextEditor::New();
2837 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2838 editor.SetProperty( TextEditor::Property::TEXT,
2839 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2841 application.GetScene().Add( editor );
2843 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2844 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2845 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2847 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2848 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2849 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2854 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2857 ToolkitTestApplication application;
2858 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2860 TextEditor editor = TextEditor::New();
2861 DALI_TEST_CHECK( editor );
2863 application.GetScene().Add( editor );
2865 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2866 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2867 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2868 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2869 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2870 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2872 bool startedCalled = false;
2873 bool finishedCalled = false;
2875 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2876 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2878 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2880 // Render and notify
2881 application.SendNotification();
2882 application.Render();
2884 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2885 application.SendNotification();
2886 application.Render(6000);
2888 application.SendNotification();
2889 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2890 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2895 int UtcDaliToolkitTextEditorTextWrapMode(void)
2897 ToolkitTestApplication application;
2898 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2902 TextEditor editor = TextEditor::New();
2903 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2904 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2906 application.GetScene().Add( editor );
2908 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2909 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2911 application.SendNotification();
2912 application.Render();
2914 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2915 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2917 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2918 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2920 application.SendNotification();
2921 application.Render();
2923 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2924 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2926 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2927 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2929 application.SendNotification();
2930 application.Render();
2932 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2933 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2935 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2936 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2938 application.SendNotification();
2939 application.Render();
2941 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2942 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2947 int UtcDaliTextEditorSetPaddingProperty(void)
2949 ToolkitTestApplication application;
2950 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2952 TextEditor editor = TextEditor::New();
2953 DALI_TEST_CHECK( editor );
2954 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2955 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2956 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2957 application.GetScene().Add( editor );
2959 application.SendNotification();
2960 application.Render();
2962 Vector3 originalSize = editor.GetNaturalSize();
2964 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2966 application.SendNotification();
2967 application.Render();
2969 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2971 Vector3 paddingAddedSize = editor.GetNaturalSize();
2973 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2975 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2980 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2982 ToolkitTestApplication application;
2983 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2985 TextEditor editor = TextEditor::New();
2986 DALI_TEST_CHECK( editor );
2987 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2988 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2989 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2990 application.GetScene().Add( editor );
2992 application.SendNotification();
2993 application.Render();
2995 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2996 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2998 // Check the enable shift selection property
2999 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3000 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3002 application.SendNotification();
3003 application.Render();
3008 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3010 ToolkitTestApplication application;
3011 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3013 TextEditor editor = TextEditor::New();
3014 DALI_TEST_CHECK( editor );
3015 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3016 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3017 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3018 application.GetScene().Add( editor );
3020 application.SendNotification();
3021 application.Render();
3023 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3024 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3026 // Check the enable grab handle property
3027 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3028 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3030 application.SendNotification();
3031 application.Render();
3036 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3038 ToolkitTestApplication application;
3039 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3041 TextEditor editor = TextEditor::New();
3042 DALI_TEST_CHECK( editor );
3043 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3044 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3045 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3046 application.GetScene().Add( editor );
3048 application.SendNotification();
3049 application.Render();
3051 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3052 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3054 // Check the disable match system language direction property
3055 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3056 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3058 application.SendNotification();
3059 application.Render();
3064 int UtcDaliTextEditorGetInputMethodContext(void)
3066 ToolkitTestApplication application;
3067 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3069 TextEditor editor = TextEditor::New();
3070 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3075 int utcDaliTextEditorMaxCharactersReached(void)
3077 ToolkitTestApplication application;
3078 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3080 TextEditor editor = TextEditor::New();
3081 DALI_TEST_CHECK( editor );
3083 application.GetScene().Add( editor );
3085 const int maxNumberOfCharacters = 1;
3086 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3087 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3089 editor.SetKeyInputFocus();
3091 // connect to the text changed signal.
3092 ConnectionTracker* testTracker = new ConnectionTracker();
3093 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3094 bool maxLengthReachedSignal = false;
3095 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3097 gMaxCharactersCallBackCalled = false;
3099 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3100 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3102 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3103 DALI_TEST_CHECK( maxLengthReachedSignal );
3108 int UtcDaliTextEditorSelectWholeText(void)
3110 ToolkitTestApplication application;
3111 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3113 TextEditor textEditor = TextEditor::New();
3115 application.GetScene().Add( textEditor );
3117 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3118 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3119 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3121 // Avoid a crash when core load gl resources.
3122 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3124 application.SendNotification();
3125 application.Render();
3127 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3129 DevelTextEditor::SelectWholeText( textEditor );
3131 application.SendNotification();
3132 application.Render();
3134 // Nothing should have been selected. The number of children is still 1
3135 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3137 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3139 application.SendNotification();
3140 application.Render();
3142 DevelTextEditor::SelectWholeText( textEditor );
3144 application.SendNotification();
3145 application.Render();
3147 // Should be 2 children, the stencil and the layer
3148 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3150 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3151 Actor stencil = textEditor.GetChildAt( 0u );
3153 // The highlight actor is drawn first, so is the first actor in the list
3154 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3155 DALI_TEST_CHECK( highlight );
3160 int UtcDaliTextEditorSelectNone(void)
3162 ToolkitTestApplication application;
3163 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3165 TextEditor textEditor = TextEditor::New();
3167 application.GetScene().Add( textEditor );
3169 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3170 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3171 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3173 // Avoid a crash when core load gl resources.
3174 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3176 application.SendNotification();
3177 application.Render();
3179 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3181 application.SendNotification();
3182 application.Render();
3184 // Nothing is selected
3185 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3186 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3188 DevelTextEditor::SelectWholeText( textEditor );
3190 application.SendNotification();
3191 application.Render();
3193 // whole text is selected
3194 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3195 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3197 DevelTextEditor::SelectNone( textEditor );
3199 application.SendNotification();
3200 application.Render();
3202 // Nothing is selected
3203 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3204 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3209 int UtcDaliTextEditorSelectRange(void)
3211 ToolkitTestApplication application;
3212 tet_infoline("utcDaliTextEditorSelectRange");
3214 TextEditor textEditor = TextEditor::New();
3215 DALI_TEST_CHECK( textEditor );
3217 application.GetScene().Add( textEditor );
3219 // Avoid a crash when core load gl resources.
3220 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3222 application.SendNotification();
3223 application.Render();
3225 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3227 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3228 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3230 // Hello is selected
3231 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3232 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3234 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3235 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3240 int UtcDaliTextEditorEnableEditing(void)
3242 ToolkitTestApplication application;
3243 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3245 TextEditor textEditor = TextEditor::New();
3247 application.GetScene().Add( textEditor );
3249 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3250 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3251 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3253 // Avoid a crash when core load gl resources.
3254 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3256 application.SendNotification();
3257 application.Render();
3259 textEditor.SetKeyInputFocus();
3260 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3261 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3263 // Render and notify
3264 application.SendNotification();
3265 application.Render();
3267 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3268 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3270 textEditor.SetKeyInputFocus();
3271 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3272 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3274 // Render and notify
3275 application.SendNotification();
3276 application.Render();
3278 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3279 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3284 int UtcDaliTextEditorScrolling(void)
3286 ToolkitTestApplication application;
3287 tet_infoline(" UtcDaliTextEditorScrolling ");
3289 TextEditor textEditor = TextEditor::New();
3290 DALI_TEST_CHECK( textEditor );
3292 application.GetScene().Add( textEditor );
3294 // Avoid a crash when core load gl resources.
3295 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3297 application.SendNotification();
3298 application.Render();
3300 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3301 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3302 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3303 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3305 application.SendNotification();
3306 application.Render();
3308 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3309 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3312 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3314 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3315 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3317 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3319 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3320 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3322 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3323 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3325 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3326 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3331 int UtcDaliToolkitTextEditorFontSizeScale(void)
3333 ToolkitTestApplication application;
3334 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3336 TextEditor textEditor = TextEditor::New();
3337 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3338 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3339 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3341 TextEditor textEditorScaled = TextEditor::New();
3342 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3343 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3344 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3345 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3347 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3349 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3350 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3351 nonScaledSize = textEditor.GetNaturalSize();
3353 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3354 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3355 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3356 scaledSize = textEditorScaled.GetNaturalSize();
3358 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3363 int UtcDaliTextEditorPrimaryCursorPosition(void)
3365 ToolkitTestApplication application;
3366 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3368 TextEditor textEditor = TextEditor::New();
3370 application.GetScene().Add( textEditor );
3372 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3373 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3374 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3375 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3377 // Avoid a crash when core load gl resources.
3378 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3380 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3381 application.SendNotification();
3382 application.Render();
3384 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3386 // Render and notify
3387 application.SendNotification();
3388 application.Render();
3390 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3391 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3396 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3398 ToolkitTestApplication application;
3399 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3401 TextEditor textEditor = TextEditor::New();
3402 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3403 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3404 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3405 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3406 application.GetScene().Add( textEditor );
3408 application.SendNotification();
3409 application.Render();
3412 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3413 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3415 textEditor.GetNaturalSize();
3417 // Create a tap event to touch the text editor.
3418 TestGenerateTap( application, 18.0f, 25.0f );
3420 application.SendNotification();
3421 application.Render();
3423 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3424 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3430 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3432 ToolkitTestApplication application;
3434 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3436 int lineCountBefore =0 ;
3437 int lineCountAfter =0 ;
3439 // Create a text editor
3440 TextEditor textEditor = TextEditor::New();
3441 //Set very large font-size using point-size
3442 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3443 //Specify font-family
3444 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3446 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3447 //Set text longer than width of textEditor
3448 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3450 application.GetScene().Add( textEditor );
3452 application.SendNotification();
3453 application.Render();
3455 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3456 //GetHeightForWidth is a retrieval method which should not modify object
3457 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3458 textEditor.GetHeightForWidth(200.f);
3460 //This is to simulate focus into text editor after calling GetHeightForWidth
3461 //Create a tap event to touch the text editor.
3462 TestGenerateTap( application, 18.0f, 25.0f );
3464 application.SendNotification();
3465 application.Render();
3467 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3469 //The LineCount must not be changed when calling GetHeightForWidth.
3470 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3475 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3477 ToolkitTestApplication application;
3479 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3481 int lineCountBefore =0 ;
3482 int lineCountAfter =0 ;
3484 // Create a text editor
3485 TextEditor textEditor = TextEditor::New();
3486 //Set very large font-size using point-size
3487 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3488 //Specify font-family
3489 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3491 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3492 //Set text longer than width of textEditor
3493 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3494 //Set line wrap mode Character
3495 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3497 application.GetScene().Add( textEditor );
3499 application.SendNotification();
3500 application.Render();
3502 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3503 //GetHeightForWidth is a retrieval method which should not modify object
3504 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3505 textEditor.GetHeightForWidth(200.f);
3507 //This is to simulate focus into text editor after calling GetHeightForWidth
3508 //Create a tap event to touch the text editor.
3509 TestGenerateTap( application, 18.0f, 25.0f );
3511 application.SendNotification();
3512 application.Render();
3514 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3516 //The LineCount must not be changed when calling GetHeightForWidth.
3517 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3522 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3524 ToolkitTestApplication application;
3526 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3528 int lineCountBefore =0 ;
3529 int lineCountAfter =0 ;
3531 // Create a text editor
3532 TextEditor textEditor = TextEditor::New();
3533 //Set very large font-size using point-size
3534 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3535 //Specify font-family
3536 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3538 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3539 //Set text longer than width of textEditor
3540 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3541 //Set line wrap mode Character
3542 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3544 application.GetScene().Add( textEditor );
3546 application.SendNotification();
3547 application.Render();
3550 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3552 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3553 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3555 // When the text changed, the Line-count should be updated according to new text.
3556 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3557 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3558 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3565 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3567 ToolkitTestApplication application;
3569 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3571 int lineCountBefore =0 ;
3572 int lineCountAfter =0 ;
3574 // Create a text editor
3575 TextEditor textEditor = TextEditor::New();
3576 //Set very large font-size using point-size
3577 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3578 //Specify font-family
3579 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3581 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3582 //Set text longer than width of textEditor
3583 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3585 application.GetScene().Add( textEditor );
3587 application.SendNotification();
3588 application.Render();
3590 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3591 //GetNaturalSize is a retrieval method which should not modify object
3592 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3593 textEditor.GetNaturalSize();
3595 //This is to simulate focus into text editor after calling GetNaturalSize
3596 //Create a tap event to touch the text editor.
3597 TestGenerateTap( application, 18.0f, 25.0f );
3599 application.SendNotification();
3600 application.Render();
3602 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3604 //The LineCount must not be changed when calling GetNaturalSize.
3605 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3610 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3612 ToolkitTestApplication application;
3614 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3616 int lineCountBefore =0 ;
3617 int lineCountAfter =0 ;
3619 // Create a text editor
3620 TextEditor textEditor = TextEditor::New();
3621 //Set very large font-size using point-size
3622 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3623 //Specify font-family
3624 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3626 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3627 //Set text longer than width of textEditor
3628 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3629 //Set line wrap mode Character
3630 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3632 application.GetScene().Add( textEditor );
3634 application.SendNotification();
3635 application.Render();
3637 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3638 //GetNaturalSize is a retrieval method which should not modify object
3639 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3640 textEditor.GetNaturalSize( );
3642 //This is to simulate focus into text editor after calling GetNaturalSize
3643 //Create a tap event to touch the text editor.
3644 TestGenerateTap( application, 18.0f, 25.0f );
3646 application.SendNotification();
3647 application.Render();
3649 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3651 //The LineCount must not be changed when calling GetNaturalSize.
3652 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3657 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3659 ToolkitTestApplication application;
3660 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3662 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3663 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3664 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3666 // Create a text editor
3667 TextEditor textEditor = TextEditor::New();
3669 //Set size to avoid automatic eliding
3670 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3671 //Set very large font-size using point-size
3672 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3673 //Specify font-family
3674 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3675 //Set text to check if appear or not
3676 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3678 application.GetScene().Add( textEditor );
3680 application.SendNotification();
3681 application.Render();
3682 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3683 Vector3 naturalSize = textEditor.GetNaturalSize();
3685 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3686 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3691 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3693 ToolkitTestApplication application;
3694 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3696 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3697 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3698 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3700 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3701 // Create a text editor
3702 TextEditor textEditor = TextEditor::New();
3703 //Set size to avoid automatic eliding
3704 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3705 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3706 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3708 const int numberOfCases = 6;
3709 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3711 for (int index=0; index < numberOfCases; index++)
3713 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3714 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3715 application.GetScene().Add( textEditor );
3716 application.SendNotification();
3717 application.Render();
3718 naturalSize = textEditor.GetNaturalSize();
3719 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3720 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3727 int UtcDaliTextEditorHyphenWrapMode(void)
3729 ToolkitTestApplication application;
3730 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3733 TextEditor textEditor = TextEditor::New();
3735 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3737 application.GetScene().Add( textEditor );
3738 application.SendNotification();
3739 application.Render();
3741 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3742 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3743 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3745 application.SendNotification();
3746 application.Render();
3748 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3754 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3756 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3757 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3758 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3760 application.SendNotification();
3761 application.Render();
3763 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3770 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );