2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
32 #include "test-text-geometry-utils.h"
35 using namespace Toolkit;
37 void dali_texteditor_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_texteditor_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
58 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
59 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
60 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
61 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
63 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
64 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
66 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
73 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
74 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
75 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
76 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
77 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
78 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
79 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
81 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
82 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
83 const char* const PROPERTY_NAME_UNDERLINE = "underline";
84 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
85 const char* const PROPERTY_NAME_SHADOW = "shadow";
86 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
87 const char* const PROPERTY_NAME_EMBOSS = "emboss";
88 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
89 const char* const PROPERTY_NAME_OUTLINE = "outline";
90 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
93 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
94 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
95 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
96 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
97 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
98 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
100 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
105 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
109 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
110 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
111 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
113 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
114 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
116 const float RENDER_FRAME_INTERVAL = 16.66f;
118 const unsigned int DEFAULT_FONT_SIZE = 1152u;
119 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
123 const int KEY_C_CODE = 54;
124 const int KEY_V_CODE = 55;
125 const int KEY_X_CODE = 53;
126 const int KEY_WHITE_SPACE_CODE = 65;
128 const int KEY_SHIFT_MODIFIER = 257;
129 const int KEY_CONTROL_MODIFIER = 258;
131 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
132 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
133 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
135 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
137 static bool gSelectionChangedCallbackCalled;
138 static uint32_t oldSelectionStart;
139 static uint32_t oldSelectionEnd;
140 static bool gSelectionClearedCallbackCalled;
141 static bool gAnchorClickedCallBackCalled;
142 static bool gAnchorClickedCallBackNotCalled;
143 static bool gTextChangedCallBackCalled;
144 static bool gInputFilteredAcceptedCallbackCalled;
145 static bool gInputFilteredRejectedCallbackCalled;
146 static bool gInputStyleChangedCallbackCalled;
147 static bool gMaxCharactersCallBackCalled;
148 static bool gCursorPositionChangedCallbackCalled;
149 static uint32_t oldCursorPos;
150 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
152 struct CallbackFunctor
154 CallbackFunctor(bool* callbackFlag)
155 : mCallbackFlag( callbackFlag )
161 *mCallbackFlag = true;
166 static void TestSelectionClearedCallback(TextEditor control)
168 tet_infoline(" TestSelectionClearedCallback");
170 gSelectionClearedCallbackCalled = true;
173 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
175 tet_infoline(" TestSelectionChangedCallback");
177 gSelectionChangedCallbackCalled = true;
178 oldSelectionStart = oldStart;
179 oldSelectionEnd = oldEnd;
182 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
184 tet_infoline(" TestAnchorClickedCallback");
186 gAnchorClickedCallBackNotCalled = false;
188 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
190 gAnchorClickedCallBackCalled = true;
194 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
196 tet_infoline(" TestCursorPositionChangedCallback");
198 gCursorPositionChangedCallbackCalled = true;
199 oldCursorPos = oldPos;
202 static void TestTextChangedCallback( TextEditor control )
204 tet_infoline(" TestTextChangedCallback");
206 gTextChangedCallBackCalled = true;
209 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
211 tet_infoline(" TestInputStyleChangedCallback");
213 gInputStyleChangedCallbackCalled = true;
214 gInputStyleMask = mask;
217 static void TestMaxLengthReachedCallback( TextEditor control )
219 tet_infoline(" TestMaxLengthReachedCallback");
221 gMaxCharactersCallBackCalled = true;
224 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
226 tet_infoline(" TestInputFilteredCallback");
228 if(type == Toolkit::InputFilter::Property::ACCEPTED)
230 gInputFilteredAcceptedCallbackCalled = true;
232 else if(type == Toolkit::InputFilter::Property::REJECTED)
234 gInputFilteredRejectedCallbackCalled = true;
238 // Generate a KeyEvent to send to Core.
239 Integration::KeyEvent GenerateKey( const std::string& keyName,
240 const std::string& logicalKey,
241 const std::string& keyString,
244 unsigned long timeStamp,
245 const Integration::KeyEvent::State& keyState,
246 const std::string& compose = "",
247 const std::string& deviceName = DEFAULT_DEVICE_NAME,
248 const Device::Class::Type& deviceClass = Device::Class::NONE,
249 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
251 return Integration::KeyEvent( keyName,
264 Dali::Integration::Point GetPointDownInside( Vector2& pos )
266 Dali::Integration::Point point;
267 point.SetState( PointState::DOWN );
268 point.SetScreenPosition( pos );
272 Dali::Integration::Point GetPointUpInside( Vector2& pos )
274 Dali::Integration::Point point;
275 point.SetState( PointState::UP );
276 point.SetScreenPosition( pos );
280 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
282 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
284 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
286 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
288 Property::Value* valueSet = NULL;
289 if ( valueGet.first.type == Property::Key::INDEX )
291 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
295 // Get Key is a string so searching Set Map for a string key
296 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
299 if( NULL != valueSet )
301 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
303 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
306 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
308 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
311 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
313 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
316 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
318 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
321 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
323 Vector2 vector2Get = valueGet.second.Get<Vector2>();
324 Vector2 vector2Set = valueSet->Get<Vector2>();
325 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
328 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
330 Vector4 vector4Get = valueGet.second.Get<Vector4>();
331 Vector4 vector4Set = valueSet->Get<Vector4>();
332 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
338 if ( valueGet.first.type == Property::Key::INDEX )
340 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
344 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
354 class ScrollStateChangeCallback : public Dali::ConnectionTracker
357 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
358 : mStartedCalled( startedCalled ),
359 mFinishedCalled( finishedCalled )
363 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
365 if( type == TextEditor::Scroll::STARTED )
367 mStartedCalled = true;
369 else if( type == TextEditor::Scroll::FINISHED )
371 mFinishedCalled = true;
375 bool& mStartedCalled;
376 bool& mFinishedCalled;
381 int UtcDaliToolkitTextEditorConstructorP(void)
383 ToolkitTestApplication application;
384 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
385 TextEditor textEditor;
386 DALI_TEST_CHECK( !textEditor );
390 int UtcDaliToolkitTextEditorNewP(void)
392 ToolkitTestApplication application;
393 tet_infoline(" UtcDaliToolkitTextEditorNewP");
394 TextEditor textEditor = TextEditor::New();
395 DALI_TEST_CHECK( textEditor );
399 int UtcDaliToolkitTextEditorDownCastP(void)
401 ToolkitTestApplication application;
402 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
403 TextEditor textEditor1 = TextEditor::New();
404 BaseHandle object( textEditor1 );
406 TextEditor textEditor2 = TextEditor::DownCast( object );
407 DALI_TEST_CHECK( textEditor2 );
409 TextEditor textEditor3 = DownCast< TextEditor >( object );
410 DALI_TEST_CHECK( textEditor3 );
414 int UtcDaliToolkitTextEditorDownCastN(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
418 BaseHandle uninitializedObject;
419 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
420 DALI_TEST_CHECK( !textEditor1 );
422 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
423 DALI_TEST_CHECK( !textEditor2 );
427 int UtcDaliToolkitTextEditorCopyConstructorP(void)
429 ToolkitTestApplication application;
430 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
431 TextEditor textEditor = TextEditor::New();
432 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
434 TextEditor copy( textEditor );
435 DALI_TEST_CHECK( copy );
436 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
440 int UtcDaliTextEditorMoveConstructor(void)
442 ToolkitTestApplication application;
444 TextEditor textEditor = TextEditor::New();
445 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
446 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
448 TextEditor moved = std::move( textEditor );
449 DALI_TEST_CHECK( moved );
450 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
451 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
452 DALI_TEST_CHECK( !textEditor );
457 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
461 TextEditor textEditor = TextEditor::New();
462 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
464 TextEditor copy = textEditor;
465 DALI_TEST_CHECK( copy );
466 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
470 int UtcDaliTextEditorMoveAssignment(void)
472 ToolkitTestApplication application;
474 TextEditor textEditor = TextEditor::New();
475 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
476 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
479 moved = std::move( textEditor );
480 DALI_TEST_CHECK( moved );
481 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
482 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
483 DALI_TEST_CHECK( !textEditor );
488 int UtcDaliTextEditorNewP(void)
490 ToolkitTestApplication application;
491 tet_infoline(" UtcDaliToolkitTextEditorNewP");
492 TextEditor textEditor = TextEditor::New();
493 DALI_TEST_CHECK( textEditor );
497 // Positive test case for a method
498 int UtcDaliTextEditorGetPropertyP(void)
500 ToolkitTestApplication application;
501 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
502 TextEditor editor = TextEditor::New();
503 DALI_TEST_CHECK( editor );
505 // Check Property Indices are correct
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
550 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
551 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
552 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
553 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
554 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
555 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
556 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
557 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
558 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
559 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
560 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
561 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
562 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
563 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
564 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
565 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
566 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
571 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
574 Property::Map imageMap;
575 imageMap[mapKey] =mapValue;
577 editor.SetProperty( property , imageMap );
578 Property::Value propValue = editor.GetProperty( property );
579 Property::Map* resultMap = propValue.GetMap();
581 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
589 // Positive test case for a method
590 int UtcDaliTextEditorSetPropertyP(void)
592 ToolkitTestApplication application;
593 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
594 TextEditor editor = TextEditor::New();
595 DALI_TEST_CHECK( editor );
596 application.GetScene().Add( editor );
598 // Note - we can't check the defaults since the stylesheets are platform-specific
600 // Check the render backend property.
601 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
602 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
604 // Check text property.
605 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
606 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
608 // Check text's color property
609 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
610 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
612 // Check font properties.
613 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
614 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
616 Property::Map fontStyleMapSet;
617 Property::Map fontStyleMapGet;
618 Property::Value* slantValue = NULL;
620 fontStyleMapSet.Insert( "weight", "bold" );
621 fontStyleMapSet.Insert( "width", "condensed" );
622 fontStyleMapSet.Insert( "slant", "italic" );
624 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
625 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
626 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
627 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
629 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
630 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
632 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
633 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
634 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
637 fontStyleMapSet.Clear();
638 fontStyleMapSet.Insert( "weight", "normal" );
639 fontStyleMapSet.Insert( "slant", "oblique" );
640 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
641 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
642 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
643 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
645 fontStyleMapSet.Clear();
646 fontStyleMapSet.Insert( "slant", "roman" );
647 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
648 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
650 // Replace 'roman' for 'normal'.
651 slantValue = fontStyleMapGet.Find( "slant" );
652 if( NULL != slantValue )
654 if( "normal" == slantValue->Get<std::string>() )
656 fontStyleMapGet["slant"] = "roman";
659 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
660 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
662 fontStyleMapSet.Clear();
664 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
665 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
666 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
667 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
669 // Check that the Alignment properties can be correctly set
670 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
671 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
673 // Check scroll properties.
674 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
675 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
676 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
677 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
679 // Check cursor properties
680 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
681 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
682 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
683 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
685 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
686 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
687 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
688 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
689 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
690 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
691 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
692 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
694 // Check handle images
695 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
696 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
697 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
698 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
699 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
701 // Check handle images
702 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
703 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
704 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
705 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
706 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
707 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
709 // Check the highlight color
710 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
711 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
713 // Decoration bounding box
714 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
715 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
717 // Check the enable markup property.
718 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
719 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
720 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
722 // Check input color property.
723 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
724 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
726 // Check input font properties.
727 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
728 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
730 fontStyleMapSet.Clear();
731 fontStyleMapSet.Insert( "weight", "bold" );
732 fontStyleMapSet.Insert( "width", "condensed" );
733 fontStyleMapSet.Insert( "slant", "italic" );
735 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
736 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
737 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
738 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
740 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
741 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
743 // Reset input font style.
744 fontStyleMapSet.Clear();
745 fontStyleMapSet.Insert( "weight", "normal" );
746 fontStyleMapSet.Insert( "slant", "oblique" );
748 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
749 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
750 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
753 fontStyleMapSet.Clear();
754 fontStyleMapSet.Insert( "slant", "roman" );
756 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
757 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
759 // Replace 'roman' for 'normal'.
760 slantValue = fontStyleMapGet.Find( "slant" );
761 if( NULL != slantValue )
763 if( "normal" == slantValue->Get<std::string>() )
765 fontStyleMapGet["slant"] = "roman";
768 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
769 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
771 fontStyleMapSet.Clear();
773 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
774 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
775 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
776 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
778 // Check the line spacing property
779 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
780 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
781 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
783 // Check the input line spacing property
784 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
785 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
786 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
788 // Check the underline property
790 Property::Map underlineMapSet;
791 Property::Map underlineMapGet;
793 underlineMapSet.Insert( "enable", true );
794 underlineMapSet.Insert( "color", Color::RED );
795 underlineMapSet.Insert( "height", 1 );
797 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
799 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
800 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
801 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
803 // Check the input underline property
804 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
805 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
807 // Check the shadow property
808 Property::Map shadowMapSet;
809 Property::Map shadowMapGet;
811 shadowMapSet.Insert( "color", Color::GREEN );
812 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
813 shadowMapSet.Insert( "blurRadius", 3.0f );
815 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
817 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
818 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
819 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
821 // Check the input shadow property
822 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
823 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
825 // Check the emboss property
826 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
827 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
829 // Check the input emboss property
830 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
831 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
833 // Check the outline property
835 // Test string type first
836 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
837 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
838 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
840 // Then test the property map type
841 Property::Map outlineMapSet;
842 Property::Map outlineMapGet;
844 outlineMapSet["color"] = Color::RED;
845 outlineMapSet["width"] = 2.0f;
847 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
849 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
850 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
851 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
853 // Check the input outline property
854 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
855 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
857 // Check the smooth scroll property
858 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
859 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
860 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
862 // Check the smooth scroll duration property
863 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
864 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
866 // Check the scroll bar property
867 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
868 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
869 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
871 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
872 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
873 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
874 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
876 // Check the pixel size of font
877 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
878 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
880 // Check placeholder text properties.
881 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
882 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
884 // Check placeholder text's color property.
885 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
886 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
888 // Check the enable selection property
889 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
890 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
892 // Check the placeholder property with pixel size
893 Property::Map placeholderPixelSizeMapSet;
894 Property::Map placeholderPixelSizeMapGet;
895 Property::Map placeholderFontstyleMap;
896 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
897 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
898 placeholderPixelSizeMapSet["color"] = Color::BLUE;
899 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
900 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
902 placeholderFontstyleMap.Insert( "weight", "bold" );
903 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
904 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
906 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
907 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
909 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
910 Property::Map placeholderConversionMap;
911 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
912 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
913 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
916 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
918 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
920 // Check the placeholder property with point size
921 Property::Map placeholderMapSet;
922 Property::Map placeholderMapGet;
923 placeholderMapSet["text"] = "Setting Placeholder Text";
924 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
925 placeholderMapSet["color"] = Color::RED;
926 placeholderMapSet["fontFamily"] = "Arial";
927 placeholderMapSet["pointSize"] = 12.0f;
928 // Check the placeholder font style property
929 placeholderFontstyleMap.Clear();
931 placeholderFontstyleMap.Insert( "weight", "bold" );
932 placeholderFontstyleMap.Insert( "width", "condensed" );
933 placeholderFontstyleMap.Insert( "slant", "italic" );
934 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
935 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
937 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
938 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
940 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
941 placeholderConversionMap.Clear();
942 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
943 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
944 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
945 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
946 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
947 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
948 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
951 placeholderFontstyleMap.Clear();
952 placeholderFontstyleMap.Insert( "weight", "normal" );
953 placeholderFontstyleMap.Insert( "slant", "oblique" );
954 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
955 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
957 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
958 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
959 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
960 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
962 placeholderFontstyleMap.Clear();
963 placeholderFontstyleMap.Insert( "slant", "roman" );
964 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
965 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
967 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
969 placeholderFontstyleMap.Clear();
970 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
972 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
973 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
974 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
975 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
976 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
978 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
979 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
981 // Check handle color
982 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
983 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
985 // Test the ENABLE_GRAB_HANDLE_POPUP property
986 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
987 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
989 // Check the input method setting
990 Property::Map propertyMap;
991 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
992 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
993 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
994 int inputVariation = 1;
995 propertyMap["PANEL_LAYOUT"] = panelLayout;
996 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
997 propertyMap["BUTTON_ACTION"] = buttonAction;
998 propertyMap["VARIATION"] = inputVariation;
999 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
1001 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1003 DALI_TEST_CHECK( value.Get( map ) );
1006 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1007 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1010 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1011 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1014 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1015 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1018 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1019 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1021 // Check the input filter property
1022 Property::Map inputFilterMapSet;
1023 Property::Map inputFilterMapGet;
1024 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1025 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1027 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1029 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1030 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1033 inputFilterMapSet.Clear();
1034 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1036 application.SendNotification();
1037 application.Render();
1039 // Check the line size property
1040 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1041 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1042 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1047 // Positive Atlas Text Renderer test
1048 int utcDaliTextEditorAtlasRenderP(void)
1050 ToolkitTestApplication application;
1051 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1052 StyleManager styleManager = StyleManager::Get();
1053 styleManager.ApplyDefaultTheme();
1054 TextEditor editor = TextEditor::New();
1055 DALI_TEST_CHECK( editor );
1057 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1059 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1061 application.GetScene().Add( editor );
1065 // Render some text with the shared atlas backend
1066 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1067 application.SendNotification();
1068 application.Render();
1072 tet_result(TET_FAIL);
1077 // Positive test for the anchorClicked signal.
1078 int utcDaliTextEditorAnchorClickedP(void)
1080 ToolkitTestApplication application;
1081 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1082 TextEditor editor = TextEditor::New();
1083 DALI_TEST_CHECK(editor);
1085 application.GetScene().Add(editor);
1087 // connect to the anchor clicked signal.
1088 ConnectionTracker* testTracker = new ConnectionTracker();
1089 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1090 bool anchorClickedSignal = false;
1091 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1093 gAnchorClickedCallBackCalled = false;
1094 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1095 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1096 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1097 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1098 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1100 application.SendNotification();
1101 application.Render();
1102 editor.SetKeyInputFocus();
1104 // Create a tap event to touch the text editor.
1105 TestGenerateTap(application, 5.0f, 5.0f);
1106 application.SendNotification();
1107 application.Render();
1109 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1110 DALI_TEST_CHECK(anchorClickedSignal);
1112 gAnchorClickedCallBackNotCalled = true;
1113 // Tap the outside of anchor, callback should not be called.
1114 TestGenerateTap(application, 150.f, 100.f);
1115 application.SendNotification();
1116 application.Render();
1118 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1123 // Positive test for the textChanged signal.
1124 int utcDaliTextEditorTextChangedP(void)
1126 ToolkitTestApplication application;
1127 tet_infoline(" utcDaliTextEditorTextChangedP");
1128 TextEditor editor = TextEditor::New();
1129 DALI_TEST_CHECK( editor );
1131 application.GetScene().Add( editor );
1133 // connect to the text changed signal.
1134 ConnectionTracker* testTracker = new ConnectionTracker();
1135 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1136 bool textChangedSignal = false;
1137 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1139 gTextChangedCallBackCalled = false;
1140 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1141 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1142 DALI_TEST_CHECK( textChangedSignal );
1144 application.SendNotification();
1145 editor.SetKeyInputFocus();
1147 gTextChangedCallBackCalled = false;
1148 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1149 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1152 editor.SetProperty( TextField::Property::TEXT, "" );
1154 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1155 gTextChangedCallBackCalled = false;
1156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1157 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1159 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1160 gTextChangedCallBackCalled = false;
1161 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1162 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1167 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1169 ToolkitTestApplication application;
1170 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1171 TextEditor editor = TextEditor::New();
1172 DALI_TEST_CHECK( editor );
1175 application.GetScene().Add( editor );
1177 // connect to the text changed signal.
1178 ConnectionTracker* testTracker = new ConnectionTracker();
1179 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1180 bool textChangedSignal = false;
1181 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1184 // get InputMethodContext
1186 InputMethodContext::EventData imfEvent;
1187 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1189 editor.SetKeyInputFocus();
1190 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1193 gTextChangedCallBackCalled = false;
1194 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1195 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1196 application.SendNotification();
1197 application.Render();
1198 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1199 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1201 gTextChangedCallBackCalled = false;
1202 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1203 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1204 application.SendNotification();
1205 application.Render();
1206 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1207 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1209 gTextChangedCallBackCalled = false;
1210 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1211 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1212 application.SendNotification();
1213 application.Render();
1214 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1215 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1217 gTextChangedCallBackCalled = false;
1218 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1219 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1220 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1222 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1223 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1224 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1226 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1227 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1228 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1230 application.SendNotification();
1231 application.Render();
1232 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1233 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1239 int utcDaliTextEditorInputStyleChanged01(void)
1241 // The text-editor emits signals when the input style changes. These changes of style are
1242 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1243 // can't be emitted during the size negotiation as the callbacks may update the UI.
1244 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1245 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1246 ToolkitTestApplication application;
1247 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1251 char* pathNamePtr = get_current_dir_name();
1252 const std::string pathName( pathNamePtr );
1253 free( pathNamePtr );
1255 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1256 fontClient.SetDpi( 93u, 93u );
1258 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1259 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1261 TextEditor editor = TextEditor::New();
1262 DALI_TEST_CHECK( editor );
1265 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1266 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1267 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1269 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1270 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1272 // connect to the text changed signal.
1273 ConnectionTracker* testTracker = new ConnectionTracker();
1274 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1275 bool inputStyleChangedSignal = false;
1276 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1278 application.GetScene().Add( editor );
1280 // Render and notify
1281 application.SendNotification();
1282 application.Render();
1284 // Executes the idle callbacks added by the text control on the change of input style.
1285 application.RunIdles();
1287 gInputStyleChangedCallbackCalled = false;
1288 gInputStyleMask = TextEditor::InputStyle::NONE;
1289 inputStyleChangedSignal = false;
1291 // Create a tap event to touch the text editor.
1292 TestGenerateTap( application, 18.0f, 25.0f );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Executes the idle callbacks added by the text control on the change of input style.
1299 application.RunIdles();
1301 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1302 if( gInputStyleChangedCallbackCalled )
1304 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1306 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1307 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1309 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1310 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1312 DALI_TEST_CHECK( inputStyleChangedSignal );
1314 gInputStyleChangedCallbackCalled = false;
1315 gInputStyleMask = TextEditor::InputStyle::NONE;
1316 inputStyleChangedSignal = false;
1318 // Create a tap event to touch the text editor.
1319 TestGenerateTap( application, 30.0f, 25.0f );
1321 // Render and notify
1322 application.SendNotification();
1323 application.Render();
1325 // Executes the idle callbacks added by the text control on the change of input style.
1326 application.RunIdles();
1328 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1329 DALI_TEST_CHECK( !inputStyleChangedSignal );
1331 gInputStyleChangedCallbackCalled = false;
1332 gInputStyleMask = TextEditor::InputStyle::NONE;
1333 inputStyleChangedSignal = false;
1335 // Create a tap event to touch the text editor.
1336 TestGenerateTap( application, 43.0f, 25.0f );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1346 if( gInputStyleChangedCallbackCalled )
1348 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1350 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1351 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1353 DALI_TEST_CHECK( inputStyleChangedSignal );
1355 gInputStyleChangedCallbackCalled = false;
1356 gInputStyleMask = TextEditor::InputStyle::NONE;
1357 inputStyleChangedSignal = false;
1359 // Create a tap event to touch the text editor.
1360 TestGenerateTap( application, 88.0f, 25.0f );
1362 // Render and notify
1363 application.SendNotification();
1364 application.Render();
1366 // Executes the idle callbacks added by the text control on the change of input style.
1367 application.RunIdles();
1369 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1370 if( gInputStyleChangedCallbackCalled )
1372 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1374 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1375 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1377 Property::Map fontStyleMapSet;
1378 Property::Map fontStyleMapGet;
1380 fontStyleMapSet.Insert( "weight", "bold" );
1382 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1383 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1384 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1386 DALI_TEST_CHECK( inputStyleChangedSignal );
1388 gInputStyleChangedCallbackCalled = false;
1389 gInputStyleMask = TextEditor::InputStyle::NONE;
1390 inputStyleChangedSignal = false;
1392 // Create a tap event to touch the text editor.
1393 TestGenerateTap( application, 115.0f, 25.0f );
1395 // Render and notify
1396 application.SendNotification();
1397 application.Render();
1399 // Executes the idle callbacks added by the text control on the change of input style.
1400 application.RunIdles();
1402 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1403 DALI_TEST_CHECK( !inputStyleChangedSignal );
1405 gInputStyleChangedCallbackCalled = false;
1406 gInputStyleMask = TextEditor::InputStyle::NONE;
1407 inputStyleChangedSignal = false;
1409 // Create a tap event to touch the text editor.
1410 TestGenerateTap( application, 164.0f, 25.0f );
1412 // Render and notify
1413 application.SendNotification();
1414 application.Render();
1416 // Executes the idle callbacks added by the text control on the change of input style.
1417 application.RunIdles();
1419 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1420 if( gInputStyleChangedCallbackCalled )
1422 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1424 Property::Map fontStyleMapSet;
1425 Property::Map fontStyleMapGet;
1427 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1428 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1429 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1431 DALI_TEST_CHECK( inputStyleChangedSignal );
1433 gInputStyleChangedCallbackCalled = false;
1434 gInputStyleMask = TextEditor::InputStyle::NONE;
1435 inputStyleChangedSignal = false;
1437 // Create a tap event to touch the text editor.
1438 TestGenerateTap( application, 191.0f, 25.0f );
1440 // Render and notify
1441 application.SendNotification();
1442 application.Render();
1444 // Executes the idle callbacks added by the text control on the change of input style.
1445 application.RunIdles();
1447 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1448 DALI_TEST_CHECK( !inputStyleChangedSignal );
1453 int utcDaliTextEditorInputStyleChanged02(void)
1455 // The text-editor emits signals when the input style changes. These changes of style are
1456 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1457 // can't be emitted during the size negotiation as the callbacks may update the UI.
1458 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1459 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1460 ToolkitTestApplication application;
1461 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1465 char* pathNamePtr = get_current_dir_name();
1466 const std::string pathName( pathNamePtr );
1467 free( pathNamePtr );
1469 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1470 fontClient.SetDpi( 93u, 93u );
1472 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1473 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1475 TextEditor editor = TextEditor::New();
1476 DALI_TEST_CHECK( editor );
1479 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1480 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1481 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1483 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1484 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='blue'> l</color><color value='green'>lo</color> <font weight='bold'>world</font> demo</font>" );
1486 // connect to the text changed signal.
1487 ConnectionTracker* testTracker = new ConnectionTracker();
1488 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1489 bool inputStyleChangedSignal = false;
1490 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1492 application.GetScene().Add( editor );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Executes the idle callbacks added by the text control on the change of input style.
1499 application.RunIdles();
1501 gInputStyleChangedCallbackCalled = false;
1502 gInputStyleMask = TextEditor::InputStyle::NONE;
1503 inputStyleChangedSignal = false;
1505 // Create a tap event to touch the text editor.
1506 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1507 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1509 // Render and notify
1510 application.SendNotification();
1511 application.Render();
1513 // Executes the idle callbacks added by the text control on the change of input style.
1514 application.RunIdles();
1516 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1517 if( gInputStyleChangedCallbackCalled )
1519 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1520 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1521 TextEditor::InputStyle::POINT_SIZE |
1522 TextEditor::InputStyle::COLOR ),
1525 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1526 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1528 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1529 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1531 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1532 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1534 DALI_TEST_CHECK( inputStyleChangedSignal );
1536 gInputStyleChangedCallbackCalled = false;
1537 gInputStyleMask = TextEditor::InputStyle::NONE;
1538 inputStyleChangedSignal = false;
1540 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1542 // Render and notify
1543 application.SendNotification();
1544 application.Render();
1546 // Executes the idle callbacks added by the text control on the change of input style.
1547 application.RunIdles();
1549 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1550 if( gInputStyleChangedCallbackCalled )
1552 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1553 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1556 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1557 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1559 DALI_TEST_CHECK( inputStyleChangedSignal );
1561 gInputStyleChangedCallbackCalled = false;
1562 gInputStyleMask = TextEditor::InputStyle::NONE;
1563 inputStyleChangedSignal = false;
1565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // Executes the idle callbacks added by the text control on the change of input style.
1572 application.RunIdles();
1574 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1575 DALI_TEST_CHECK( !inputStyleChangedSignal );
1577 gInputStyleChangedCallbackCalled = false;
1578 gInputStyleMask = TextEditor::InputStyle::NONE;
1579 inputStyleChangedSignal = false;
1581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 // Executes the idle callbacks added by the text control on the change of input style.
1588 application.RunIdles();
1590 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1591 if( gInputStyleChangedCallbackCalled )
1593 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1594 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1597 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1598 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1600 DALI_TEST_CHECK( inputStyleChangedSignal );
1602 gInputStyleChangedCallbackCalled = false;
1603 gInputStyleMask = TextEditor::InputStyle::NONE;
1604 inputStyleChangedSignal = false;
1606 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1608 Property::Map fontStyleMapSet;
1609 fontStyleMapSet.Insert( "weight", "thin" );
1610 fontStyleMapSet.Insert( "width", "condensed" );
1611 fontStyleMapSet.Insert( "slant", "italic" );
1613 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1614 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1615 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1617 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1618 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1619 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1620 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1622 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1628 // Executes the idle callbacks added by the text control on the change of input style.
1629 application.RunIdles();
1631 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1632 DALI_TEST_CHECK( !inputStyleChangedSignal );
1634 // Create a tap event to touch the text editor.
1635 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1637 // Render and notify
1638 application.SendNotification();
1639 application.Render();
1641 // Executes the idle callbacks added by the text control on the change of input style.
1642 application.RunIdles();
1644 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1645 if( gInputStyleChangedCallbackCalled )
1647 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1648 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1649 TextEditor::InputStyle::POINT_SIZE |
1650 TextEditor::InputStyle::FONT_STYLE |
1651 TextEditor::InputStyle::LINE_SPACING |
1652 TextEditor::InputStyle::UNDERLINE |
1653 TextEditor::InputStyle::SHADOW |
1654 TextEditor::InputStyle::EMBOSS |
1655 TextEditor::InputStyle::OUTLINE ),
1658 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1659 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1661 DALI_TEST_CHECK( inputStyleChangedSignal );
1663 gInputStyleChangedCallbackCalled = false;
1664 gInputStyleMask = TextEditor::InputStyle::NONE;
1665 inputStyleChangedSignal = false;
1667 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1669 fontStyleMapSet.Clear();
1670 fontStyleMapSet.Insert( "weight", "black" );
1671 fontStyleMapSet.Insert( "width", "expanded" );
1672 fontStyleMapSet.Insert( "slant", "oblique" );
1674 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1676 // Create a tap event to touch the text editor.
1677 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Executes the idle callbacks added by the text control on the change of input style.
1684 application.RunIdles();
1686 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1687 if( gInputStyleChangedCallbackCalled )
1689 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1690 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1691 TextEditor::InputStyle::POINT_SIZE |
1692 TextEditor::InputStyle::FONT_STYLE ),
1695 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1696 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1698 DALI_TEST_CHECK( inputStyleChangedSignal );
1703 int utcDaliTextEditorEvent01(void)
1705 ToolkitTestApplication application;
1706 tet_infoline(" utcDaliTextEditorEvent01");
1708 // Creates a tap event. After creating a tap event the text editor should
1709 // have the focus and add text with key events should be possible.
1711 TextEditor editor = TextEditor::New();
1712 DALI_TEST_CHECK( editor );
1714 application.GetScene().Add( editor );
1716 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1717 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1718 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1720 // Avoid a crash when core load gl resources.
1721 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1723 // Render and notify
1724 application.SendNotification();
1725 application.Render();
1727 // Add a key event but as the text editor has not the focus it should do nothing.
1728 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1736 // Create a tap event to touch the text editor.
1737 TestGenerateTap( application, 150.0f, 25.0f );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 // Now the text editor has the focus, so it can handle the key events.
1744 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1753 // Create a second text editor and send key events to it.
1754 TextEditor editor2 = TextEditor::New();
1756 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1757 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1758 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1759 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1761 application.GetScene().Add( editor2 );
1763 // Render and notify
1764 application.SendNotification();
1765 application.Render();
1767 // Create a tap event on the second text editor.
1768 TestGenerateTap( application, 150.0f, 125.0f );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // The second text editor has the focus. It should handle the key events.
1775 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1776 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 // Check the text has been added to the second text editor.
1783 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1788 int utcDaliTextEditorEvent02(void)
1790 ToolkitTestApplication application;
1791 tet_infoline(" utcDaliTextEditorEvent02");
1793 // Checks if the right number of actors are created.
1795 TextEditor editor = TextEditor::New();
1796 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1797 DALI_TEST_CHECK( editor );
1799 application.GetScene().Add( editor );
1801 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1802 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1803 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1805 // Avoid a crash when core load gl resources.
1806 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1808 // Render and notify
1809 application.SendNotification();
1810 application.Render();
1812 // Check there are the expected number of children (the stencil).
1813 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1815 Actor stencil = editor.GetChildAt( 0u );
1817 // Create a tap event to touch the text editor.
1818 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 Actor layer = editor.GetChildAt( 1u );
1825 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1826 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1828 // Now the text editor has the focus, so it can handle the key events.
1829 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1830 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1832 // Render and notify
1833 application.SendNotification();
1834 application.Render();
1836 // Checks the cursor and the renderer have been created.
1837 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1838 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1840 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1841 DALI_TEST_CHECK( cursor );
1843 // The stencil actor has a container with all the actors which contain the text renderers.
1844 Actor container = stencil.GetChildAt( 0u );
1845 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1847 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1848 DALI_TEST_CHECK( renderer );
1851 // Move the cursor and check the position changes.
1852 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1854 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1863 DALI_TEST_CHECK( position2.x < position1.x );
1865 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1868 // Render and notify
1869 application.SendNotification();
1870 application.Render();
1872 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1874 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1876 // Send some taps and check the cursor positions.
1878 // Try to tap at the beginning.
1879 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 // Cursor position should be the same than position1.
1886 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1888 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1890 // Tap away from the start position.
1891 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1899 DALI_TEST_CHECK( position5.x > position4.x );
1901 // Remove all the text.
1902 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1903 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1904 editor.SetProperty( TextEditor::Property::TEXT, "" );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Cursor position should be the same than position2.
1911 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1913 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1915 // Should not be a renderer.
1916 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1921 int utcDaliTextEditorEvent03(void)
1923 ToolkitTestApplication application;
1924 tet_infoline(" utcDaliTextEditorEvent03");
1926 // Checks if the highlight actor is created.
1928 TextEditor editor = TextEditor::New();
1929 DALI_TEST_CHECK( editor );
1931 application.GetScene().Add( editor );
1933 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1934 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1935 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1936 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1937 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1939 // Avoid a crash when core load gl resources.
1940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 // Send some taps and check text controller with clipboard window
1947 Dali::Clipboard clipboard = Clipboard::Get();
1948 clipboard.ShowClipboard();
1949 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1950 clipboard.HideClipboard();
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1956 // Tap first to get the focus.
1957 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1963 // Double tap to select a word.
1964 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1966 // Render and notify
1967 application.SendNotification();
1968 application.Render();
1970 // The stencil actor should have two actors: the renderer and the highlight actor.
1971 Actor stencil = editor.GetChildAt( 0u );
1973 // Highlight needs to be drawn before text, so should come first in child order
1974 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1975 DALI_TEST_CHECK( highlight );
1977 // The stencil actor has a container with all the actors which contain the text renderers.
1978 Actor container = stencil.GetChildAt( 1u );
1979 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1981 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1982 DALI_TEST_CHECK( renderer );
1985 // Double tap out of bounds
1986 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1987 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1989 // Render and notify
1990 application.SendNotification();
1991 application.Render();
1993 // The stencil actor should have one actors: the renderer actor.
1994 stencil = editor.GetChildAt( 0u );
1996 // The stencil actor has a container with all the actors which contain the text renderers.
1997 container = stencil.GetChildAt( 0u );
1998 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2000 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2001 DALI_TEST_CHECK( renderer );
2005 TestGenerateLongPress(application, 1.0f, 25.0f);
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2012 TestGenerateMiniPan(application);
2014 // Render and notify
2015 application.SendNotification();
2016 application.Render();
2021 int utcDaliTextEditorEvent04(void)
2023 ToolkitTestApplication application;
2024 tet_infoline(" utcDaliTextEditorEvent04");
2026 // Checks if the highlight actor is created.
2028 TextEditor editor = TextEditor::New();
2029 DALI_TEST_CHECK( editor );
2031 application.GetScene().Add( editor );
2033 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2034 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2035 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2036 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2037 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2039 // Avoid a crash when core load gl resources.
2040 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2042 // Render and notify
2043 application.SendNotification();
2044 application.Render();
2046 // Tap on the text editor
2047 TestGenerateTap( application, 3.0f, 25.0f );
2049 // Render and notify
2050 application.SendNotification();
2051 application.Render();
2053 // Move at the end of the text.
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2061 for( unsigned int index = 0u; index < 10u; ++index )
2063 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2064 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066 // Render and notify
2067 application.SendNotification();
2068 application.Render();
2072 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2074 // Render and notify
2075 application.SendNotification();
2076 application.Render();
2078 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2080 // Add some key events
2081 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2088 for( unsigned int index = 0u; index < 10u; ++index )
2090 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2099 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2110 int utcDaliTextEditorEvent05(void)
2112 ToolkitTestApplication application;
2113 tet_infoline(" utcDaliTextEditorEvent05");
2115 // Checks if the highlight actor is created.
2117 TextEditor editor = TextEditor::New();
2118 DALI_TEST_CHECK( editor );
2120 application.GetScene().Add( editor );
2122 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2123 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2124 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2125 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2126 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2127 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2128 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2129 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2130 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2131 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2133 // Avoid a crash when core load gl resources.
2134 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // Tap on the text editor
2141 TestGenerateTap( application, 3.0f, 25.0f );
2143 // Render and notify
2144 application.SendNotification();
2145 application.Render();
2147 // Move at the end of the text.
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 for( unsigned int index = 0u; index < 10u; ++index )
2158 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Modify duration after scroll is enabled
2165 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2167 // Continuous scroll left to increase coverage
2168 for( unsigned int index = 0u; index < 10u; ++index )
2170 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2177 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2178 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2179 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2180 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2182 // Press Escape to increase coverage
2183 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2184 application.SendNotification();
2185 application.Render();
2187 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2192 int utcDaliTextEditorEvent06(void)
2194 ToolkitTestApplication application;
2195 tet_infoline(" utcDaliTextEditorEvent06");
2197 // Checks if the highlight actor is created.
2199 TextEditor editor = TextEditor::New();
2200 DALI_TEST_CHECK( editor );
2202 application.GetScene().Add( editor );
2204 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2205 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2206 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2207 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2208 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2210 // Avoid a crash when core load gl resources.
2211 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 // Tap on the text editor
2218 TestGenerateTap( application, 3.0f, 25.0f );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // Move to seconds line of the text.
2225 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 float layoutHeight = editor.GetHeightForWidth( 100.f );
2234 // Add another script characters ( glyph height is defferent )
2235 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2238 // Delete characters
2239 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2244 // Render and notify
2245 application.SendNotification();
2246 application.Render();
2248 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2251 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2252 application.SendNotification();
2253 application.Render();
2255 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 application.SendNotification();
2257 application.Render();
2259 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2260 application.SendNotification();
2261 application.Render();
2263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 application.SendNotification();
2265 application.Render();
2267 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 application.SendNotification();
2269 application.Render();
2271 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 application.SendNotification();
2273 application.Render();
2275 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.SendNotification();
2277 application.Render();
2282 int utcDaliTextEditorEvent07(void)
2284 ToolkitTestApplication application;
2285 tet_infoline(" utcDaliTextEditorEvent07");
2287 // Checks if the highlight actor is created.
2289 TextEditor editor = TextEditor::New();
2290 DALI_TEST_CHECK( editor );
2292 application.GetScene().Add( editor );
2294 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2295 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2296 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2297 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2298 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2300 // Avoid a crash when core load gl resources.
2301 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2303 // Render and notify
2304 application.SendNotification();
2305 application.Render();
2307 // Tap on the text editor
2308 TestGenerateTap( application, 3.0f, 25.0f );
2310 // Render and notify
2311 application.SendNotification();
2312 application.Render();
2314 // Move to second line of the text.
2315 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 // Select some text in the right of the current cursor position
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Cut the selected text
2332 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2341 // Select some text in the left of the current cursor position
2342 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Copy the selected text
2352 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 // Move the cursor to the third line
2360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363 // Render and notify
2364 application.SendNotification();
2365 application.Render();
2367 // Paste the selected text at the current cursor position
2368 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 application.ProcessEvent( GenerateKey( "v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371 // Render and notify
2372 application.SendNotification();
2373 application.Render();
2375 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2378 // Disable Shift Selection
2379 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2381 // Test to select some text in the right of the current cursor position
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 // Cut the selected text
2392 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2400 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2402 // Test to select some text in the left of the current cursor position
2403 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 // Copy the selected text
2413 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2420 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2421 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2424 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // replace text with "c"
2431 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2438 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2441 DevelTextEditor::SelectWholeText(editor);
2443 // Render and notify
2444 application.SendNotification();
2445 application.Render();
2447 // Copy the selected text using logical keys
2448 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2456 DevelTextEditor::SelectNone(editor);
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 // Paste the selected using logical keys
2463 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2469 // select all using logical keys
2470 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 // cut text using logical keys
2478 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2479 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2481 // Render and notify
2482 application.SendNotification();
2483 application.Render();
2486 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2491 int utcDaliTextEditorEvent08(void)
2493 ToolkitTestApplication application;
2494 tet_infoline(" utcDaliTextEditorEvent08");
2496 // Checks if the highlight actor is released correctly.
2498 TextEditor editor = TextEditor::New();
2499 DALI_TEST_CHECK( editor );
2501 application.GetScene().Add( editor );
2503 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2504 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2505 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2506 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2507 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2509 // Avoid a crash when core load gl resources.
2510 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2512 // Render and notify
2513 application.SendNotification();
2514 application.Render();
2516 // Tap on the text editor
2517 TestGenerateTap( application, 3.0f, 25.0f );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2524 // Test to select some text in the left of the current cursor position
2525 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Test to the left selection handle position and the right selection handle position
2535 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2536 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2540 // Render and notify
2541 application.SendNotification();
2542 application.Render();
2544 // Test to select full text in the left of the current cursor position
2545 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2548 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2550 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2552 // Render and notify
2553 application.SendNotification();
2554 application.Render();
2556 // Test to release the current full text selection
2557 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2558 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2560 // Render and notify
2561 application.SendNotification();
2562 application.Render();
2564 // Test to move the current cursor position correctly
2565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2567 // Render and notify
2568 application.SendNotification();
2569 application.Render();
2572 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2580 // Test to select some text in the right of the current cursor position
2581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2582 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2585 // Render and notify
2586 application.SendNotification();
2587 application.Render();
2589 // Test the cursor position with right arrow key
2590 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2592 // Render and notify
2593 application.SendNotification();
2594 application.Render();
2597 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2599 // Render and notify
2600 application.SendNotification();
2601 application.Render();
2603 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2605 // Test to select some text in the left of the current cursor position
2606 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2607 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2608 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2609 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2610 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2612 // Render and notify
2613 application.SendNotification();
2614 application.Render();
2616 // Test the cursor position with left arrow key
2617 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2619 // Render and notify
2620 application.SendNotification();
2621 application.Render();
2624 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2626 // Render and notify
2627 application.SendNotification();
2628 application.Render();
2630 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2632 // Test to select some text in the right of the current cursor position
2633 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2634 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2635 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2636 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2638 // Render and notify
2639 application.SendNotification();
2640 application.Render();
2642 // Test the cursor position with left arrow key
2643 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2645 // Render and notify
2646 application.SendNotification();
2647 application.Render();
2650 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2652 // Render and notify
2653 application.SendNotification();
2654 application.Render();
2656 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2658 // Test to select some text in the left of the current cursor position
2659 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2660 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2661 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2662 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2664 // Render and notify
2665 application.SendNotification();
2666 application.Render();
2668 // Test the cursor position with right arrow key
2669 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2671 // Render and notify
2672 application.SendNotification();
2673 application.Render();
2676 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2678 // Render and notify
2679 application.SendNotification();
2680 application.Render();
2682 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2687 int utcDaliTextEditorHandles(void)
2689 ToolkitTestApplication application;
2690 tet_infoline(" utcDaliTextEditorHandles");
2692 TextEditor editor = TextEditor::New();
2693 DALI_TEST_CHECK( editor );
2695 application.GetScene().Add( editor );
2697 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2698 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2699 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2700 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2702 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2703 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2704 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2705 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2707 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2708 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2709 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2711 // Avoid a crash when core load gl resources.
2712 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2714 // Render and notify
2715 application.SendNotification();
2716 application.Render();
2718 // Tap first to get the focus.
2719 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2721 // Render and notify
2722 application.SendNotification();
2723 application.Render();
2725 // Tap to create the grab handle.
2726 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2728 // Render and notify
2729 application.SendNotification();
2730 application.Render();
2732 // Get the active layer where the text's decoration is added.
2733 Actor activeLayer = editor.GetChildAt( 1u );
2735 // Get the handle's actor.
2736 Actor handle = activeLayer.GetChildAt( 1u );
2737 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2739 // Render and notify
2740 application.SendNotification();
2741 application.Render();
2743 // Touch the grab handle to set it as pressed.
2744 Vector2 touchPos( 10.0f, 50.0f );
2745 Dali::Integration::TouchEvent event;
2746 event = Dali::Integration::TouchEvent();
2747 event.AddPoint( GetPointDownInside( touchPos ) );
2748 application.ProcessEvent( event );
2750 // Render and notify
2751 application.SendNotification();
2752 application.Render();
2754 // Pan the grab handle
2755 uint32_t time = 100;
2756 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2757 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2758 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2759 application.SendNotification();
2760 application.Render();
2763 // Release the grab handle.
2764 event = Dali::Integration::TouchEvent();
2765 event.AddPoint( GetPointUpInside( touchPos ) );
2766 application.ProcessEvent( event );
2768 // Render and notify
2769 application.SendNotification();
2770 application.Render();
2772 // Tap first to get the focus.
2773 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2775 // Render and notify
2776 application.SendNotification();
2777 application.Render();
2779 // Double tap to select a word and create the selection handles.
2780 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2782 // Render and notify
2783 application.SendNotification();
2784 application.Render();
2786 touchPos = Vector2( 10.0f, 50.0f );
2788 // Touch the left selection handle to set it as pressed.
2789 event = Dali::Integration::TouchEvent();
2790 event.AddPoint( GetPointDownInside( touchPos ) );
2791 application.ProcessEvent( event );
2793 // Render and notify
2794 application.SendNotification();
2795 application.Render();
2797 // Release the left selection handle.
2798 event = Dali::Integration::TouchEvent();
2799 event.AddPoint( GetPointUpInside( touchPos ) );
2800 application.ProcessEvent( event );
2802 // Render and notify
2803 application.SendNotification();
2804 application.Render();
2809 int utcDaliTextEditorUnderPropertyStringP(void)
2811 ToolkitTestApplication application;
2812 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2813 TextEditor editor = TextEditor::New();
2814 DALI_TEST_CHECK( editor );
2816 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2818 application.GetScene().Add( editor );
2820 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2821 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2823 tet_infoline("Set underline settings with a map");
2824 // Check the input underline property
2825 Property::Map underlineMapSet;
2826 Property::Map underlineMapGet;
2827 underlineMapSet.Insert( "enable", true );
2828 underlineMapSet.Insert( "color", Color::BLUE );
2829 underlineMapSet.Insert( "height", 2 );
2831 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2832 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2833 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2834 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2836 tet_infoline("Set underline settings with a string");
2837 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2838 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2841 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2843 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2844 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2845 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2846 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2848 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2853 int utcDaliTextEditorShadowPropertyStringP(void)
2855 ToolkitTestApplication application;
2856 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2858 TextEditor editor = TextEditor::New();
2860 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2862 application.GetScene().Add( editor );
2864 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2866 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2870 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2875 int utcDaliTextEditorFontStylePropertyStringP(void)
2877 ToolkitTestApplication application;
2878 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2880 TextEditor editor = TextEditor::New();
2882 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2884 application.GetScene().Add( editor );
2886 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2888 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2892 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2897 int utcDaliTextEditorGetPropertyLinecountP(void)
2899 ToolkitTestApplication application;
2901 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2905 TextEditor editor = TextEditor::New();
2906 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2907 editor.SetProperty( TextEditor::Property::TEXT,
2908 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2910 application.GetScene().Add( editor );
2912 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2913 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2914 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2916 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2917 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2918 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2923 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2926 ToolkitTestApplication application;
2927 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2929 TextEditor editor = TextEditor::New();
2930 DALI_TEST_CHECK( editor );
2932 application.GetScene().Add( editor );
2934 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2935 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2936 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2937 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2938 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2939 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2941 bool startedCalled = false;
2942 bool finishedCalled = false;
2944 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2945 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2947 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2949 // Render and notify
2950 application.SendNotification();
2951 application.Render();
2953 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2954 application.SendNotification();
2955 application.Render(6000);
2957 application.SendNotification();
2958 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2959 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2964 int UtcDaliToolkitTextEditorTextWrapMode(void)
2966 ToolkitTestApplication application;
2967 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2971 TextEditor editor = TextEditor::New();
2972 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2973 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2975 application.GetScene().Add( editor );
2977 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2978 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2980 application.SendNotification();
2981 application.Render();
2983 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2984 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2986 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2987 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2989 application.SendNotification();
2990 application.Render();
2992 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2993 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2995 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2996 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2998 application.SendNotification();
2999 application.Render();
3001 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );