2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
106 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
107 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
108 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
109 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
110 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
115 const float RENDER_FRAME_INTERVAL = 16.66f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
122 const int KEY_C_CODE = 54;
123 const int KEY_V_CODE = 55;
124 const int KEY_X_CODE = 53;
125 const int KEY_WHITE_SPACE_CODE = 65;
127 const int KEY_SHIFT_MODIFIER = 257;
128 const int KEY_CONTROL_MODIFIER = 258;
130 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
131 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
132 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
134 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
136 static bool gSelectionChangedCallbackCalled;
137 static uint32_t oldSelectionStart;
138 static uint32_t oldSelectionEnd;
139 static bool gAnchorClickedCallBackCalled;
140 static bool gAnchorClickedCallBackNotCalled;
141 static bool gTextChangedCallBackCalled;
142 static bool gInputFilteredAcceptedCallbackCalled;
143 static bool gInputFilteredRejectedCallbackCalled;
144 static bool gInputStyleChangedCallbackCalled;
145 static bool gMaxCharactersCallBackCalled;
146 static bool gCursorPositionChangedCallbackCalled;
147 static uint32_t oldCursorPos;
148 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
150 struct CallbackFunctor
152 CallbackFunctor(bool* callbackFlag)
153 : mCallbackFlag( callbackFlag )
159 *mCallbackFlag = true;
164 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
166 tet_infoline(" TestSelectionChangedCallback");
168 gSelectionChangedCallbackCalled = true;
169 oldSelectionStart = oldStart;
170 oldSelectionEnd = oldEnd;
173 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
175 tet_infoline(" TestAnchorClickedCallback");
177 gAnchorClickedCallBackNotCalled = false;
179 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
181 gAnchorClickedCallBackCalled = true;
185 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
187 tet_infoline(" TestCursorPositionChangedCallback");
189 gCursorPositionChangedCallbackCalled = true;
190 oldCursorPos = oldPos;
193 static void TestTextChangedCallback( TextEditor control )
195 tet_infoline(" TestTextChangedCallback");
197 gTextChangedCallBackCalled = true;
200 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
202 tet_infoline(" TestInputStyleChangedCallback");
204 gInputStyleChangedCallbackCalled = true;
205 gInputStyleMask = mask;
208 static void TestMaxLengthReachedCallback( TextEditor control )
210 tet_infoline(" TestMaxLengthReachedCallback");
212 gMaxCharactersCallBackCalled = true;
215 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
217 tet_infoline(" TestInputFilteredCallback");
219 if(type == Toolkit::InputFilter::Property::ACCEPTED)
221 gInputFilteredAcceptedCallbackCalled = true;
223 else if(type == Toolkit::InputFilter::Property::REJECTED)
225 gInputFilteredRejectedCallbackCalled = true;
229 // Generate a KeyEvent to send to Core.
230 Integration::KeyEvent GenerateKey( const std::string& keyName,
231 const std::string& logicalKey,
232 const std::string& keyString,
235 unsigned long timeStamp,
236 const Integration::KeyEvent::State& keyState,
237 const std::string& compose = "",
238 const std::string& deviceName = DEFAULT_DEVICE_NAME,
239 const Device::Class::Type& deviceClass = Device::Class::NONE,
240 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
242 return Integration::KeyEvent( keyName,
255 Dali::Integration::Point GetPointDownInside( Vector2& pos )
257 Dali::Integration::Point point;
258 point.SetState( PointState::DOWN );
259 point.SetScreenPosition( pos );
263 Dali::Integration::Point GetPointUpInside( Vector2& pos )
265 Dali::Integration::Point point;
266 point.SetState( PointState::UP );
267 point.SetScreenPosition( pos );
271 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
273 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
275 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
277 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
279 Property::Value* valueSet = NULL;
280 if ( valueGet.first.type == Property::Key::INDEX )
282 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
286 // Get Key is a string so searching Set Map for a string key
287 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
290 if( NULL != valueSet )
292 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
294 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
297 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
299 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
302 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
304 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
307 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
309 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
312 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
314 Vector2 vector2Get = valueGet.second.Get<Vector2>();
315 Vector2 vector2Set = valueSet->Get<Vector2>();
316 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
319 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
321 Vector4 vector4Get = valueGet.second.Get<Vector4>();
322 Vector4 vector4Set = valueSet->Get<Vector4>();
323 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 );
329 if ( valueGet.first.type == Property::Key::INDEX )
331 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
335 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
345 class ScrollStateChangeCallback : public Dali::ConnectionTracker
348 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
349 : mStartedCalled( startedCalled ),
350 mFinishedCalled( finishedCalled )
354 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
356 if( type == TextEditor::Scroll::STARTED )
358 mStartedCalled = true;
360 else if( type == TextEditor::Scroll::FINISHED )
362 mFinishedCalled = true;
366 bool& mStartedCalled;
367 bool& mFinishedCalled;
372 int UtcDaliToolkitTextEditorConstructorP(void)
374 ToolkitTestApplication application;
375 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
376 TextEditor textEditor;
377 DALI_TEST_CHECK( !textEditor );
381 int UtcDaliToolkitTextEditorNewP(void)
383 ToolkitTestApplication application;
384 tet_infoline(" UtcDaliToolkitTextEditorNewP");
385 TextEditor textEditor = TextEditor::New();
386 DALI_TEST_CHECK( textEditor );
390 int UtcDaliToolkitTextEditorDownCastP(void)
392 ToolkitTestApplication application;
393 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
394 TextEditor textEditor1 = TextEditor::New();
395 BaseHandle object( textEditor1 );
397 TextEditor textEditor2 = TextEditor::DownCast( object );
398 DALI_TEST_CHECK( textEditor2 );
400 TextEditor textEditor3 = DownCast< TextEditor >( object );
401 DALI_TEST_CHECK( textEditor3 );
405 int UtcDaliToolkitTextEditorDownCastN(void)
407 ToolkitTestApplication application;
408 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
409 BaseHandle uninitializedObject;
410 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
411 DALI_TEST_CHECK( !textEditor1 );
413 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
414 DALI_TEST_CHECK( !textEditor2 );
418 int UtcDaliToolkitTextEditorCopyConstructorP(void)
420 ToolkitTestApplication application;
421 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
422 TextEditor textEditor = TextEditor::New();
423 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
425 TextEditor copy( textEditor );
426 DALI_TEST_CHECK( copy );
427 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
431 int UtcDaliTextEditorMoveConstructor(void)
433 ToolkitTestApplication application;
435 TextEditor textEditor = TextEditor::New();
436 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
437 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
439 TextEditor moved = std::move( textEditor );
440 DALI_TEST_CHECK( moved );
441 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
442 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
443 DALI_TEST_CHECK( !textEditor );
448 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
450 ToolkitTestApplication application;
451 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
452 TextEditor textEditor = TextEditor::New();
453 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
455 TextEditor copy = textEditor;
456 DALI_TEST_CHECK( copy );
457 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
461 int UtcDaliTextEditorMoveAssignment(void)
463 ToolkitTestApplication application;
465 TextEditor textEditor = TextEditor::New();
466 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
467 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
470 moved = std::move( textEditor );
471 DALI_TEST_CHECK( moved );
472 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
473 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
474 DALI_TEST_CHECK( !textEditor );
479 int UtcDaliTextEditorNewP(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliToolkitTextEditorNewP");
483 TextEditor textEditor = TextEditor::New();
484 DALI_TEST_CHECK( textEditor );
488 // Positive test case for a method
489 int UtcDaliTextEditorGetPropertyP(void)
491 ToolkitTestApplication application;
492 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
493 TextEditor editor = TextEditor::New();
494 DALI_TEST_CHECK( editor );
496 // Check Property Indices are correct
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
550 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
551 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
552 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
553 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
554 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
555 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
556 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
557 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
562 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
565 Property::Map imageMap;
566 imageMap[mapKey] =mapValue;
568 editor.SetProperty( property , imageMap );
569 Property::Value propValue = editor.GetProperty( property );
570 Property::Map* resultMap = propValue.GetMap();
572 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
580 // Positive test case for a method
581 int UtcDaliTextEditorSetPropertyP(void)
583 ToolkitTestApplication application;
584 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
585 TextEditor editor = TextEditor::New();
586 DALI_TEST_CHECK( editor );
587 application.GetScene().Add( editor );
589 // Note - we can't check the defaults since the stylesheets are platform-specific
591 // Check the render backend property.
592 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
593 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
595 // Check text property.
596 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
597 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
599 // Check text's color property
600 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
601 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
603 // Check font properties.
604 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
605 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
607 Property::Map fontStyleMapSet;
608 Property::Map fontStyleMapGet;
609 Property::Value* slantValue = NULL;
611 fontStyleMapSet.Insert( "weight", "bold" );
612 fontStyleMapSet.Insert( "width", "condensed" );
613 fontStyleMapSet.Insert( "slant", "italic" );
615 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
616 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
617 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
618 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
620 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
621 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
624 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
625 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
628 fontStyleMapSet.Clear();
629 fontStyleMapSet.Insert( "weight", "normal" );
630 fontStyleMapSet.Insert( "slant", "oblique" );
631 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
632 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
633 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
634 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
636 fontStyleMapSet.Clear();
637 fontStyleMapSet.Insert( "slant", "roman" );
638 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
639 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
641 // Replace 'roman' for 'normal'.
642 slantValue = fontStyleMapGet.Find( "slant" );
643 if( NULL != slantValue )
645 if( "normal" == slantValue->Get<std::string>() )
647 fontStyleMapGet["slant"] = "roman";
650 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
651 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
653 fontStyleMapSet.Clear();
655 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
656 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
657 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
658 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
660 // Check that the Alignment properties can be correctly set
661 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
662 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
664 // Check scroll properties.
665 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
666 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
667 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
668 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
670 // Check cursor properties
671 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
672 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
673 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
674 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
676 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
677 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
678 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
679 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
680 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
681 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
683 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
685 // Check handle images
686 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
687 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
688 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
689 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
690 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
692 // Check handle images
693 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
694 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
695 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
696 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
697 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
698 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
700 // Check the highlight color
701 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
702 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
704 // Decoration bounding box
705 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
706 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
708 // Check the enable markup property.
709 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
710 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
711 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
713 // Check input color property.
714 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
715 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
717 // Check input font properties.
718 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
719 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
721 fontStyleMapSet.Clear();
722 fontStyleMapSet.Insert( "weight", "bold" );
723 fontStyleMapSet.Insert( "width", "condensed" );
724 fontStyleMapSet.Insert( "slant", "italic" );
726 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
727 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
728 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
729 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
731 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
732 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
734 // Reset input font style.
735 fontStyleMapSet.Clear();
736 fontStyleMapSet.Insert( "weight", "normal" );
737 fontStyleMapSet.Insert( "slant", "oblique" );
739 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
740 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
741 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
742 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
744 fontStyleMapSet.Clear();
745 fontStyleMapSet.Insert( "slant", "roman" );
747 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
748 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
750 // Replace 'roman' for 'normal'.
751 slantValue = fontStyleMapGet.Find( "slant" );
752 if( NULL != slantValue )
754 if( "normal" == slantValue->Get<std::string>() )
756 fontStyleMapGet["slant"] = "roman";
759 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
760 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
762 fontStyleMapSet.Clear();
764 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
765 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
766 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
767 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
769 // Check the line spacing property
770 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
771 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
772 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
774 // Check the input line spacing property
775 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
776 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
777 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
779 // Check the underline property
781 Property::Map underlineMapSet;
782 Property::Map underlineMapGet;
784 underlineMapSet.Insert( "enable", true );
785 underlineMapSet.Insert( "color", Color::RED );
786 underlineMapSet.Insert( "height", 1 );
788 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
790 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
791 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
792 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
794 // Check the input underline property
795 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
796 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
798 // Check the shadow property
799 Property::Map shadowMapSet;
800 Property::Map shadowMapGet;
802 shadowMapSet.Insert( "color", Color::GREEN );
803 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
804 shadowMapSet.Insert( "blurRadius", 3.0f );
806 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
808 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
809 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
810 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
812 // Check the input shadow property
813 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
814 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
816 // Check the emboss property
817 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
818 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
820 // Check the input emboss property
821 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
822 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
824 // Check the outline property
826 // Test string type first
827 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
828 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
829 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
831 // Then test the property map type
832 Property::Map outlineMapSet;
833 Property::Map outlineMapGet;
835 outlineMapSet["color"] = Color::RED;
836 outlineMapSet["width"] = 2.0f;
838 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
840 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
841 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
842 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
844 // Check the input outline property
845 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
846 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
848 // Check the smooth scroll property
849 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
850 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
851 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
853 // Check the smooth scroll duration property
854 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
855 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
857 // Check the scroll bar property
858 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
859 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
860 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
862 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
863 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
864 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
865 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
867 // Check the pixel size of font
868 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
869 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
871 // Check placeholder text properties.
872 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
873 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
875 // Check placeholder text's color property.
876 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
877 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
879 // Check the enable selection property
880 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
881 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
883 // Check the placeholder property with pixel size
884 Property::Map placeholderPixelSizeMapSet;
885 Property::Map placeholderPixelSizeMapGet;
886 Property::Map placeholderFontstyleMap;
887 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
888 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
889 placeholderPixelSizeMapSet["color"] = Color::BLUE;
890 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
891 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
893 placeholderFontstyleMap.Insert( "weight", "bold" );
894 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
895 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
897 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
898 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
900 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
901 Property::Map placeholderConversionMap;
902 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
903 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
904 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
905 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
906 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
907 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
909 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
911 // Check the placeholder property with point size
912 Property::Map placeholderMapSet;
913 Property::Map placeholderMapGet;
914 placeholderMapSet["text"] = "Setting Placeholder Text";
915 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
916 placeholderMapSet["color"] = Color::RED;
917 placeholderMapSet["fontFamily"] = "Arial";
918 placeholderMapSet["pointSize"] = 12.0f;
919 // Check the placeholder font style property
920 placeholderFontstyleMap.Clear();
922 placeholderFontstyleMap.Insert( "weight", "bold" );
923 placeholderFontstyleMap.Insert( "width", "condensed" );
924 placeholderFontstyleMap.Insert( "slant", "italic" );
925 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
926 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
928 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
929 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
931 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
932 placeholderConversionMap.Clear();
933 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
934 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
935 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
936 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
937 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
938 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
939 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
942 placeholderFontstyleMap.Clear();
943 placeholderFontstyleMap.Insert( "weight", "normal" );
944 placeholderFontstyleMap.Insert( "slant", "oblique" );
945 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
946 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
948 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
949 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
950 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
951 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
953 placeholderFontstyleMap.Clear();
954 placeholderFontstyleMap.Insert( "slant", "roman" );
955 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
956 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
958 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
960 placeholderFontstyleMap.Clear();
961 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
963 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
964 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
965 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
966 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
967 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
969 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
970 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
972 // Check handle color
973 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
974 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
976 // Test the ENABLE_GRAB_HANDLE_POPUP property
977 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
978 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
980 // Check the input method setting
981 Property::Map propertyMap;
982 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
983 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
984 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
985 int inputVariation = 1;
986 propertyMap["PANEL_LAYOUT"] = panelLayout;
987 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
988 propertyMap["BUTTON_ACTION"] = buttonAction;
989 propertyMap["VARIATION"] = inputVariation;
990 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
992 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
994 DALI_TEST_CHECK( value.Get( map ) );
997 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
998 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1001 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1002 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1005 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1006 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1009 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1010 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1012 // Check the input filter property
1013 Property::Map inputFilterMapSet;
1014 Property::Map inputFilterMapGet;
1015 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1016 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1018 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1020 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1021 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1024 inputFilterMapSet.Clear();
1025 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1027 application.SendNotification();
1028 application.Render();
1030 // Check the line size property
1031 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1032 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1033 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1038 // Positive Atlas Text Renderer test
1039 int utcDaliTextEditorAtlasRenderP(void)
1041 ToolkitTestApplication application;
1042 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1043 StyleManager styleManager = StyleManager::Get();
1044 styleManager.ApplyDefaultTheme();
1045 TextEditor editor = TextEditor::New();
1046 DALI_TEST_CHECK( editor );
1048 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1050 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1052 application.GetScene().Add( editor );
1056 // Render some text with the shared atlas backend
1057 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1058 application.SendNotification();
1059 application.Render();
1063 tet_result(TET_FAIL);
1068 // Positive test for the anchorClicked signal.
1069 int utcDaliTextEditorAnchorClickedP(void)
1071 ToolkitTestApplication application;
1072 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1073 TextEditor editor = TextEditor::New();
1074 DALI_TEST_CHECK(editor);
1076 application.GetScene().Add(editor);
1078 // connect to the anchor clicked signal.
1079 ConnectionTracker* testTracker = new ConnectionTracker();
1080 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1081 bool anchorClickedSignal = false;
1082 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1084 gAnchorClickedCallBackCalled = false;
1085 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1086 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1087 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1088 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1089 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1091 application.SendNotification();
1092 application.Render();
1093 editor.SetKeyInputFocus();
1095 // Create a tap event to touch the text editor.
1096 TestGenerateTap(application, 5.0f, 5.0f);
1097 application.SendNotification();
1098 application.Render();
1100 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1101 DALI_TEST_CHECK(anchorClickedSignal);
1103 gAnchorClickedCallBackNotCalled = true;
1104 // Tap the outside of anchor, callback should not be called.
1105 TestGenerateTap(application, 150.f, 100.f);
1106 application.SendNotification();
1107 application.Render();
1109 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1114 // Positive test for the textChanged signal.
1115 int utcDaliTextEditorTextChangedP(void)
1117 ToolkitTestApplication application;
1118 tet_infoline(" utcDaliTextEditorTextChangedP");
1119 TextEditor editor = TextEditor::New();
1120 DALI_TEST_CHECK( editor );
1122 application.GetScene().Add( editor );
1124 // connect to the text changed signal.
1125 ConnectionTracker* testTracker = new ConnectionTracker();
1126 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1127 bool textChangedSignal = false;
1128 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1130 gTextChangedCallBackCalled = false;
1131 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1132 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1133 DALI_TEST_CHECK( textChangedSignal );
1135 application.SendNotification();
1136 editor.SetKeyInputFocus();
1138 gTextChangedCallBackCalled = false;
1139 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1140 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1143 editor.SetProperty( TextField::Property::TEXT, "" );
1145 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1146 gTextChangedCallBackCalled = false;
1147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1148 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1150 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1151 gTextChangedCallBackCalled = false;
1152 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1153 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1158 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1160 ToolkitTestApplication application;
1161 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1162 TextEditor editor = TextEditor::New();
1163 DALI_TEST_CHECK( editor );
1166 application.GetScene().Add( editor );
1168 // connect to the text changed signal.
1169 ConnectionTracker* testTracker = new ConnectionTracker();
1170 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1171 bool textChangedSignal = false;
1172 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1175 // get InputMethodContext
1177 InputMethodContext::EventData imfEvent;
1178 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1180 editor.SetKeyInputFocus();
1181 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1184 gTextChangedCallBackCalled = false;
1185 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1186 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1187 application.SendNotification();
1188 application.Render();
1189 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1190 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1192 gTextChangedCallBackCalled = false;
1193 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1194 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1195 application.SendNotification();
1196 application.Render();
1197 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1198 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1200 gTextChangedCallBackCalled = false;
1201 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1202 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1203 application.SendNotification();
1204 application.Render();
1205 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1206 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1208 gTextChangedCallBackCalled = false;
1209 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1210 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1211 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1213 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1214 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1215 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1217 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1218 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1219 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1221 application.SendNotification();
1222 application.Render();
1223 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1224 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1230 int utcDaliTextEditorInputStyleChanged01(void)
1232 // The text-editor emits signals when the input style changes. These changes of style are
1233 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1234 // can't be emitted during the size negotiation as the callbacks may update the UI.
1235 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1236 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1237 ToolkitTestApplication application;
1238 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1242 char* pathNamePtr = get_current_dir_name();
1243 const std::string pathName( pathNamePtr );
1244 free( pathNamePtr );
1246 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1247 fontClient.SetDpi( 93u, 93u );
1249 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1250 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1252 TextEditor editor = TextEditor::New();
1253 DALI_TEST_CHECK( editor );
1256 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1257 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1258 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1260 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1261 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1263 // connect to the text changed signal.
1264 ConnectionTracker* testTracker = new ConnectionTracker();
1265 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1266 bool inputStyleChangedSignal = false;
1267 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1269 application.GetScene().Add( editor );
1271 // Render and notify
1272 application.SendNotification();
1273 application.Render();
1275 // Executes the idle callbacks added by the text control on the change of input style.
1276 application.RunIdles();
1278 gInputStyleChangedCallbackCalled = false;
1279 gInputStyleMask = TextEditor::InputStyle::NONE;
1280 inputStyleChangedSignal = false;
1282 // Create a tap event to touch the text editor.
1283 TestGenerateTap( application, 18.0f, 25.0f );
1285 // Render and notify
1286 application.SendNotification();
1287 application.Render();
1289 // Executes the idle callbacks added by the text control on the change of input style.
1290 application.RunIdles();
1292 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1293 if( gInputStyleChangedCallbackCalled )
1295 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1297 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1298 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1300 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1301 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1303 DALI_TEST_CHECK( inputStyleChangedSignal );
1305 gInputStyleChangedCallbackCalled = false;
1306 gInputStyleMask = TextEditor::InputStyle::NONE;
1307 inputStyleChangedSignal = false;
1309 // Create a tap event to touch the text editor.
1310 TestGenerateTap( application, 30.0f, 25.0f );
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Executes the idle callbacks added by the text control on the change of input style.
1317 application.RunIdles();
1319 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1320 DALI_TEST_CHECK( !inputStyleChangedSignal );
1322 gInputStyleChangedCallbackCalled = false;
1323 gInputStyleMask = TextEditor::InputStyle::NONE;
1324 inputStyleChangedSignal = false;
1326 // Create a tap event to touch the text editor.
1327 TestGenerateTap( application, 43.0f, 25.0f );
1329 // Render and notify
1330 application.SendNotification();
1331 application.Render();
1333 // Executes the idle callbacks added by the text control on the change of input style.
1334 application.RunIdles();
1336 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1337 if( gInputStyleChangedCallbackCalled )
1339 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1341 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1342 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1344 DALI_TEST_CHECK( inputStyleChangedSignal );
1346 gInputStyleChangedCallbackCalled = false;
1347 gInputStyleMask = TextEditor::InputStyle::NONE;
1348 inputStyleChangedSignal = false;
1350 // Create a tap event to touch the text editor.
1351 TestGenerateTap( application, 88.0f, 25.0f );
1353 // Render and notify
1354 application.SendNotification();
1355 application.Render();
1357 // Executes the idle callbacks added by the text control on the change of input style.
1358 application.RunIdles();
1360 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1361 if( gInputStyleChangedCallbackCalled )
1363 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1365 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1366 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1368 Property::Map fontStyleMapSet;
1369 Property::Map fontStyleMapGet;
1371 fontStyleMapSet.Insert( "weight", "bold" );
1373 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1374 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1375 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1377 DALI_TEST_CHECK( inputStyleChangedSignal );
1379 gInputStyleChangedCallbackCalled = false;
1380 gInputStyleMask = TextEditor::InputStyle::NONE;
1381 inputStyleChangedSignal = false;
1383 // Create a tap event to touch the text editor.
1384 TestGenerateTap( application, 115.0f, 25.0f );
1386 // Render and notify
1387 application.SendNotification();
1388 application.Render();
1390 // Executes the idle callbacks added by the text control on the change of input style.
1391 application.RunIdles();
1393 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1394 DALI_TEST_CHECK( !inputStyleChangedSignal );
1396 gInputStyleChangedCallbackCalled = false;
1397 gInputStyleMask = TextEditor::InputStyle::NONE;
1398 inputStyleChangedSignal = false;
1400 // Create a tap event to touch the text editor.
1401 TestGenerateTap( application, 164.0f, 25.0f );
1403 // Render and notify
1404 application.SendNotification();
1405 application.Render();
1407 // Executes the idle callbacks added by the text control on the change of input style.
1408 application.RunIdles();
1410 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1411 if( gInputStyleChangedCallbackCalled )
1413 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1415 Property::Map fontStyleMapSet;
1416 Property::Map fontStyleMapGet;
1418 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1419 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1420 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1422 DALI_TEST_CHECK( inputStyleChangedSignal );
1424 gInputStyleChangedCallbackCalled = false;
1425 gInputStyleMask = TextEditor::InputStyle::NONE;
1426 inputStyleChangedSignal = false;
1428 // Create a tap event to touch the text editor.
1429 TestGenerateTap( application, 191.0f, 25.0f );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 // Executes the idle callbacks added by the text control on the change of input style.
1436 application.RunIdles();
1438 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1439 DALI_TEST_CHECK( !inputStyleChangedSignal );
1444 int utcDaliTextEditorInputStyleChanged02(void)
1446 // The text-editor emits signals when the input style changes. These changes of style are
1447 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1448 // can't be emitted during the size negotiation as the callbacks may update the UI.
1449 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1450 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1451 ToolkitTestApplication application;
1452 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1456 char* pathNamePtr = get_current_dir_name();
1457 const std::string pathName( pathNamePtr );
1458 free( pathNamePtr );
1460 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1461 fontClient.SetDpi( 93u, 93u );
1463 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1464 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1466 TextEditor editor = TextEditor::New();
1467 DALI_TEST_CHECK( editor );
1470 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1471 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1472 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1474 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1475 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>" );
1477 // connect to the text changed signal.
1478 ConnectionTracker* testTracker = new ConnectionTracker();
1479 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1480 bool inputStyleChangedSignal = false;
1481 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1483 application.GetScene().Add( editor );
1485 // Render and notify
1486 application.SendNotification();
1487 application.Render();
1489 // Executes the idle callbacks added by the text control on the change of input style.
1490 application.RunIdles();
1492 gInputStyleChangedCallbackCalled = false;
1493 gInputStyleMask = TextEditor::InputStyle::NONE;
1494 inputStyleChangedSignal = false;
1496 // Create a tap event to touch the text editor.
1497 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1498 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1500 // Render and notify
1501 application.SendNotification();
1502 application.Render();
1504 // Executes the idle callbacks added by the text control on the change of input style.
1505 application.RunIdles();
1507 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1508 if( gInputStyleChangedCallbackCalled )
1510 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1511 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1512 TextEditor::InputStyle::POINT_SIZE |
1513 TextEditor::InputStyle::COLOR ),
1516 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1517 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1519 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1520 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1522 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1523 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1525 DALI_TEST_CHECK( inputStyleChangedSignal );
1527 gInputStyleChangedCallbackCalled = false;
1528 gInputStyleMask = TextEditor::InputStyle::NONE;
1529 inputStyleChangedSignal = false;
1531 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Executes the idle callbacks added by the text control on the change of input style.
1538 application.RunIdles();
1540 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1541 if( gInputStyleChangedCallbackCalled )
1543 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1544 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1547 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1548 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1550 DALI_TEST_CHECK( inputStyleChangedSignal );
1552 gInputStyleChangedCallbackCalled = false;
1553 gInputStyleMask = TextEditor::InputStyle::NONE;
1554 inputStyleChangedSignal = false;
1556 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 // Executes the idle callbacks added by the text control on the change of input style.
1563 application.RunIdles();
1565 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1566 DALI_TEST_CHECK( !inputStyleChangedSignal );
1568 gInputStyleChangedCallbackCalled = false;
1569 gInputStyleMask = TextEditor::InputStyle::NONE;
1570 inputStyleChangedSignal = false;
1572 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Executes the idle callbacks added by the text control on the change of input style.
1579 application.RunIdles();
1581 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1582 if( gInputStyleChangedCallbackCalled )
1584 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1585 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1588 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1589 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1591 DALI_TEST_CHECK( inputStyleChangedSignal );
1593 gInputStyleChangedCallbackCalled = false;
1594 gInputStyleMask = TextEditor::InputStyle::NONE;
1595 inputStyleChangedSignal = false;
1597 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1599 Property::Map fontStyleMapSet;
1600 fontStyleMapSet.Insert( "weight", "thin" );
1601 fontStyleMapSet.Insert( "width", "condensed" );
1602 fontStyleMapSet.Insert( "slant", "italic" );
1604 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1605 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1606 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1608 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1609 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1610 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1611 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1613 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1619 // Executes the idle callbacks added by the text control on the change of input style.
1620 application.RunIdles();
1622 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1623 DALI_TEST_CHECK( !inputStyleChangedSignal );
1625 // Create a tap event to touch the text editor.
1626 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 // Executes the idle callbacks added by the text control on the change of input style.
1633 application.RunIdles();
1635 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1636 if( gInputStyleChangedCallbackCalled )
1638 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1639 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1640 TextEditor::InputStyle::POINT_SIZE |
1641 TextEditor::InputStyle::FONT_STYLE |
1642 TextEditor::InputStyle::LINE_SPACING |
1643 TextEditor::InputStyle::UNDERLINE |
1644 TextEditor::InputStyle::SHADOW |
1645 TextEditor::InputStyle::EMBOSS |
1646 TextEditor::InputStyle::OUTLINE ),
1649 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1650 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1652 DALI_TEST_CHECK( inputStyleChangedSignal );
1654 gInputStyleChangedCallbackCalled = false;
1655 gInputStyleMask = TextEditor::InputStyle::NONE;
1656 inputStyleChangedSignal = false;
1658 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1660 fontStyleMapSet.Clear();
1661 fontStyleMapSet.Insert( "weight", "black" );
1662 fontStyleMapSet.Insert( "width", "expanded" );
1663 fontStyleMapSet.Insert( "slant", "oblique" );
1665 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1667 // Create a tap event to touch the text editor.
1668 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 // Executes the idle callbacks added by the text control on the change of input style.
1675 application.RunIdles();
1677 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1678 if( gInputStyleChangedCallbackCalled )
1680 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1681 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1682 TextEditor::InputStyle::POINT_SIZE |
1683 TextEditor::InputStyle::FONT_STYLE ),
1686 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1687 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1689 DALI_TEST_CHECK( inputStyleChangedSignal );
1694 int utcDaliTextEditorEvent01(void)
1696 ToolkitTestApplication application;
1697 tet_infoline(" utcDaliTextEditorEvent01");
1699 // Creates a tap event. After creating a tap event the text editor should
1700 // have the focus and add text with key events should be possible.
1702 TextEditor editor = TextEditor::New();
1703 DALI_TEST_CHECK( editor );
1705 application.GetScene().Add( editor );
1707 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1708 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1709 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1711 // Avoid a crash when core load gl resources.
1712 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // Add a key event but as the text editor has not the focus it should do nothing.
1719 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1721 // Render and notify
1722 application.SendNotification();
1723 application.Render();
1725 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1727 // Create a tap event to touch the text editor.
1728 TestGenerateTap( application, 150.0f, 25.0f );
1730 // Render and notify
1731 application.SendNotification();
1732 application.Render();
1734 // Now the text editor has the focus, so it can handle the key events.
1735 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1744 // Create a second text editor and send key events to it.
1745 TextEditor editor2 = TextEditor::New();
1747 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1748 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1749 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1750 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1752 application.GetScene().Add( editor2 );
1754 // Render and notify
1755 application.SendNotification();
1756 application.Render();
1758 // Create a tap event on the second text editor.
1759 TestGenerateTap( application, 150.0f, 125.0f );
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 // The second text editor has the focus. It should handle the key events.
1766 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1767 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 // Check the text has been added to the second text editor.
1774 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1779 int utcDaliTextEditorEvent02(void)
1781 ToolkitTestApplication application;
1782 tet_infoline(" utcDaliTextEditorEvent02");
1784 // Checks if the right number of actors are created.
1786 TextEditor editor = TextEditor::New();
1787 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1788 DALI_TEST_CHECK( editor );
1790 application.GetScene().Add( editor );
1792 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1793 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1794 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1796 // Avoid a crash when core load gl resources.
1797 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1799 // Render and notify
1800 application.SendNotification();
1801 application.Render();
1803 // Check there are the expected number of children (the stencil).
1804 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1806 Actor stencil = editor.GetChildAt( 0u );
1808 // Create a tap event to touch the text editor.
1809 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1811 // Render and notify
1812 application.SendNotification();
1813 application.Render();
1815 Actor layer = editor.GetChildAt( 1u );
1816 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1817 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1819 // Now the text editor has the focus, so it can handle the key events.
1820 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1823 // Render and notify
1824 application.SendNotification();
1825 application.Render();
1827 // Checks the cursor and the renderer have been created.
1828 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1829 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1831 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1832 DALI_TEST_CHECK( cursor );
1834 // The stencil actor has a container with all the actors which contain the text renderers.
1835 Actor container = stencil.GetChildAt( 0u );
1836 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1838 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1839 DALI_TEST_CHECK( renderer );
1842 // Move the cursor and check the position changes.
1843 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1845 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1846 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1852 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1854 DALI_TEST_CHECK( position2.x < position1.x );
1856 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1857 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1859 // Render and notify
1860 application.SendNotification();
1861 application.Render();
1863 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1865 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1867 // Send some taps and check the cursor positions.
1869 // Try to tap at the beginning.
1870 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1876 // Cursor position should be the same than position1.
1877 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1879 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1881 // Tap away from the start position.
1882 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1884 // Render and notify
1885 application.SendNotification();
1886 application.Render();
1888 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1890 DALI_TEST_CHECK( position5.x > position4.x );
1892 // Remove all the text.
1893 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1894 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1895 editor.SetProperty( TextEditor::Property::TEXT, "" );
1897 // Render and notify
1898 application.SendNotification();
1899 application.Render();
1901 // Cursor position should be the same than position2.
1902 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1904 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1906 // Should not be a renderer.
1907 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1912 int utcDaliTextEditorEvent03(void)
1914 ToolkitTestApplication application;
1915 tet_infoline(" utcDaliTextEditorEvent03");
1917 // Checks if the highlight actor is created.
1919 TextEditor editor = TextEditor::New();
1920 DALI_TEST_CHECK( editor );
1922 application.GetScene().Add( editor );
1924 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1925 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1926 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1927 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1928 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1930 // Avoid a crash when core load gl resources.
1931 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1933 // Render and notify
1934 application.SendNotification();
1935 application.Render();
1937 // Send some taps and check text controller with clipboard window
1938 Dali::Clipboard clipboard = Clipboard::Get();
1939 clipboard.ShowClipboard();
1940 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1941 clipboard.HideClipboard();
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1947 // Tap first to get the focus.
1948 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1950 // Render and notify
1951 application.SendNotification();
1952 application.Render();
1954 // Double tap to select a word.
1955 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1957 // Render and notify
1958 application.SendNotification();
1959 application.Render();
1961 // The stencil actor should have two actors: the renderer and the highlight actor.
1962 Actor stencil = editor.GetChildAt( 0u );
1964 // Highlight needs to be drawn before text, so should come first in child order
1965 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1966 DALI_TEST_CHECK( highlight );
1968 // The stencil actor has a container with all the actors which contain the text renderers.
1969 Actor container = stencil.GetChildAt( 1u );
1970 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1972 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1973 DALI_TEST_CHECK( renderer );
1976 // Double tap out of bounds
1977 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1978 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1980 // Render and notify
1981 application.SendNotification();
1982 application.Render();
1984 // The stencil actor should have one actors: the renderer actor.
1985 stencil = editor.GetChildAt( 0u );
1987 // The stencil actor has a container with all the actors which contain the text renderers.
1988 container = stencil.GetChildAt( 0u );
1989 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1991 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1992 DALI_TEST_CHECK( renderer );
1996 TestGenerateLongPress(application, 1.0f, 25.0f);
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2003 TestGenerateMiniPan(application);
2005 // Render and notify
2006 application.SendNotification();
2007 application.Render();
2012 int utcDaliTextEditorEvent04(void)
2014 ToolkitTestApplication application;
2015 tet_infoline(" utcDaliTextEditorEvent04");
2017 // Checks if the highlight actor is created.
2019 TextEditor editor = TextEditor::New();
2020 DALI_TEST_CHECK( editor );
2022 application.GetScene().Add( editor );
2024 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2025 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2026 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2027 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2028 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2030 // Avoid a crash when core load gl resources.
2031 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2033 // Render and notify
2034 application.SendNotification();
2035 application.Render();
2037 // Tap on the text editor
2038 TestGenerateTap( application, 3.0f, 25.0f );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2044 // Move at the end of the text.
2045 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 for( unsigned int index = 0u; index < 10u; ++index )
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2063 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2069 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2071 // Add some key events
2072 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2073 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2075 // Render and notify
2076 application.SendNotification();
2077 application.Render();
2079 for( unsigned int index = 0u; index < 10u; ++index )
2081 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2090 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2092 // Render and notify
2093 application.SendNotification();
2094 application.Render();
2096 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2101 int utcDaliTextEditorEvent05(void)
2103 ToolkitTestApplication application;
2104 tet_infoline(" utcDaliTextEditorEvent05");
2106 // Checks if the highlight actor is created.
2108 TextEditor editor = TextEditor::New();
2109 DALI_TEST_CHECK( editor );
2111 application.GetScene().Add( editor );
2113 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2114 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2115 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2116 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2117 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2118 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2119 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2120 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2121 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2122 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2124 // Avoid a crash when core load gl resources.
2125 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2127 // Render and notify
2128 application.SendNotification();
2129 application.Render();
2131 // Tap on the text editor
2132 TestGenerateTap( application, 3.0f, 25.0f );
2134 // Render and notify
2135 application.SendNotification();
2136 application.Render();
2138 // Move at the end of the text.
2139 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2140 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 for( unsigned int index = 0u; index < 10u; ++index )
2149 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 // Modify duration after scroll is enabled
2156 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2158 // Continuous scroll left to increase coverage
2159 for( unsigned int index = 0u; index < 10u; ++index )
2161 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2168 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2169 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2170 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2171 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2173 // Press Escape to increase coverage
2174 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2175 application.SendNotification();
2176 application.Render();
2178 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2183 int utcDaliTextEditorEvent06(void)
2185 ToolkitTestApplication application;
2186 tet_infoline(" utcDaliTextEditorEvent06");
2188 // Checks if the highlight actor is created.
2190 TextEditor editor = TextEditor::New();
2191 DALI_TEST_CHECK( editor );
2193 application.GetScene().Add( editor );
2195 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2196 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2197 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2198 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2199 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2201 // Avoid a crash when core load gl resources.
2202 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 // Tap on the text editor
2209 TestGenerateTap( application, 3.0f, 25.0f );
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 // Move to seconds line of the text.
2216 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218 // Render and notify
2219 application.SendNotification();
2220 application.Render();
2222 float layoutHeight = editor.GetHeightForWidth( 100.f );
2225 // Add another script characters ( glyph height is defferent )
2226 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2229 // Delete characters
2230 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2231 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2233 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2235 // Render and notify
2236 application.SendNotification();
2237 application.Render();
2239 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2242 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2243 application.SendNotification();
2244 application.Render();
2246 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2247 application.SendNotification();
2248 application.Render();
2250 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2251 application.SendNotification();
2252 application.Render();
2254 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 application.SendNotification();
2256 application.Render();
2258 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2259 application.SendNotification();
2260 application.Render();
2262 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263 application.SendNotification();
2264 application.Render();
2266 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 application.SendNotification();
2268 application.Render();
2273 int utcDaliTextEditorEvent07(void)
2275 ToolkitTestApplication application;
2276 tet_infoline(" utcDaliTextEditorEvent07");
2278 // Checks if the highlight actor is created.
2280 TextEditor editor = TextEditor::New();
2281 DALI_TEST_CHECK( editor );
2283 application.GetScene().Add( editor );
2285 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2286 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2287 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2288 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2289 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2291 // Avoid a crash when core load gl resources.
2292 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2294 // Render and notify
2295 application.SendNotification();
2296 application.Render();
2298 // Tap on the text editor
2299 TestGenerateTap( application, 3.0f, 25.0f );
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 // Move to second line of the text.
2306 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 // Render and notify
2309 application.SendNotification();
2310 application.Render();
2312 // Select some text in the right of the current cursor position
2313 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2322 // Cut the selected text
2323 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2330 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2332 // Select some text in the left of the current cursor position
2333 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2334 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2338 // Render and notify
2339 application.SendNotification();
2340 application.Render();
2342 // Copy the selected text
2343 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 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 ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Move the cursor to the third line
2351 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // Paste the selected text at the current cursor position
2359 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 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 ) );
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2366 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2369 // Disable Shift Selection
2370 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2372 // Test to select some text in the right of the current cursor position
2373 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2374 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 // Render and notify
2379 application.SendNotification();
2380 application.Render();
2382 // Cut the selected text
2383 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 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 ) );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2391 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2393 // Test to select some text in the left of the current cursor position
2394 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2396 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2397 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2399 // Render and notify
2400 application.SendNotification();
2401 application.Render();
2403 // Copy the selected text
2404 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 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 ) );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2412 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2415 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 ) );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 // replace text with "c"
2422 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2429 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2432 DevelTextEditor::SelectWholeText(editor);
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 // Copy the selected text using logical keys
2439 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2447 DevelTextEditor::SelectNone(editor);
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 // Paste the selected using logical keys
2454 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2455 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2458 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2460 // select all using logical keys
2461 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2462 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2468 // cut text using logical keys
2469 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2472 // Render and notify
2473 application.SendNotification();
2474 application.Render();
2477 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2482 int utcDaliTextEditorEvent08(void)
2484 ToolkitTestApplication application;
2485 tet_infoline(" utcDaliTextEditorEvent08");
2487 // Checks if the highlight actor is released correctly.
2489 TextEditor editor = TextEditor::New();
2490 DALI_TEST_CHECK( editor );
2492 application.GetScene().Add( editor );
2494 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2495 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2496 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2497 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2498 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2500 // Avoid a crash when core load gl resources.
2501 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2503 // Render and notify
2504 application.SendNotification();
2505 application.Render();
2507 // Tap on the text editor
2508 TestGenerateTap( application, 3.0f, 25.0f );
2510 // Render and notify
2511 application.SendNotification();
2512 application.Render();
2514 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2515 // Test to select some text in the left of the current cursor position
2516 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2517 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2518 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2519 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2521 // Render and notify
2522 application.SendNotification();
2523 application.Render();
2525 // Test to the left selection handle position and the right selection handle position
2526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2529 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Test to select full text in the left of the current cursor position
2536 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2539 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2540 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2541 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2543 // Render and notify
2544 application.SendNotification();
2545 application.Render();
2547 // Test to release the current full text selection
2548 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2551 // Render and notify
2552 application.SendNotification();
2553 application.Render();
2555 // Test to move the current cursor position correctly
2556 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2563 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2565 // Render and notify
2566 application.SendNotification();
2567 application.Render();
2569 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2571 // Test to select some text in the right of the current cursor position
2572 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2573 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2574 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Test the cursor position with right arrow key
2581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 // Render and notify
2584 application.SendNotification();
2585 application.Render();
2588 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2590 // Render and notify
2591 application.SendNotification();
2592 application.Render();
2594 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2596 // Test to select some text in the left of the current cursor position
2597 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2598 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2599 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2600 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2601 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2603 // Render and notify
2604 application.SendNotification();
2605 application.Render();
2607 // Test the cursor position with left arrow key
2608 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2610 // Render and notify
2611 application.SendNotification();
2612 application.Render();
2615 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2617 // Render and notify
2618 application.SendNotification();
2619 application.Render();
2621 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2623 // Test to select some text in the right of the current cursor position
2624 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2625 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2626 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2627 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2629 // Render and notify
2630 application.SendNotification();
2631 application.Render();
2633 // Test the cursor position with left arrow key
2634 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2636 // Render and notify
2637 application.SendNotification();
2638 application.Render();
2641 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2643 // Render and notify
2644 application.SendNotification();
2645 application.Render();
2647 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2649 // Test to select some text in the left of the current cursor position
2650 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2651 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2652 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2653 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2655 // Render and notify
2656 application.SendNotification();
2657 application.Render();
2659 // Test the cursor position with right arrow key
2660 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2662 // Render and notify
2663 application.SendNotification();
2664 application.Render();
2667 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2669 // Render and notify
2670 application.SendNotification();
2671 application.Render();
2673 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2678 int utcDaliTextEditorHandles(void)
2680 ToolkitTestApplication application;
2681 tet_infoline(" utcDaliTextEditorHandles");
2683 TextEditor editor = TextEditor::New();
2684 DALI_TEST_CHECK( editor );
2686 application.GetScene().Add( editor );
2688 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2689 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2690 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2691 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2693 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2694 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2695 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2696 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2698 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2699 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2700 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2702 // Avoid a crash when core load gl resources.
2703 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2705 // Render and notify
2706 application.SendNotification();
2707 application.Render();
2709 // Tap first to get the focus.
2710 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2712 // Render and notify
2713 application.SendNotification();
2714 application.Render();
2716 // Tap to create the grab handle.
2717 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2719 // Render and notify
2720 application.SendNotification();
2721 application.Render();
2723 // Get the active layer where the text's decoration is added.
2724 Actor activeLayer = editor.GetChildAt( 1u );
2726 // Get the handle's actor.
2727 Actor handle = activeLayer.GetChildAt( 1u );
2728 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2730 // Render and notify
2731 application.SendNotification();
2732 application.Render();
2734 // Touch the grab handle to set it as pressed.
2735 Vector2 touchPos( 10.0f, 50.0f );
2736 Dali::Integration::TouchEvent event;
2737 event = Dali::Integration::TouchEvent();
2738 event.AddPoint( GetPointDownInside( touchPos ) );
2739 application.ProcessEvent( event );
2741 // Render and notify
2742 application.SendNotification();
2743 application.Render();
2745 // Pan the grab handle
2746 uint32_t time = 100;
2747 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2748 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2749 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2750 application.SendNotification();
2751 application.Render();
2754 // Release the grab handle.
2755 event = Dali::Integration::TouchEvent();
2756 event.AddPoint( GetPointUpInside( touchPos ) );
2757 application.ProcessEvent( event );
2759 // Render and notify
2760 application.SendNotification();
2761 application.Render();
2763 // Tap first to get the focus.
2764 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2766 // Render and notify
2767 application.SendNotification();
2768 application.Render();
2770 // Double tap to select a word and create the selection handles.
2771 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2773 // Render and notify
2774 application.SendNotification();
2775 application.Render();
2777 touchPos = Vector2( 10.0f, 50.0f );
2779 // Touch the left selection handle to set it as pressed.
2780 event = Dali::Integration::TouchEvent();
2781 event.AddPoint( GetPointDownInside( touchPos ) );
2782 application.ProcessEvent( event );
2784 // Render and notify
2785 application.SendNotification();
2786 application.Render();
2788 // Release the left selection handle.
2789 event = Dali::Integration::TouchEvent();
2790 event.AddPoint( GetPointUpInside( touchPos ) );
2791 application.ProcessEvent( event );
2793 // Render and notify
2794 application.SendNotification();
2795 application.Render();
2800 int utcDaliTextEditorUnderPropertyStringP(void)
2802 ToolkitTestApplication application;
2803 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2804 TextEditor editor = TextEditor::New();
2805 DALI_TEST_CHECK( editor );
2807 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2809 application.GetScene().Add( editor );
2811 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2812 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2814 tet_infoline("Set underline settings with a map");
2815 // Check the input underline property
2816 Property::Map underlineMapSet;
2817 Property::Map underlineMapGet;
2818 underlineMapSet.Insert( "enable", true );
2819 underlineMapSet.Insert( "color", Color::BLUE );
2820 underlineMapSet.Insert( "height", 2 );
2822 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2823 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2824 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2825 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2827 tet_infoline("Set underline settings with a string");
2828 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2829 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2832 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2834 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2835 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2836 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2837 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2839 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2844 int utcDaliTextEditorShadowPropertyStringP(void)
2846 ToolkitTestApplication application;
2847 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2849 TextEditor editor = TextEditor::New();
2851 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2853 application.GetScene().Add( editor );
2855 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2857 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2861 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2866 int utcDaliTextEditorFontStylePropertyStringP(void)
2868 ToolkitTestApplication application;
2869 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2871 TextEditor editor = TextEditor::New();
2873 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2875 application.GetScene().Add( editor );
2877 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2879 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2883 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2888 int utcDaliTextEditorGetPropertyLinecountP(void)
2890 ToolkitTestApplication application;
2892 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2896 TextEditor editor = TextEditor::New();
2897 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2898 editor.SetProperty( TextEditor::Property::TEXT,
2899 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2901 application.GetScene().Add( editor );
2903 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2904 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2905 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2907 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2908 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2909 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2914 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2917 ToolkitTestApplication application;
2918 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2920 TextEditor editor = TextEditor::New();
2921 DALI_TEST_CHECK( editor );
2923 application.GetScene().Add( editor );
2925 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2926 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2927 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2928 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2929 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2930 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2932 bool startedCalled = false;
2933 bool finishedCalled = false;
2935 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2936 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2938 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2940 // Render and notify
2941 application.SendNotification();
2942 application.Render();
2944 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2945 application.SendNotification();
2946 application.Render(6000);
2948 application.SendNotification();
2949 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2950 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2955 int UtcDaliToolkitTextEditorTextWrapMode(void)
2957 ToolkitTestApplication application;
2958 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2962 TextEditor editor = TextEditor::New();
2963 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2964 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2966 application.GetScene().Add( editor );
2968 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2969 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2971 application.SendNotification();
2972 application.Render();
2974 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2975 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2977 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2978 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2980 application.SendNotification();
2981 application.Render();
2983 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2984 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2986 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2987 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2989 application.SendNotification();
2990 application.Render();
2992 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2993 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2995 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2996 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2998 application.SendNotification();
2999 application.Render();
3001 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3002 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3007 int UtcDaliTextEditorSetPaddingProperty(void)
3009 ToolkitTestApplication application;
3010 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3012 TextEditor editor = TextEditor::New();
3013 DALI_TEST_CHECK( editor );
3014 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3015 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3016 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3017 application.GetScene().Add( editor );
3019 application.SendNotification();
3020 application.Render();
3022 Vector3 originalSize = editor.GetNaturalSize();
3024 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3026 application.SendNotification();
3027 application.Render();
3029 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3031 Vector3 paddingAddedSize = editor.GetNaturalSize();
3033 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3035 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3040 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3042 ToolkitTestApplication application;
3043 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3045 TextEditor editor = TextEditor::New();
3046 DALI_TEST_CHECK( editor );
3047 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3048 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3049 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3050 application.GetScene().Add( editor );
3052 application.SendNotification();
3053 application.Render();
3055 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3056 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3058 // Check the enable shift selection property
3059 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3060 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3062 application.SendNotification();
3063 application.Render();
3068 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3070 ToolkitTestApplication application;
3071 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3073 TextEditor editor = TextEditor::New();
3074 DALI_TEST_CHECK( editor );
3075 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3076 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3077 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3078 application.GetScene().Add( editor );
3080 application.SendNotification();
3081 application.Render();
3083 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3084 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3086 // Check the enable grab handle property
3087 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3088 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3090 application.SendNotification();
3091 application.Render();
3096 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3098 ToolkitTestApplication application;
3099 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3101 TextEditor editor = TextEditor::New();
3102 DALI_TEST_CHECK( editor );
3103 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3104 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3105 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3106 application.GetScene().Add( editor );
3108 application.SendNotification();
3109 application.Render();
3111 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3112 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3114 // Check the disable match system language direction property
3115 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3116 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3118 application.SendNotification();
3119 application.Render();
3124 int UtcDaliTextEditorGetInputMethodContext(void)
3126 ToolkitTestApplication application;
3127 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3129 TextEditor editor = TextEditor::New();
3130 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3135 int utcDaliTextEditorMaxCharactersReached(void)
3137 ToolkitTestApplication application;
3138 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3140 TextEditor editor = TextEditor::New();
3141 DALI_TEST_CHECK( editor );
3143 application.GetScene().Add( editor );
3145 const int maxNumberOfCharacters = 1;
3146 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3147 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3149 editor.SetKeyInputFocus();
3151 // connect to the text changed signal.
3152 ConnectionTracker* testTracker = new ConnectionTracker();
3153 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3154 bool maxLengthReachedSignal = false;
3155 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3157 gMaxCharactersCallBackCalled = false;
3159 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3160 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3162 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3163 DALI_TEST_CHECK( maxLengthReachedSignal );
3168 int utcDaliTextEditorInputFiltered(void)
3170 ToolkitTestApplication application;
3171 tet_infoline(" utcDaliTextEditorInputFiltered");
3172 TextEditor editor = TextEditor::New();
3173 DALI_TEST_CHECK(editor);
3175 application.GetScene().Add(editor);
3177 Property::Map inputFilter;
3179 // Only digit is accepted.
3180 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3182 // Set input filter to TextEditor.
3183 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3185 editor.SetKeyInputFocus();
3187 // connect to the input filtered signal.
3188 ConnectionTracker* testTracker = new ConnectionTracker();
3189 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3190 bool inputFilteredSignal = false;
3191 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3193 gInputFilteredAcceptedCallbackCalled = false;
3195 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3197 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3198 DALI_TEST_CHECK(inputFilteredSignal);
3200 // Word is rejected.
3201 inputFilter[InputFilter::Property::ACCEPTED] = "";
3202 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3204 // Set input filter to TextEditor.
3205 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3207 editor.SetKeyInputFocus();
3209 inputFilteredSignal = false;
3210 gInputFilteredRejectedCallbackCalled = false;
3212 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3214 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3215 DALI_TEST_CHECK(inputFilteredSignal);
3220 int UtcDaliTextEditorSelectWholeText(void)
3222 ToolkitTestApplication application;
3223 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3225 TextEditor textEditor = TextEditor::New();
3227 application.GetScene().Add( textEditor );
3229 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3230 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3231 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3233 // Avoid a crash when core load gl resources.
3234 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3236 application.SendNotification();
3237 application.Render();
3239 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3241 DevelTextEditor::SelectWholeText( textEditor );
3243 application.SendNotification();
3244 application.Render();
3246 // Nothing should have been selected. The number of children is still 1
3247 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3249 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3251 application.SendNotification();
3252 application.Render();
3254 DevelTextEditor::SelectWholeText( textEditor );
3256 application.SendNotification();
3257 application.Render();
3259 // Should be 2 children, the stencil and the layer
3260 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3262 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3263 Actor stencil = textEditor.GetChildAt( 0u );
3265 // The highlight actor is drawn first, so is the first actor in the list
3266 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3267 DALI_TEST_CHECK( highlight );
3272 int UtcDaliTextEditorSelectText(void)
3274 ToolkitTestApplication application;
3275 tet_infoline(" UtcDaliTextEditorSelectText ");
3277 TextEditor textEditor = TextEditor::New();
3279 application.GetScene().Add( textEditor );
3281 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3282 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3283 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3285 // Avoid a crash when core load gl resources.
3286 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3288 application.SendNotification();
3289 application.Render();
3291 DevelTextEditor::SelectText( textEditor ,0, 5 );
3293 application.SendNotification();
3294 application.Render();
3296 // Nothing is selected
3297 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3298 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3300 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3302 application.SendNotification();
3303 application.Render();
3305 DevelTextEditor::SelectText( textEditor, 0, 5 );
3307 application.SendNotification();
3308 application.Render();
3310 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3311 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3313 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3314 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3316 // world is selected
3317 DevelTextEditor::SelectText( textEditor, 6, 11 );
3319 application.SendNotification();
3320 application.Render();
3322 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3323 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3325 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3326 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3331 int UtcDaliTextEditorSelectNone(void)
3333 ToolkitTestApplication application;
3334 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3336 TextEditor textEditor = TextEditor::New();
3338 application.GetScene().Add( textEditor );
3340 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3341 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3342 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3344 // Avoid a crash when core load gl resources.
3345 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3347 application.SendNotification();
3348 application.Render();
3350 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3352 application.SendNotification();
3353 application.Render();
3355 // Nothing is selected
3356 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3357 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3359 DevelTextEditor::SelectWholeText( textEditor );
3361 application.SendNotification();
3362 application.Render();
3364 // whole text is selected
3365 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3366 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3368 DevelTextEditor::SelectNone( textEditor );
3370 application.SendNotification();
3371 application.Render();
3373 // Nothing is selected
3374 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3375 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3380 int UtcDaliTextEditorSelectRange(void)
3382 ToolkitTestApplication application;
3383 tet_infoline("utcDaliTextEditorSelectRange");
3385 TextEditor textEditor = TextEditor::New();
3386 DALI_TEST_CHECK( textEditor );
3388 application.GetScene().Add( textEditor );
3390 // Avoid a crash when core load gl resources.
3391 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3393 application.SendNotification();
3394 application.Render();
3396 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3398 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3399 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3401 // Hello is selected
3402 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3403 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3405 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3406 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3411 int UtcDaliTextEditorEnableEditing(void)
3413 ToolkitTestApplication application;
3414 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3416 TextEditor textEditor = TextEditor::New();
3418 application.GetScene().Add( textEditor );
3420 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3421 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3422 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3424 // Avoid a crash when core load gl resources.
3425 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3427 application.SendNotification();
3428 application.Render();
3430 textEditor.SetKeyInputFocus();
3431 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3432 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3434 // Render and notify
3435 application.SendNotification();
3436 application.Render();
3438 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3439 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3441 textEditor.SetKeyInputFocus();
3442 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3443 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3445 // Render and notify
3446 application.SendNotification();
3447 application.Render();
3449 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3450 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3455 int UtcDaliTextEditorScrolling(void)
3457 ToolkitTestApplication application;
3458 tet_infoline(" UtcDaliTextEditorScrolling ");
3460 TextEditor textEditor = TextEditor::New();
3461 DALI_TEST_CHECK( textEditor );
3463 application.GetScene().Add( textEditor );
3465 // Avoid a crash when core load gl resources.
3466 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3468 application.SendNotification();
3469 application.Render();
3471 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3472 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3473 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3474 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3476 application.SendNotification();
3477 application.Render();
3479 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3480 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3483 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3485 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3486 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3488 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3490 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3491 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3493 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3494 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3496 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3497 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3502 int UtcDaliToolkitTextEditorFontSizeScale(void)
3504 ToolkitTestApplication application;
3505 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3507 TextEditor textEditor = TextEditor::New();
3508 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3509 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3510 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3512 TextEditor textEditorScaled = TextEditor::New();
3513 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3514 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3515 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3516 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3518 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3520 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3521 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3522 nonScaledSize = textEditor.GetNaturalSize();
3524 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3525 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3526 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3527 scaledSize = textEditorScaled.GetNaturalSize();
3529 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3534 int UtcDaliTextEditorPrimaryCursorPosition(void)
3536 ToolkitTestApplication application;
3537 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3539 TextEditor textEditor = TextEditor::New();
3541 application.GetScene().Add( textEditor );
3543 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3544 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3545 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3546 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3548 // Avoid a crash when core load gl resources.
3549 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3551 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3552 application.SendNotification();
3553 application.Render();
3554 textEditor.SetKeyInputFocus();
3556 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3558 // Render and notify
3559 application.SendNotification();
3560 application.Render();
3562 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3563 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3568 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3570 ToolkitTestApplication application;
3571 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3573 TextEditor textEditor = TextEditor::New();
3574 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3575 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3576 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3577 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3578 application.GetScene().Add( textEditor );
3580 application.SendNotification();
3581 application.Render();
3584 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3585 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3587 textEditor.GetNaturalSize();
3589 // Create a tap event to touch the text editor.
3590 TestGenerateTap( application, 18.0f, 25.0f );
3592 application.SendNotification();
3593 application.Render();
3595 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3596 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3602 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3604 ToolkitTestApplication application;
3606 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3608 int lineCountBefore =0 ;
3609 int lineCountAfter =0 ;
3611 // Create a text editor
3612 TextEditor textEditor = TextEditor::New();
3613 //Set very large font-size using point-size
3614 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3615 //Specify font-family
3616 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3618 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3619 //Set text longer than width of textEditor
3620 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3622 application.GetScene().Add( textEditor );
3624 application.SendNotification();
3625 application.Render();
3627 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3628 //GetHeightForWidth is a retrieval method which should not modify object
3629 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3630 textEditor.GetHeightForWidth(200.f);
3632 //This is to simulate focus into text editor after calling GetHeightForWidth
3633 //Create a tap event to touch the text editor.
3634 TestGenerateTap( application, 18.0f, 25.0f );
3636 application.SendNotification();
3637 application.Render();
3639 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3641 //The LineCount must not be changed when calling GetHeightForWidth.
3642 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3647 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3649 ToolkitTestApplication application;
3651 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3653 int lineCountBefore =0 ;
3654 int lineCountAfter =0 ;
3656 // Create a text editor
3657 TextEditor textEditor = TextEditor::New();
3658 //Set very large font-size using point-size
3659 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3660 //Specify font-family
3661 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3663 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3664 //Set text longer than width of textEditor
3665 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3666 //Set line wrap mode Character
3667 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3669 application.GetScene().Add( textEditor );
3671 application.SendNotification();
3672 application.Render();
3674 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3675 //GetHeightForWidth is a retrieval method which should not modify object
3676 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3677 textEditor.GetHeightForWidth(200.f);
3679 //This is to simulate focus into text editor after calling GetHeightForWidth
3680 //Create a tap event to touch the text editor.
3681 TestGenerateTap( application, 18.0f, 25.0f );
3683 application.SendNotification();
3684 application.Render();
3686 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3688 //The LineCount must not be changed when calling GetHeightForWidth.
3689 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3694 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3696 ToolkitTestApplication application;
3698 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3700 int lineCountBefore =0 ;
3701 int lineCountAfter =0 ;
3703 // Create a text editor
3704 TextEditor textEditor = TextEditor::New();
3705 //Set very large font-size using point-size
3706 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3707 //Specify font-family
3708 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3710 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3711 //Set text longer than width of textEditor
3712 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3713 //Set line wrap mode Character
3714 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3716 application.GetScene().Add( textEditor );
3718 application.SendNotification();
3719 application.Render();
3722 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3724 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3725 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3727 // When the text changed, the Line-count should be updated according to new text.
3728 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3729 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3730 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3737 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3739 ToolkitTestApplication application;
3741 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3743 int lineCountBefore =0 ;
3744 int lineCountAfter =0 ;
3746 // Create a text editor
3747 TextEditor textEditor = TextEditor::New();
3748 //Set very large font-size using point-size
3749 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3750 //Specify font-family
3751 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3753 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3754 //Set text longer than width of textEditor
3755 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3757 application.GetScene().Add( textEditor );
3759 application.SendNotification();
3760 application.Render();
3762 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3763 //GetNaturalSize is a retrieval method which should not modify object
3764 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3765 textEditor.GetNaturalSize();
3767 //This is to simulate focus into text editor after calling GetNaturalSize
3768 //Create a tap event to touch the text editor.
3769 TestGenerateTap( application, 18.0f, 25.0f );
3771 application.SendNotification();
3772 application.Render();
3774 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3776 //The LineCount must not be changed when calling GetNaturalSize.
3777 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3782 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3784 ToolkitTestApplication application;
3786 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3788 int lineCountBefore =0 ;
3789 int lineCountAfter =0 ;
3791 // Create a text editor
3792 TextEditor textEditor = TextEditor::New();
3793 //Set very large font-size using point-size
3794 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3795 //Specify font-family
3796 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3798 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3799 //Set text longer than width of textEditor
3800 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3801 //Set line wrap mode Character
3802 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3804 application.GetScene().Add( textEditor );
3806 application.SendNotification();
3807 application.Render();
3809 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3810 //GetNaturalSize is a retrieval method which should not modify object
3811 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3812 textEditor.GetNaturalSize( );
3814 //This is to simulate focus into text editor after calling GetNaturalSize
3815 //Create a tap event to touch the text editor.
3816 TestGenerateTap( application, 18.0f, 25.0f );
3818 application.SendNotification();
3819 application.Render();
3821 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3823 //The LineCount must not be changed when calling GetNaturalSize.
3824 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3829 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3831 ToolkitTestApplication application;
3832 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3834 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3835 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3836 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3838 // Create a text editor
3839 TextEditor textEditor = TextEditor::New();
3841 //Set size to avoid automatic eliding
3842 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3843 //Set very large font-size using point-size
3844 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3845 //Specify font-family
3846 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3847 //Set text to check if appear or not
3848 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3850 application.GetScene().Add( textEditor );
3852 application.SendNotification();
3853 application.Render();
3854 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3855 Vector3 naturalSize = textEditor.GetNaturalSize();
3857 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3858 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3863 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3865 ToolkitTestApplication application;
3866 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3868 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3869 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3870 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3872 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3873 // Create a text editor
3874 TextEditor textEditor = TextEditor::New();
3875 //Set size to avoid automatic eliding
3876 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3877 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3878 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3880 const int numberOfCases = 6;
3881 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3883 for (int index=0; index < numberOfCases; index++)
3885 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3886 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3887 application.GetScene().Add( textEditor );
3888 application.SendNotification();
3889 application.Render();
3890 naturalSize = textEditor.GetNaturalSize();
3891 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3892 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3899 int UtcDaliTextEditorHyphenWrapMode(void)
3901 ToolkitTestApplication application;
3902 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3905 TextEditor textEditor = TextEditor::New();
3907 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3909 application.GetScene().Add( textEditor );
3910 application.SendNotification();
3911 application.Render();
3913 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3914 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3915 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3917 application.SendNotification();
3918 application.Render();
3920 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3926 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3928 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3929 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3930 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3932 application.SendNotification();
3933 application.Render();
3935 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3942 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3947 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
3949 ToolkitTestApplication application;
3950 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
3951 TextEditor textEditor = TextEditor::New();
3953 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
3954 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3956 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
3957 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3958 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3960 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
3961 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3962 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3964 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
3965 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3966 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3968 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
3969 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
3970 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3972 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
3973 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
3974 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3976 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
3977 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
3978 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3980 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3981 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
3982 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3984 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3985 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
3986 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3988 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3989 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
3990 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3992 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3993 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
3994 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3996 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3997 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
3998 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4000 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4001 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4002 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4007 int UtcDaliTextEditorCopyText(void)
4009 ToolkitTestApplication application;
4010 tet_infoline(" UtcDaliTextEditorCopyText ");
4012 TextEditor textEditor = TextEditor::New();
4014 std::string selectedText = "";
4015 std::string copiedText = "";
4017 application.GetScene().Add( textEditor );
4019 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4020 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4021 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4023 // Avoid a crash when core load gl resources.
4024 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4026 application.SendNotification();
4027 application.Render();
4029 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4031 application.SendNotification();
4032 application.Render();
4034 // Hello is selected
4035 DevelTextEditor::SelectText( textEditor, 0, 5 );
4037 application.SendNotification();
4038 application.Render();
4040 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4041 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4043 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4044 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4047 copiedText = DevelTextEditor::CopyText( textEditor );
4048 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4050 // world is selected
4051 DevelTextEditor::SelectText( textEditor, 6, 11 );
4053 application.SendNotification();
4054 application.Render();
4056 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4057 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4059 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4060 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4063 copiedText = DevelTextEditor::CopyText( textEditor );
4064 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4066 // "lo wo" is selected
4067 DevelTextEditor::SelectText( textEditor, 3, 8 );
4069 application.SendNotification();
4070 application.Render();
4072 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4073 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4075 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4076 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4078 // "lo wo" is copied
4079 copiedText = DevelTextEditor::CopyText( textEditor );
4080 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4085 int UtcDaliTextEditorCutText(void)
4087 ToolkitTestApplication application;
4088 tet_infoline(" UtcDaliTextEditorCutText ");
4090 TextEditor textEditor = TextEditor::New();
4092 std::string selectedText = "";
4094 application.GetScene().Add( textEditor );
4096 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4097 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4098 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4100 // Avoid a crash when core load gl resources.
4101 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4103 application.SendNotification();
4104 application.Render();
4106 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4108 application.SendNotification();
4109 application.Render();
4111 // Hello is selected
4112 DevelTextEditor::SelectText( textEditor, 0, 5 );
4114 application.SendNotification();
4115 application.Render();
4117 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4118 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4120 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4121 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4124 DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4126 application.SendNotification();
4127 application.Render();
4129 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4132 DevelTextEditor::SelectText( textEditor, 0, 2 );
4134 application.SendNotification();
4135 application.Render();
4137 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4138 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4140 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4141 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4144 DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4146 application.SendNotification();
4147 application.Render();
4149 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4151 // Test Cut from the middle
4154 DevelTextEditor::SelectText( textEditor, 1, 3 );
4156 application.SendNotification();
4157 application.Render();
4159 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4160 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4162 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4163 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4166 DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4168 application.SendNotification();
4169 application.Render();
4171 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4173 // Test Cut from the end
4176 DevelTextEditor::SelectText( textEditor, 1, 2 );
4178 application.SendNotification();
4179 application.Render();
4181 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4182 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4184 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4185 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4188 DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4190 application.SendNotification();
4191 application.Render();
4193 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4198 int UtcDaliTextEditorPasteText(void)
4200 ToolkitTestApplication application;
4201 tet_infoline(" UtcDaliTextEditorPasteText ");
4203 TextEditor editor = TextEditor::New();
4204 DALI_TEST_CHECK( editor );
4206 application.GetScene().Add( editor );
4208 std::string cutText = "";
4209 std::string copiedText = "";
4211 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4212 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4213 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4214 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4215 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4217 // Avoid a crash when core load gl resources.
4218 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4220 // Render and notify
4221 application.SendNotification();
4222 application.Render();
4224 // Tap on the text editor
4225 TestGenerateTap( application, 3.0f, 25.0f );
4227 // Render and notify
4228 application.SendNotification();
4229 application.Render();
4231 // Move to second line of the text.
4232 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4234 // Render and notify
4235 application.SendNotification();
4236 application.Render();
4238 // Select some text in the right of the current cursor position
4239 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4240 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4241 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4242 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4244 // Render and notify
4245 application.SendNotification();
4246 application.Render();
4248 // Cut the selected text
4249 cutText = DevelTextEditor::CutText(editor);
4251 // Render and notify
4252 application.SendNotification();
4253 application.Render();
4255 DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
4256 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4258 // Select some text in the left of the current cursor position
4259 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4260 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4261 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4262 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4264 // Render and notify
4265 application.SendNotification();
4266 application.Render();
4268 // Copy the selected text
4269 copiedText = DevelTextEditor::CopyText(editor);
4271 // Render and notify
4272 application.SendNotification();
4273 application.Render();
4275 DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
4276 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4279 // Move the cursor to the third line
4280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4281 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4283 // Render and notify
4284 application.SendNotification();
4285 application.Render();
4287 // Paste the selected text at the current cursor position
4288 DevelTextEditor::PasteText(editor);
4290 // Render and notify
4291 application.SendNotification();
4292 application.Render();
4294 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4298 int UtcDaliTextEditorLineSpacing(void)
4300 ToolkitTestApplication application;
4301 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4303 TextEditor textEditor = TextEditor::New();
4304 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4305 application.GetScene().Add( textEditor );
4306 application.SendNotification();
4307 application.Render();
4309 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4310 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4312 Vector3 sizeBefore = textEditor.GetNaturalSize();
4314 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4316 //add 20 for each line 20 * 3
4317 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4322 int UtcDaliTextEditorMinLineSize(void)
4324 ToolkitTestApplication application;
4325 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4327 TextEditor textEditor = TextEditor::New();
4328 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4329 application.GetScene().Add( textEditor );
4330 application.SendNotification();
4331 application.Render();
4333 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4334 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4336 Vector3 sizeBefore = textEditor.GetNaturalSize();
4338 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4340 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4343 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4348 int utcDaliTextEditorCursorPositionChangedSignal(void)
4350 ToolkitTestApplication application;
4351 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4353 TextEditor editor = TextEditor::New();
4354 DALI_TEST_CHECK( editor );
4356 application.GetScene().Add( editor );
4358 // connect to the selection changed signal.
4359 ConnectionTracker* testTracker = new ConnectionTracker();
4360 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4361 bool cursorPositionChangedSignal = false;
4362 editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4364 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4365 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4366 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4367 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4368 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4370 // Avoid a crash when core load gl resources.
4371 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4373 // Render and notify
4374 application.SendNotification();
4375 application.Render();
4377 editor.SetKeyInputFocus();
4379 // Tap on the text editor
4380 TestGenerateTap( application, 3.0f, 25.0f );
4382 // Render and notify
4383 application.SendNotification();
4384 application.Render();
4386 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4387 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4389 gCursorPositionChangedCallbackCalled = false;
4392 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4394 // Render and notify
4395 application.SendNotification();
4396 application.Render();
4398 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4399 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4401 gCursorPositionChangedCallbackCalled = false;
4404 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4406 // Render and notify
4407 application.SendNotification();
4408 application.Render();
4410 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4411 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4413 gCursorPositionChangedCallbackCalled = false;
4415 //delete one character
4416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4418 // Render and notify
4419 application.SendNotification();
4420 application.Render();
4422 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4423 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4425 gCursorPositionChangedCallbackCalled = false;
4427 editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4429 // Render and notify
4430 application.SendNotification();
4431 application.Render();
4433 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4434 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4436 gCursorPositionChangedCallbackCalled = false;
4438 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4440 // Render and notify
4441 application.SendNotification();
4442 application.Render();
4444 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4445 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4450 int utcDaliTextEditorSelectionChangedSignal(void)
4452 ToolkitTestApplication application;
4453 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
4455 TextEditor editor = TextEditor::New();
4456 DALI_TEST_CHECK( editor );
4458 application.GetScene().Add( editor );
4460 // connect to the selection changed signal.
4461 ConnectionTracker* testTracker = new ConnectionTracker();
4462 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
4463 bool selectionChangedSignal = false;
4464 editor.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4466 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4467 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4468 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4469 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4470 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4472 // Avoid a crash when core load gl resources.
4473 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4475 // Render and notify
4476 application.SendNotification();
4477 application.Render();
4479 // Tap on the text editor
4480 TestGenerateTap( application, 3.0f, 25.0f );
4482 // Render and notify
4483 application.SendNotification();
4484 application.Render();
4486 // Move to second line of the text.
4487 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4489 // Render and notify
4490 application.SendNotification();
4491 application.Render();
4493 // Select some text in the right of the current cursor position
4494 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4495 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4497 // Render and notify
4498 application.SendNotification();
4499 application.Render();
4501 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4502 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4504 gSelectionChangedCallbackCalled = false;
4506 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4508 // Render and notify
4509 application.SendNotification();
4510 application.Render();
4512 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4513 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4514 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
4516 gSelectionChangedCallbackCalled = false;
4518 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4520 // Render and notify
4521 application.SendNotification();
4522 application.Render();
4524 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4525 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4526 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
4528 gSelectionChangedCallbackCalled = false;
4529 editor.SetKeyInputFocus();
4531 // Render and notify
4532 application.SendNotification();
4533 application.Render();
4535 DevelTextEditor::SelectText( editor ,0, 5 );
4537 application.SendNotification();
4538 application.Render();
4540 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4541 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4543 gSelectionChangedCallbackCalled = false;
4545 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4547 // Render and notify
4548 application.SendNotification();
4549 application.Render();
4551 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4552 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4553 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4555 gSelectionChangedCallbackCalled = false;
4558 DevelTextEditor::SelectWholeText(editor);
4560 // Render and notify
4561 application.SendNotification();
4562 application.Render();
4564 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4565 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4567 gSelectionChangedCallbackCalled = false;
4570 DevelTextEditor::SelectNone(editor);
4572 // Render and notify
4573 application.SendNotification();
4574 application.Render();
4576 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4577 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4578 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);