2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
32 #include "test-text-geometry-utils.h"
35 using namespace Toolkit;
37 void dali_texteditor_startup(void)
39 test_return_value = TET_UNDEF;
42 void dali_texteditor_cleanup(void)
44 test_return_value = TET_PASS;
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
58 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
59 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
60 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
61 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
63 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
64 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
66 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
72 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
73 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
74 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
75 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
76 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
77 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
78 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
79 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
81 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
82 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
83 const char* const PROPERTY_NAME_UNDERLINE = "underline";
84 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
85 const char* const PROPERTY_NAME_SHADOW = "shadow";
86 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
87 const char* const PROPERTY_NAME_EMBOSS = "emboss";
88 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
89 const char* const PROPERTY_NAME_OUTLINE = "outline";
90 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
93 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
94 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
95 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
96 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
97 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
98 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
100 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
101 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
102 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
105 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
107 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
109 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
110 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
111 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
112 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
114 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
115 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
117 const float RENDER_FRAME_INTERVAL = 16.66f;
119 const unsigned int DEFAULT_FONT_SIZE = 1152u;
120 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
122 const int KEY_A_CODE = 38;
123 const int KEY_D_CODE = 40;
124 const int KEY_C_CODE = 54;
125 const int KEY_V_CODE = 55;
126 const int KEY_X_CODE = 53;
127 const int KEY_WHITE_SPACE_CODE = 65;
129 const int KEY_SHIFT_MODIFIER = 257;
130 const int KEY_CONTROL_MODIFIER = 258;
132 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
133 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
134 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
136 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
138 static bool gSelectionChangedCallbackCalled;
139 static uint32_t oldSelectionStart;
140 static uint32_t oldSelectionEnd;
141 static bool gSelectionClearedCallbackCalled;
142 static bool gAnchorClickedCallBackCalled;
143 static bool gAnchorClickedCallBackNotCalled;
144 static bool gTextChangedCallBackCalled;
145 static bool gInputFilteredAcceptedCallbackCalled;
146 static bool gInputFilteredRejectedCallbackCalled;
147 static bool gInputStyleChangedCallbackCalled;
148 static bool gMaxCharactersCallBackCalled;
149 static bool gCursorPositionChangedCallbackCalled;
150 static uint32_t oldCursorPos;
151 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
153 struct CallbackFunctor
155 CallbackFunctor(bool* callbackFlag)
156 : mCallbackFlag( callbackFlag )
162 *mCallbackFlag = true;
167 static void TestSelectionClearedCallback(TextEditor control)
169 tet_infoline(" TestSelectionClearedCallback");
171 gSelectionClearedCallbackCalled = true;
174 static void TestSelectionChangedCallback(TextEditor control, uint32_t oldStart, uint32_t oldEnd)
176 tet_infoline(" TestSelectionChangedCallback");
178 gSelectionChangedCallbackCalled = true;
179 oldSelectionStart = oldStart;
180 oldSelectionEnd = oldEnd;
183 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
185 tet_infoline(" TestAnchorClickedCallback");
187 gAnchorClickedCallBackNotCalled = false;
189 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
191 gAnchorClickedCallBackCalled = true;
195 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
197 tet_infoline(" TestCursorPositionChangedCallback");
199 gCursorPositionChangedCallbackCalled = true;
200 oldCursorPos = oldPos;
203 static void TestTextChangedCallback( TextEditor control )
205 tet_infoline(" TestTextChangedCallback");
207 gTextChangedCallBackCalled = true;
210 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
212 tet_infoline(" TestInputStyleChangedCallback");
214 gInputStyleChangedCallbackCalled = true;
215 gInputStyleMask = mask;
218 static void TestMaxLengthReachedCallback( TextEditor control )
220 tet_infoline(" TestMaxLengthReachedCallback");
222 gMaxCharactersCallBackCalled = true;
225 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
227 tet_infoline(" TestInputFilteredCallback");
229 if(type == Toolkit::InputFilter::Property::ACCEPTED)
231 gInputFilteredAcceptedCallbackCalled = true;
233 else if(type == Toolkit::InputFilter::Property::REJECTED)
235 gInputFilteredRejectedCallbackCalled = true;
239 // Generate a KeyEvent to send to Core.
240 Integration::KeyEvent GenerateKey( const std::string& keyName,
241 const std::string& logicalKey,
242 const std::string& keyString,
245 unsigned long timeStamp,
246 const Integration::KeyEvent::State& keyState,
247 const std::string& compose = "",
248 const std::string& deviceName = DEFAULT_DEVICE_NAME,
249 const Device::Class::Type& deviceClass = Device::Class::NONE,
250 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
252 return Integration::KeyEvent( keyName,
265 Dali::Integration::Point GetPointDownInside( Vector2& pos )
267 Dali::Integration::Point point;
268 point.SetState( PointState::DOWN );
269 point.SetScreenPosition( pos );
273 Dali::Integration::Point GetPointUpInside( Vector2& pos )
275 Dali::Integration::Point point;
276 point.SetState( PointState::UP );
277 point.SetScreenPosition( pos );
281 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
283 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
285 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
287 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
289 Property::Value* valueSet = NULL;
290 if ( valueGet.first.type == Property::Key::INDEX )
292 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
296 // Get Key is a string so searching Set Map for a string key
297 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
300 if( NULL != valueSet )
302 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
304 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
307 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
309 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
312 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
314 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
317 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
319 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
322 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
324 Vector2 vector2Get = valueGet.second.Get<Vector2>();
325 Vector2 vector2Set = valueSet->Get<Vector2>();
326 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
329 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
331 Vector4 vector4Get = valueGet.second.Get<Vector4>();
332 Vector4 vector4Set = valueSet->Get<Vector4>();
333 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 );
339 if ( valueGet.first.type == Property::Key::INDEX )
341 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
345 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
355 class ScrollStateChangeCallback : public Dali::ConnectionTracker
358 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
359 : mStartedCalled( startedCalled ),
360 mFinishedCalled( finishedCalled )
364 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
366 if( type == TextEditor::Scroll::STARTED )
368 mStartedCalled = true;
370 else if( type == TextEditor::Scroll::FINISHED )
372 mFinishedCalled = true;
376 bool& mStartedCalled;
377 bool& mFinishedCalled;
382 int UtcDaliToolkitTextEditorConstructorP(void)
384 ToolkitTestApplication application;
385 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
386 TextEditor textEditor;
387 DALI_TEST_CHECK( !textEditor );
391 int UtcDaliToolkitTextEditorNewP(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliToolkitTextEditorNewP");
395 TextEditor textEditor = TextEditor::New();
396 DALI_TEST_CHECK( textEditor );
400 int UtcDaliToolkitTextEditorDownCastP(void)
402 ToolkitTestApplication application;
403 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
404 TextEditor textEditor1 = TextEditor::New();
405 BaseHandle object( textEditor1 );
407 TextEditor textEditor2 = TextEditor::DownCast( object );
408 DALI_TEST_CHECK( textEditor2 );
410 TextEditor textEditor3 = DownCast< TextEditor >( object );
411 DALI_TEST_CHECK( textEditor3 );
415 int UtcDaliToolkitTextEditorDownCastN(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
419 BaseHandle uninitializedObject;
420 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
421 DALI_TEST_CHECK( !textEditor1 );
423 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
424 DALI_TEST_CHECK( !textEditor2 );
428 int UtcDaliToolkitTextEditorCopyConstructorP(void)
430 ToolkitTestApplication application;
431 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
432 TextEditor textEditor = TextEditor::New();
433 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
435 TextEditor copy( textEditor );
436 DALI_TEST_CHECK( copy );
437 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
441 int UtcDaliTextEditorMoveConstructor(void)
443 ToolkitTestApplication application;
445 TextEditor textEditor = TextEditor::New();
446 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
447 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
449 TextEditor moved = std::move( textEditor );
450 DALI_TEST_CHECK( moved );
451 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
452 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
453 DALI_TEST_CHECK( !textEditor );
458 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
460 ToolkitTestApplication application;
461 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
462 TextEditor textEditor = TextEditor::New();
463 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
465 TextEditor copy = textEditor;
466 DALI_TEST_CHECK( copy );
467 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
471 int UtcDaliTextEditorMoveAssignment(void)
473 ToolkitTestApplication application;
475 TextEditor textEditor = TextEditor::New();
476 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
477 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
480 moved = std::move( textEditor );
481 DALI_TEST_CHECK( moved );
482 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
483 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
484 DALI_TEST_CHECK( !textEditor );
489 int UtcDaliTextEditorNewP(void)
491 ToolkitTestApplication application;
492 tet_infoline(" UtcDaliToolkitTextEditorNewP");
493 TextEditor textEditor = TextEditor::New();
494 DALI_TEST_CHECK( textEditor );
498 // Positive test case for a method
499 int UtcDaliTextEditorGetPropertyP(void)
501 ToolkitTestApplication application;
502 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
503 TextEditor editor = TextEditor::New();
504 DALI_TEST_CHECK( editor );
506 // Check Property Indices are correct
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
550 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
551 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
552 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
553 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
554 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
555 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
556 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
557 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
558 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE );
559 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
560 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
561 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
562 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
563 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
564 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
565 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
566 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
567 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
568 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
573 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
576 Property::Map imageMap;
577 imageMap[mapKey] =mapValue;
579 editor.SetProperty( property , imageMap );
580 Property::Value propValue = editor.GetProperty( property );
581 Property::Map* resultMap = propValue.GetMap();
583 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
591 // Positive test case for a method
592 int UtcDaliTextEditorSetPropertyP(void)
594 ToolkitTestApplication application;
595 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
596 TextEditor editor = TextEditor::New();
597 DALI_TEST_CHECK( editor );
598 application.GetScene().Add( editor );
600 // Note - we can't check the defaults since the stylesheets are platform-specific
602 // Check the render backend property.
603 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
604 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
606 // Check text property.
607 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
608 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
610 // Check text's color property
611 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
612 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
614 // Check font properties.
615 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
616 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
618 Property::Map fontStyleMapSet;
619 Property::Map fontStyleMapGet;
620 Property::Value* slantValue = NULL;
622 fontStyleMapSet.Insert( "weight", "bold" );
623 fontStyleMapSet.Insert( "width", "condensed" );
624 fontStyleMapSet.Insert( "slant", "italic" );
626 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
627 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
628 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
629 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
631 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
632 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
634 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
635 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
636 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
638 editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, false );
639 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
640 editor.SetProperty( DevelTextEditor::Property::ENABLE_FONT_SIZE_SCALE, true );
643 fontStyleMapSet.Clear();
644 fontStyleMapSet.Insert( "weight", "normal" );
645 fontStyleMapSet.Insert( "slant", "oblique" );
646 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
647 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
648 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
649 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
651 fontStyleMapSet.Clear();
652 fontStyleMapSet.Insert( "slant", "roman" );
653 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
654 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
656 // Replace 'roman' for 'normal'.
657 slantValue = fontStyleMapGet.Find( "slant" );
658 if( NULL != slantValue )
660 if( "normal" == slantValue->Get<std::string>() )
662 fontStyleMapGet["slant"] = "roman";
665 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
666 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
668 fontStyleMapSet.Clear();
670 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
671 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
672 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
673 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
675 // Check that the Alignment properties can be correctly set
676 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
677 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
679 // Check scroll properties.
680 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
681 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
683 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
685 // Check cursor properties
686 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
687 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
688 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
689 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
691 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
692 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
693 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
694 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
695 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
696 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
697 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
698 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
700 // Check handle images
701 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
702 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
703 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
704 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
705 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
707 // Check handle images
708 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
709 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
710 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
711 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
712 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
713 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
715 // Check the highlight color
716 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
717 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
719 // Decoration bounding box
720 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
721 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
723 // Check the enable markup property.
724 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
725 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
726 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
728 // Check input color property.
729 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
730 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
732 // Check input font properties.
733 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
734 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
736 fontStyleMapSet.Clear();
737 fontStyleMapSet.Insert( "weight", "bold" );
738 fontStyleMapSet.Insert( "width", "condensed" );
739 fontStyleMapSet.Insert( "slant", "italic" );
741 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
742 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
743 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
746 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
747 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
749 // Reset input font style.
750 fontStyleMapSet.Clear();
751 fontStyleMapSet.Insert( "weight", "normal" );
752 fontStyleMapSet.Insert( "slant", "oblique" );
754 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
755 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
756 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
757 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
759 fontStyleMapSet.Clear();
760 fontStyleMapSet.Insert( "slant", "roman" );
762 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
763 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
765 // Replace 'roman' for 'normal'.
766 slantValue = fontStyleMapGet.Find( "slant" );
767 if( NULL != slantValue )
769 if( "normal" == slantValue->Get<std::string>() )
771 fontStyleMapGet["slant"] = "roman";
774 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
777 fontStyleMapSet.Clear();
779 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
780 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
781 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
782 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
784 // Check the line spacing property
785 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
786 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
787 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
789 // Check the input line spacing property
790 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
791 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
792 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
794 // Check the underline property
796 Property::Map underlineMapSet;
797 Property::Map underlineMapGet;
799 underlineMapSet.Insert( "enable", true );
800 underlineMapSet.Insert( "color", Color::RED );
801 underlineMapSet.Insert( "height", 1 );
803 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
805 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
806 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
807 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
809 // Check the input underline property
810 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
811 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
813 // Check the shadow property
814 Property::Map shadowMapSet;
815 Property::Map shadowMapGet;
817 shadowMapSet.Insert( "color", Color::GREEN );
818 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
819 shadowMapSet.Insert( "blurRadius", 3.0f );
821 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
823 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
824 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
825 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
827 // Check the input shadow property
828 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
829 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
831 // Check the emboss property
832 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
833 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
835 // Check the input emboss property
836 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
837 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
839 // Check the outline property
841 // Test string type first
842 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
843 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
844 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
846 // Then test the property map type
847 Property::Map outlineMapSet;
848 Property::Map outlineMapGet;
850 outlineMapSet["color"] = Color::RED;
851 outlineMapSet["width"] = 2.0f;
853 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
855 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
856 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
857 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
859 // Check the input outline property
860 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
861 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
863 // Check the smooth scroll property
864 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
865 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
866 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
868 // Check the smooth scroll duration property
869 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
870 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
872 // Check the scroll bar property
873 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
874 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
875 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
877 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
878 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
879 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
880 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
882 // Check the pixel size of font
883 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
884 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
886 // Check placeholder text properties.
887 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
888 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
890 // Check placeholder text's color property.
891 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
892 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
894 // Check the enable selection property
895 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
896 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
898 // Check the placeholder property with pixel size
899 Property::Map placeholderPixelSizeMapSet;
900 Property::Map placeholderPixelSizeMapGet;
901 Property::Map placeholderFontstyleMap;
902 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
903 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
904 placeholderPixelSizeMapSet["color"] = Color::BLUE;
905 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
906 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
908 placeholderFontstyleMap.Insert( "weight", "bold" );
909 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
910 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
912 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
913 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
915 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
916 Property::Map placeholderConversionMap;
917 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
918 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
919 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
920 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
921 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
924 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
926 // Check the placeholder property with point size
927 Property::Map placeholderMapSet;
928 Property::Map placeholderMapGet;
929 placeholderMapSet["text"] = "Setting Placeholder Text";
930 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
931 placeholderMapSet["color"] = Color::RED;
932 placeholderMapSet["fontFamily"] = "Arial";
933 placeholderMapSet["pointSize"] = 12.0f;
934 // Check the placeholder font style property
935 placeholderFontstyleMap.Clear();
937 placeholderFontstyleMap.Insert( "weight", "bold" );
938 placeholderFontstyleMap.Insert( "width", "condensed" );
939 placeholderFontstyleMap.Insert( "slant", "italic" );
940 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
941 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
943 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
944 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
946 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
947 placeholderConversionMap.Clear();
948 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
949 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
950 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
951 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
952 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
953 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
954 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
957 placeholderFontstyleMap.Clear();
958 placeholderFontstyleMap.Insert( "weight", "normal" );
959 placeholderFontstyleMap.Insert( "slant", "oblique" );
960 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
961 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
963 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
964 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
965 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
966 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
968 placeholderFontstyleMap.Clear();
969 placeholderFontstyleMap.Insert( "slant", "roman" );
970 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
971 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
973 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
975 placeholderFontstyleMap.Clear();
976 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
978 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
979 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
980 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
981 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
982 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
984 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
985 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
987 // Check handle color
988 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
989 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
991 // Test the ENABLE_GRAB_HANDLE_POPUP property
992 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
993 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
995 // Check the input method setting
996 Property::Map propertyMap;
997 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
998 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
999 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
1000 int inputVariation = 1;
1001 propertyMap["PANEL_LAYOUT"] = panelLayout;
1002 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
1003 propertyMap["BUTTON_ACTION"] = buttonAction;
1004 propertyMap["VARIATION"] = inputVariation;
1005 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
1007 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
1009 DALI_TEST_CHECK( value.Get( map ) );
1012 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
1013 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
1016 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
1017 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
1020 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
1021 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
1024 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
1025 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1027 // Check the input filter property
1028 Property::Map inputFilterMapSet;
1029 Property::Map inputFilterMapGet;
1030 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1031 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1033 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1035 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1036 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1039 inputFilterMapSet.Clear();
1040 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1042 application.SendNotification();
1043 application.Render();
1045 // Check the line size property
1046 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1047 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1048 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1053 // Positive Atlas Text Renderer test
1054 int utcDaliTextEditorAtlasRenderP(void)
1056 ToolkitTestApplication application;
1057 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1058 StyleManager styleManager = StyleManager::Get();
1059 styleManager.ApplyDefaultTheme();
1060 TextEditor editor = TextEditor::New();
1061 DALI_TEST_CHECK( editor );
1063 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1065 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1067 application.GetScene().Add( editor );
1071 // Render some text with the shared atlas backend
1072 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1073 application.SendNotification();
1074 application.Render();
1078 tet_result(TET_FAIL);
1083 // Positive test for the anchorClicked signal.
1084 int utcDaliTextEditorAnchorClickedP(void)
1086 ToolkitTestApplication application;
1087 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1088 TextEditor editor = TextEditor::New();
1089 DALI_TEST_CHECK(editor);
1091 application.GetScene().Add(editor);
1093 // connect to the anchor clicked signal.
1094 ConnectionTracker* testTracker = new ConnectionTracker();
1095 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1096 bool anchorClickedSignal = false;
1097 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1099 gAnchorClickedCallBackCalled = false;
1100 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1101 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1102 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1103 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1104 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1106 application.SendNotification();
1107 application.Render();
1108 editor.SetKeyInputFocus();
1110 // Create a tap event to touch the text editor.
1111 TestGenerateTap(application, 5.0f, 5.0f);
1112 application.SendNotification();
1113 application.Render();
1115 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1116 DALI_TEST_CHECK(anchorClickedSignal);
1118 gAnchorClickedCallBackNotCalled = true;
1119 // Tap the outside of anchor, callback should not be called.
1120 TestGenerateTap(application, 150.f, 100.f);
1121 application.SendNotification();
1122 application.Render();
1124 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1129 // Positive test for the textChanged signal.
1130 int utcDaliTextEditorTextChangedP(void)
1132 ToolkitTestApplication application;
1133 tet_infoline(" utcDaliTextEditorTextChangedP");
1134 TextEditor editor = TextEditor::New();
1135 DALI_TEST_CHECK( editor );
1137 application.GetScene().Add( editor );
1139 // connect to the text changed signal.
1140 ConnectionTracker* testTracker = new ConnectionTracker();
1141 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1142 bool textChangedSignal = false;
1143 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1145 gTextChangedCallBackCalled = false;
1146 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1147 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1148 DALI_TEST_CHECK( textChangedSignal );
1150 application.SendNotification();
1151 editor.SetKeyInputFocus();
1153 gTextChangedCallBackCalled = false;
1154 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1155 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1158 editor.SetProperty( TextField::Property::TEXT, "" );
1160 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1161 gTextChangedCallBackCalled = false;
1162 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1163 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1165 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1166 gTextChangedCallBackCalled = false;
1167 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1168 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1173 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1175 ToolkitTestApplication application;
1176 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1177 TextEditor editor = TextEditor::New();
1178 DALI_TEST_CHECK( editor );
1181 application.GetScene().Add( editor );
1183 // connect to the text changed signal.
1184 ConnectionTracker* testTracker = new ConnectionTracker();
1185 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1186 bool textChangedSignal = false;
1187 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1190 // get InputMethodContext
1192 InputMethodContext::EventData imfEvent;
1193 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1195 editor.SetKeyInputFocus();
1196 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1199 gTextChangedCallBackCalled = false;
1200 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1201 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1202 application.SendNotification();
1203 application.Render();
1204 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1205 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1207 gTextChangedCallBackCalled = false;
1208 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1209 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1210 application.SendNotification();
1211 application.Render();
1212 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1213 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1215 gTextChangedCallBackCalled = false;
1216 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1217 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1218 application.SendNotification();
1219 application.Render();
1220 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1221 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1223 gTextChangedCallBackCalled = false;
1224 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1225 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1226 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1228 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1229 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1230 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1232 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1233 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1234 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1236 application.SendNotification();
1237 application.Render();
1238 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1239 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1245 int utcDaliTextEditorInputStyleChanged01(void)
1247 // The text-editor emits signals when the input style changes. These changes of style are
1248 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1249 // can't be emitted during the size negotiation as the callbacks may update the UI.
1250 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1251 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1252 ToolkitTestApplication application;
1253 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1257 char* pathNamePtr = get_current_dir_name();
1258 const std::string pathName( pathNamePtr );
1259 free( pathNamePtr );
1261 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1262 fontClient.SetDpi( 93u, 93u );
1264 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1265 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1267 TextEditor editor = TextEditor::New();
1268 DALI_TEST_CHECK( editor );
1271 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1272 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1273 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1275 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1276 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1278 // connect to the text changed signal.
1279 ConnectionTracker* testTracker = new ConnectionTracker();
1280 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1281 bool inputStyleChangedSignal = false;
1282 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1284 application.GetScene().Add( editor );
1286 // Render and notify
1287 application.SendNotification();
1288 application.Render();
1290 // Executes the idle callbacks added by the text control on the change of input style.
1291 application.RunIdles();
1293 gInputStyleChangedCallbackCalled = false;
1294 gInputStyleMask = TextEditor::InputStyle::NONE;
1295 inputStyleChangedSignal = false;
1297 // Create a tap event to touch the text editor.
1298 TestGenerateTap( application, 18.0f, 25.0f );
1300 // Render and notify
1301 application.SendNotification();
1302 application.Render();
1304 // Executes the idle callbacks added by the text control on the change of input style.
1305 application.RunIdles();
1307 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1308 if( gInputStyleChangedCallbackCalled )
1310 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1312 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1313 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1315 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1316 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1318 DALI_TEST_CHECK( inputStyleChangedSignal );
1320 gInputStyleChangedCallbackCalled = false;
1321 gInputStyleMask = TextEditor::InputStyle::NONE;
1322 inputStyleChangedSignal = false;
1324 // Create a tap event to touch the text editor.
1325 TestGenerateTap( application, 30.0f, 25.0f );
1327 // Render and notify
1328 application.SendNotification();
1329 application.Render();
1331 // Executes the idle callbacks added by the text control on the change of input style.
1332 application.RunIdles();
1334 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1335 DALI_TEST_CHECK( !inputStyleChangedSignal );
1337 gInputStyleChangedCallbackCalled = false;
1338 gInputStyleMask = TextEditor::InputStyle::NONE;
1339 inputStyleChangedSignal = false;
1341 // Create a tap event to touch the text editor.
1342 TestGenerateTap( application, 43.0f, 25.0f );
1344 // Render and notify
1345 application.SendNotification();
1346 application.Render();
1348 // Executes the idle callbacks added by the text control on the change of input style.
1349 application.RunIdles();
1351 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1352 if( gInputStyleChangedCallbackCalled )
1354 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1356 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1357 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1359 DALI_TEST_CHECK( inputStyleChangedSignal );
1361 gInputStyleChangedCallbackCalled = false;
1362 gInputStyleMask = TextEditor::InputStyle::NONE;
1363 inputStyleChangedSignal = false;
1365 // Create a tap event to touch the text editor.
1366 TestGenerateTap( application, 88.0f, 25.0f );
1368 // Render and notify
1369 application.SendNotification();
1370 application.Render();
1372 // Executes the idle callbacks added by the text control on the change of input style.
1373 application.RunIdles();
1375 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1376 if( gInputStyleChangedCallbackCalled )
1378 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1380 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1381 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1383 Property::Map fontStyleMapSet;
1384 Property::Map fontStyleMapGet;
1386 fontStyleMapSet.Insert( "weight", "bold" );
1388 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1389 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1390 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1392 DALI_TEST_CHECK( inputStyleChangedSignal );
1394 gInputStyleChangedCallbackCalled = false;
1395 gInputStyleMask = TextEditor::InputStyle::NONE;
1396 inputStyleChangedSignal = false;
1398 // Create a tap event to touch the text editor.
1399 TestGenerateTap( application, 115.0f, 25.0f );
1401 // Render and notify
1402 application.SendNotification();
1403 application.Render();
1405 // Executes the idle callbacks added by the text control on the change of input style.
1406 application.RunIdles();
1408 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1409 DALI_TEST_CHECK( !inputStyleChangedSignal );
1411 gInputStyleChangedCallbackCalled = false;
1412 gInputStyleMask = TextEditor::InputStyle::NONE;
1413 inputStyleChangedSignal = false;
1415 // Create a tap event to touch the text editor.
1416 TestGenerateTap( application, 164.0f, 25.0f );
1418 // Render and notify
1419 application.SendNotification();
1420 application.Render();
1422 // Executes the idle callbacks added by the text control on the change of input style.
1423 application.RunIdles();
1425 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1426 if( gInputStyleChangedCallbackCalled )
1428 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1430 Property::Map fontStyleMapSet;
1431 Property::Map fontStyleMapGet;
1433 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1434 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1435 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1437 DALI_TEST_CHECK( inputStyleChangedSignal );
1439 gInputStyleChangedCallbackCalled = false;
1440 gInputStyleMask = TextEditor::InputStyle::NONE;
1441 inputStyleChangedSignal = false;
1443 // Create a tap event to touch the text editor.
1444 TestGenerateTap( application, 191.0f, 25.0f );
1446 // Render and notify
1447 application.SendNotification();
1448 application.Render();
1450 // Executes the idle callbacks added by the text control on the change of input style.
1451 application.RunIdles();
1453 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1454 DALI_TEST_CHECK( !inputStyleChangedSignal );
1459 int utcDaliTextEditorInputStyleChanged02(void)
1461 // The text-editor emits signals when the input style changes. These changes of style are
1462 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1463 // can't be emitted during the size negotiation as the callbacks may update the UI.
1464 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1465 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1466 ToolkitTestApplication application;
1467 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1471 char* pathNamePtr = get_current_dir_name();
1472 const std::string pathName( pathNamePtr );
1473 free( pathNamePtr );
1475 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1476 fontClient.SetDpi( 93u, 93u );
1478 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1479 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1481 TextEditor editor = TextEditor::New();
1482 DALI_TEST_CHECK( editor );
1485 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1486 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1487 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1489 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1490 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>" );
1492 // connect to the text changed signal.
1493 ConnectionTracker* testTracker = new ConnectionTracker();
1494 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1495 bool inputStyleChangedSignal = false;
1496 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1498 application.GetScene().Add( editor );
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 gInputStyleChangedCallbackCalled = false;
1508 gInputStyleMask = TextEditor::InputStyle::NONE;
1509 inputStyleChangedSignal = false;
1511 // Create a tap event to touch the text editor.
1512 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1513 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1515 // Render and notify
1516 application.SendNotification();
1517 application.Render();
1519 // Executes the idle callbacks added by the text control on the change of input style.
1520 application.RunIdles();
1522 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1523 if( gInputStyleChangedCallbackCalled )
1525 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1526 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1527 TextEditor::InputStyle::POINT_SIZE |
1528 TextEditor::InputStyle::COLOR ),
1531 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1532 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1534 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1535 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1537 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1538 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1540 DALI_TEST_CHECK( inputStyleChangedSignal );
1542 gInputStyleChangedCallbackCalled = false;
1543 gInputStyleMask = TextEditor::InputStyle::NONE;
1544 inputStyleChangedSignal = false;
1546 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1552 // Executes the idle callbacks added by the text control on the change of input style.
1553 application.RunIdles();
1555 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1556 if( gInputStyleChangedCallbackCalled )
1558 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1559 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1562 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1563 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1565 DALI_TEST_CHECK( inputStyleChangedSignal );
1567 gInputStyleChangedCallbackCalled = false;
1568 gInputStyleMask = TextEditor::InputStyle::NONE;
1569 inputStyleChangedSignal = false;
1571 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1573 // Render and notify
1574 application.SendNotification();
1575 application.Render();
1577 // Executes the idle callbacks added by the text control on the change of input style.
1578 application.RunIdles();
1580 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1581 DALI_TEST_CHECK( !inputStyleChangedSignal );
1583 gInputStyleChangedCallbackCalled = false;
1584 gInputStyleMask = TextEditor::InputStyle::NONE;
1585 inputStyleChangedSignal = false;
1587 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1589 // Render and notify
1590 application.SendNotification();
1591 application.Render();
1593 // Executes the idle callbacks added by the text control on the change of input style.
1594 application.RunIdles();
1596 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1597 if( gInputStyleChangedCallbackCalled )
1599 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1600 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1603 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1604 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1606 DALI_TEST_CHECK( inputStyleChangedSignal );
1608 gInputStyleChangedCallbackCalled = false;
1609 gInputStyleMask = TextEditor::InputStyle::NONE;
1610 inputStyleChangedSignal = false;
1612 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1614 Property::Map fontStyleMapSet;
1615 fontStyleMapSet.Insert( "weight", "thin" );
1616 fontStyleMapSet.Insert( "width", "condensed" );
1617 fontStyleMapSet.Insert( "slant", "italic" );
1619 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1620 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1621 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1623 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1624 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1625 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1626 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1628 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 // Executes the idle callbacks added by the text control on the change of input style.
1635 application.RunIdles();
1637 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1638 DALI_TEST_CHECK( !inputStyleChangedSignal );
1640 // Create a tap event to touch the text editor.
1641 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Executes the idle callbacks added by the text control on the change of input style.
1648 application.RunIdles();
1650 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1651 if( gInputStyleChangedCallbackCalled )
1653 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1654 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1655 TextEditor::InputStyle::POINT_SIZE |
1656 TextEditor::InputStyle::FONT_STYLE |
1657 TextEditor::InputStyle::LINE_SPACING |
1658 TextEditor::InputStyle::UNDERLINE |
1659 TextEditor::InputStyle::SHADOW |
1660 TextEditor::InputStyle::EMBOSS |
1661 TextEditor::InputStyle::OUTLINE ),
1664 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1665 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1667 DALI_TEST_CHECK( inputStyleChangedSignal );
1669 gInputStyleChangedCallbackCalled = false;
1670 gInputStyleMask = TextEditor::InputStyle::NONE;
1671 inputStyleChangedSignal = false;
1673 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1675 fontStyleMapSet.Clear();
1676 fontStyleMapSet.Insert( "weight", "black" );
1677 fontStyleMapSet.Insert( "width", "expanded" );
1678 fontStyleMapSet.Insert( "slant", "oblique" );
1680 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1682 // Create a tap event to touch the text editor.
1683 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1685 // Render and notify
1686 application.SendNotification();
1687 application.Render();
1689 // Executes the idle callbacks added by the text control on the change of input style.
1690 application.RunIdles();
1692 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1693 if( gInputStyleChangedCallbackCalled )
1695 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1696 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1697 TextEditor::InputStyle::POINT_SIZE |
1698 TextEditor::InputStyle::FONT_STYLE ),
1701 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1702 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1704 DALI_TEST_CHECK( inputStyleChangedSignal );
1709 int utcDaliTextEditorEvent01(void)
1711 ToolkitTestApplication application;
1712 tet_infoline(" utcDaliTextEditorEvent01");
1714 // Creates a tap event. After creating a tap event the text editor should
1715 // have the focus and add text with key events should be possible.
1717 TextEditor editor = TextEditor::New();
1718 DALI_TEST_CHECK( editor );
1720 application.GetScene().Add( editor );
1722 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1723 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1724 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1726 // Avoid a crash when core load gl resources.
1727 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1729 // Render and notify
1730 application.SendNotification();
1731 application.Render();
1733 // Add a key event but as the text editor has not the focus it should do nothing.
1734 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736 // Render and notify
1737 application.SendNotification();
1738 application.Render();
1740 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1742 // Create a tap event to touch the text editor.
1743 TestGenerateTap( application, 150.0f, 25.0f );
1745 // Render and notify
1746 application.SendNotification();
1747 application.Render();
1749 // Now the text editor has the focus, so it can handle the key events.
1750 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1751 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1753 // Render and notify
1754 application.SendNotification();
1755 application.Render();
1757 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1759 // Create a second text editor and send key events to it.
1760 TextEditor editor2 = TextEditor::New();
1762 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1763 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1764 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1765 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1767 application.GetScene().Add( editor2 );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 // Create a tap event on the second text editor.
1774 TestGenerateTap( application, 150.0f, 125.0f );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1780 // The second text editor has the focus. It should handle the key events.
1781 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1782 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1788 // Check the text has been added to the second text editor.
1789 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1794 int utcDaliTextEditorEvent02(void)
1796 ToolkitTestApplication application;
1797 tet_infoline(" utcDaliTextEditorEvent02");
1799 // Checks if the right number of actors are created.
1801 TextEditor editor = TextEditor::New();
1802 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1803 DALI_TEST_CHECK( editor );
1805 application.GetScene().Add( editor );
1807 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1808 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1809 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1811 // Avoid a crash when core load gl resources.
1812 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 // Check there are the expected number of children (the stencil).
1819 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1821 Actor stencil = editor.GetChildAt( 0u );
1823 // Create a tap event to touch the text editor.
1824 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 Actor layer = editor.GetChildAt( 1u );
1831 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1832 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1834 // Now the text editor has the focus, so it can handle the key events.
1835 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1836 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1838 // Render and notify
1839 application.SendNotification();
1840 application.Render();
1842 // Checks the cursor and the renderer have been created.
1843 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1844 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1846 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1847 DALI_TEST_CHECK( cursor );
1849 // The stencil actor has a container with all the actors which contain the text renderers.
1850 Actor container = stencil.GetChildAt( 0u );
1851 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1853 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1854 DALI_TEST_CHECK( renderer );
1857 // Move the cursor and check the position changes.
1858 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1860 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1861 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1869 DALI_TEST_CHECK( position2.x < position1.x );
1871 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1872 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1874 // Render and notify
1875 application.SendNotification();
1876 application.Render();
1878 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1880 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1882 // Send some taps and check the cursor positions.
1884 // Try to tap at the beginning.
1885 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1887 // Render and notify
1888 application.SendNotification();
1889 application.Render();
1891 // Cursor position should be the same than position1.
1892 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1894 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1896 // Tap away from the start position.
1897 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1903 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1905 DALI_TEST_CHECK( position5.x > position4.x );
1907 // Remove all the text.
1908 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1909 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1910 editor.SetProperty( TextEditor::Property::TEXT, "" );
1912 // Render and notify
1913 application.SendNotification();
1914 application.Render();
1916 // Cursor position should be the same than position2.
1917 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1919 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1921 // Should not be a renderer.
1922 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1927 int utcDaliTextEditorEvent03(void)
1929 ToolkitTestApplication application;
1930 tet_infoline(" utcDaliTextEditorEvent03");
1932 // Checks if the highlight actor is created.
1934 TextEditor editor = TextEditor::New();
1935 DALI_TEST_CHECK( editor );
1937 application.GetScene().Add( editor );
1939 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1940 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1941 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1942 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1943 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1945 // Avoid a crash when core load gl resources.
1946 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Send some taps and check text controller with clipboard window
1953 Dali::Clipboard clipboard = Clipboard::Get();
1954 clipboard.ShowClipboard();
1955 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1956 clipboard.HideClipboard();
1958 // Render and notify
1959 application.SendNotification();
1960 application.Render();
1962 // Tap first to get the focus.
1963 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 // Double tap to select a word.
1970 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1972 // Render and notify
1973 application.SendNotification();
1974 application.Render();
1976 // The stencil actor should have two actors: the renderer and the highlight actor.
1977 Actor stencil = editor.GetChildAt( 0u );
1979 // Highlight needs to be drawn before text, so should come first in child order
1980 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1981 DALI_TEST_CHECK( highlight );
1983 // The stencil actor has a container with all the actors which contain the text renderers.
1984 Actor container = stencil.GetChildAt( 1u );
1985 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1987 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1988 DALI_TEST_CHECK( renderer );
1991 // Double tap out of bounds
1992 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1993 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1995 // Render and notify
1996 application.SendNotification();
1997 application.Render();
1999 // The stencil actor should have one actors: the renderer actor.
2000 stencil = editor.GetChildAt( 0u );
2002 // The stencil actor has a container with all the actors which contain the text renderers.
2003 container = stencil.GetChildAt( 0u );
2004 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2006 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2007 DALI_TEST_CHECK( renderer );
2011 TestGenerateLongPress(application, 1.0f, 25.0f);
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2018 TestGenerateMiniPan(application);
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2027 int utcDaliTextEditorEvent04(void)
2029 ToolkitTestApplication application;
2030 tet_infoline(" utcDaliTextEditorEvent04");
2032 // Checks if the highlight actor is created.
2034 TextEditor editor = TextEditor::New();
2035 DALI_TEST_CHECK( editor );
2037 application.GetScene().Add( editor );
2039 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2040 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2041 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2042 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2043 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2045 // Avoid a crash when core load gl resources.
2046 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 // Tap on the text editor
2053 TestGenerateTap( application, 3.0f, 25.0f );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 // Move at the end of the text.
2060 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2061 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2067 for( unsigned int index = 0u; index < 10u; ++index )
2069 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2078 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2086 // Add some key events
2087 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2088 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2090 // Render and notify
2091 application.SendNotification();
2092 application.Render();
2094 for( unsigned int index = 0u; index < 10u; ++index )
2096 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2097 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2105 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2111 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2116 int utcDaliTextEditorEvent05(void)
2118 ToolkitTestApplication application;
2119 tet_infoline(" utcDaliTextEditorEvent05");
2121 // Checks if the highlight actor is created.
2123 TextEditor editor = TextEditor::New();
2124 DALI_TEST_CHECK( editor );
2126 application.GetScene().Add( editor );
2128 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2129 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2130 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2131 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2132 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2133 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2134 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2135 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2136 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2137 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2139 // Avoid a crash when core load gl resources.
2140 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 // Tap on the text editor
2147 TestGenerateTap( application, 3.0f, 25.0f );
2149 // Render and notify
2150 application.SendNotification();
2151 application.Render();
2153 // Move at the end of the text.
2154 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2155 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 // Render and notify
2158 application.SendNotification();
2159 application.Render();
2161 for( unsigned int index = 0u; index < 10u; ++index )
2164 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2166 // Render and notify
2167 application.SendNotification();
2168 application.Render();
2170 // Modify duration after scroll is enabled
2171 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2173 // Continuous scroll left to increase coverage
2174 for( unsigned int index = 0u; index < 10u; ++index )
2176 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2178 // Render and notify
2179 application.SendNotification();
2180 application.Render();
2182 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2183 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2184 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2185 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2186 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2188 // Press Escape to increase coverage
2189 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.SendNotification();
2191 application.Render();
2193 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2198 int utcDaliTextEditorEvent06(void)
2200 ToolkitTestApplication application;
2201 tet_infoline(" utcDaliTextEditorEvent06");
2203 // Checks if the highlight actor is created.
2205 TextEditor editor = TextEditor::New();
2206 DALI_TEST_CHECK( editor );
2208 application.GetScene().Add( editor );
2210 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2211 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2212 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2213 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2214 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2216 // Avoid a crash when core load gl resources.
2217 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 // Tap on the text editor
2224 TestGenerateTap( application, 3.0f, 25.0f );
2226 // Render and notify
2227 application.SendNotification();
2228 application.Render();
2230 // Move to seconds line of the text.
2231 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2233 // Render and notify
2234 application.SendNotification();
2235 application.Render();
2237 float layoutHeight = editor.GetHeightForWidth( 100.f );
2240 // Add another script characters ( glyph height is defferent )
2241 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2244 // Delete characters
2245 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2248 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2250 // Render and notify
2251 application.SendNotification();
2252 application.Render();
2254 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2257 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2258 application.SendNotification();
2259 application.Render();
2261 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 application.SendNotification();
2263 application.Render();
2265 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2266 application.SendNotification();
2267 application.Render();
2269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.SendNotification();
2271 application.Render();
2273 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2274 application.SendNotification();
2275 application.Render();
2277 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 application.SendNotification();
2279 application.Render();
2281 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 application.SendNotification();
2283 application.Render();
2288 int utcDaliTextEditorEvent07(void)
2290 ToolkitTestApplication application;
2291 tet_infoline(" utcDaliTextEditorEvent07");
2293 // Checks if the highlight actor is created.
2295 TextEditor editor = TextEditor::New();
2296 DALI_TEST_CHECK( editor );
2298 application.GetScene().Add( editor );
2300 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2301 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2302 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2303 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2304 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2306 // Avoid a crash when core load gl resources.
2307 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2309 // Render and notify
2310 application.SendNotification();
2311 application.Render();
2313 // Tap on the text editor
2314 TestGenerateTap( application, 3.0f, 25.0f );
2316 // Render and notify
2317 application.SendNotification();
2318 application.Render();
2320 // Move to second line of the text.
2321 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 // Select some text in the right of the current cursor position
2328 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2330 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2331 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2337 // Cut the selected text
2338 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2339 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 ) );
2341 // Render and notify
2342 application.SendNotification();
2343 application.Render();
2345 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2347 // Select some text in the left of the current cursor position
2348 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2349 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2351 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 // Render and notify
2354 application.SendNotification();
2355 application.Render();
2357 // Copy the selected text
2358 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2359 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 ) );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2365 // Move the cursor to the third line
2366 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 // Render and notify
2370 application.SendNotification();
2371 application.Render();
2373 // Paste the selected text at the current cursor position
2374 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 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 ) );
2377 // Render and notify
2378 application.SendNotification();
2379 application.Render();
2381 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2384 // Disable Shift Selection
2385 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2387 // Test to select some text in the right of the current cursor position
2388 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Cut the selected text
2398 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2399 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 ) );
2401 // Render and notify
2402 application.SendNotification();
2403 application.Render();
2405 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2406 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2408 // Test to select some text in the left of the current cursor position
2409 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2410 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2411 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2412 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 // Render and notify
2415 application.SendNotification();
2416 application.Render();
2418 // Copy the selected text
2419 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2420 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 ) );
2422 // Render and notify
2423 application.SendNotification();
2424 application.Render();
2426 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2427 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2430 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 ) );
2432 // Render and notify
2433 application.SendNotification();
2434 application.Render();
2436 // replace text with "c"
2437 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2439 // Render and notify
2440 application.SendNotification();
2441 application.Render();
2444 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2447 DevelTextEditor::SelectWholeText(editor);
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 // Copy the selected text 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( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457 // Render and notify
2458 application.SendNotification();
2459 application.Render();
2462 DevelTextEditor::SelectNone(editor);
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2468 // Paste the selected 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( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2473 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2475 // select all using logical keys
2476 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2477 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2479 // Render and notify
2480 application.SendNotification();
2481 application.Render();
2483 // cut text using logical keys
2484 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2485 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2487 // Render and notify
2488 application.SendNotification();
2489 application.Render();
2492 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2497 int utcDaliTextEditorEvent08(void)
2499 ToolkitTestApplication application;
2500 tet_infoline(" utcDaliTextEditorEvent08");
2502 // Checks if the highlight actor is released correctly.
2504 TextEditor editor = TextEditor::New();
2505 DALI_TEST_CHECK( editor );
2507 application.GetScene().Add( editor );
2509 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2510 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2511 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2512 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2513 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2515 // Avoid a crash when core load gl resources.
2516 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2518 // Render and notify
2519 application.SendNotification();
2520 application.Render();
2522 // Tap on the text editor
2523 TestGenerateTap( application, 3.0f, 25.0f );
2525 // Render and notify
2526 application.SendNotification();
2527 application.Render();
2529 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2530 // Test to select some text in the left of the current cursor position
2531 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2532 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2533 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2534 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2536 // Render and notify
2537 application.SendNotification();
2538 application.Render();
2540 // Test to the left selection handle position and the right selection handle position
2541 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2542 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2543 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2544 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546 // Render and notify
2547 application.SendNotification();
2548 application.Render();
2550 // Test to select full text in the left of the current cursor position
2551 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2552 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2554 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2555 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2556 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2558 // Render and notify
2559 application.SendNotification();
2560 application.Render();
2562 // Test to release the current full text selection
2563 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2564 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2566 // Render and notify
2567 application.SendNotification();
2568 application.Render();
2570 // Test to move the current cursor position correctly
2571 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2573 // Render and notify
2574 application.SendNotification();
2575 application.Render();
2578 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2580 // Render and notify
2581 application.SendNotification();
2582 application.Render();
2584 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2586 // Test to select some text in the right of the current cursor position
2587 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2588 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2589 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2591 // Render and notify
2592 application.SendNotification();
2593 application.Render();
2595 // Test the cursor position with right arrow key
2596 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2598 // Render and notify
2599 application.SendNotification();
2600 application.Render();
2603 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2605 // Render and notify
2606 application.SendNotification();
2607 application.Render();
2609 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2611 // Test to select some text in the left of the current cursor position
2612 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2613 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2614 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2615 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2616 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2618 // Render and notify
2619 application.SendNotification();
2620 application.Render();
2622 // Test the cursor position with left arrow key
2623 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2625 // Render and notify
2626 application.SendNotification();
2627 application.Render();
2630 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2632 // Render and notify
2633 application.SendNotification();
2634 application.Render();
2636 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2638 // Test to select some text in the right of the current cursor position
2639 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2640 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2641 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2642 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2644 // Render and notify
2645 application.SendNotification();
2646 application.Render();
2648 // Test the cursor position with left arrow key
2649 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2651 // Render and notify
2652 application.SendNotification();
2653 application.Render();
2656 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2658 // Render and notify
2659 application.SendNotification();
2660 application.Render();
2662 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2664 // Test to select some text in the left of the current cursor position
2665 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2666 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2667 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2668 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2670 // Render and notify
2671 application.SendNotification();
2672 application.Render();
2674 // Test the cursor position with right arrow key
2675 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2677 // Render and notify
2678 application.SendNotification();
2679 application.Render();
2682 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2684 // Render and notify
2685 application.SendNotification();
2686 application.Render();
2688 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2693 int utcDaliTextEditorHandles(void)
2695 ToolkitTestApplication application;
2696 tet_infoline(" utcDaliTextEditorHandles");
2698 TextEditor editor = TextEditor::New();
2699 DALI_TEST_CHECK( editor );
2701 application.GetScene().Add( editor );
2703 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2704 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2705 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2706 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2708 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2709 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2710 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2711 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2713 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2714 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2715 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2717 // Avoid a crash when core load gl resources.
2718 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 // Tap first to get the focus.
2725 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2727 // Render and notify
2728 application.SendNotification();
2729 application.Render();
2731 // Tap to create the grab handle.
2732 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2734 // Render and notify
2735 application.SendNotification();
2736 application.Render();
2738 // Get the active layer where the text's decoration is added.
2739 Actor activeLayer = editor.GetChildAt( 1u );
2741 // Get the handle's actor.
2742 Actor handle = activeLayer.GetChildAt( 1u );
2743 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2745 // Render and notify
2746 application.SendNotification();
2747 application.Render();
2749 // Touch the grab handle to set it as pressed.
2750 Vector2 touchPos( 10.0f, 50.0f );
2751 Dali::Integration::TouchEvent event;
2752 event = Dali::Integration::TouchEvent();
2753 event.AddPoint( GetPointDownInside( touchPos ) );
2754 application.ProcessEvent( event );
2756 // Render and notify
2757 application.SendNotification();
2758 application.Render();
2760 // Pan the grab handle
2761 uint32_t time = 100;
2762 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2763 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2764 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2765 application.SendNotification();
2766 application.Render();
2769 // Release the grab handle.
2770 event = Dali::Integration::TouchEvent();
2771 event.AddPoint( GetPointUpInside( touchPos ) );
2772 application.ProcessEvent( event );
2774 // Render and notify
2775 application.SendNotification();
2776 application.Render();
2778 // Tap first to get the focus.
2779 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2781 // Render and notify
2782 application.SendNotification();
2783 application.Render();
2785 // Double tap to select a word and create the selection handles.
2786 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2788 // Render and notify
2789 application.SendNotification();
2790 application.Render();
2792 touchPos = Vector2( 10.0f, 50.0f );
2794 // Touch the left selection handle to set it as pressed.
2795 event = Dali::Integration::TouchEvent();
2796 event.AddPoint( GetPointDownInside( touchPos ) );
2797 application.ProcessEvent( event );
2799 // Render and notify
2800 application.SendNotification();
2801 application.Render();
2803 // Release the left selection handle.
2804 event = Dali::Integration::TouchEvent();
2805 event.AddPoint( GetPointUpInside( touchPos ) );
2806 application.ProcessEvent( event );
2808 // Render and notify
2809 application.SendNotification();
2810 application.Render();
2815 int utcDaliTextEditorUnderPropertyStringP(void)
2817 ToolkitTestApplication application;
2818 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2819 TextEditor editor = TextEditor::New();
2820 DALI_TEST_CHECK( editor );
2822 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2824 application.GetScene().Add( editor );
2826 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2827 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2829 tet_infoline("Set underline settings with a map");
2830 // Check the input underline property
2831 Property::Map underlineMapSet;
2832 Property::Map underlineMapGet;
2833 underlineMapSet.Insert( "enable", true );
2834 underlineMapSet.Insert( "color", Color::BLUE );
2835 underlineMapSet.Insert( "height", 2 );
2837 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2838 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2839 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2840 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2842 tet_infoline("Set underline settings with a string");
2843 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2844 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2847 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2849 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2850 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2851 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2852 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2854 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2859 int utcDaliTextEditorShadowPropertyStringP(void)
2861 ToolkitTestApplication application;
2862 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2864 TextEditor editor = TextEditor::New();
2866 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2868 application.GetScene().Add( editor );
2870 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2872 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2876 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2881 int utcDaliTextEditorFontStylePropertyStringP(void)
2883 ToolkitTestApplication application;
2884 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2886 TextEditor editor = TextEditor::New();
2888 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2890 application.GetScene().Add( editor );
2892 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2894 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2898 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2903 int utcDaliTextEditorGetPropertyLinecountP(void)
2905 ToolkitTestApplication application;
2907 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2911 TextEditor editor = TextEditor::New();
2912 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2913 editor.SetProperty( TextEditor::Property::TEXT,
2914 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2916 application.GetScene().Add( editor );
2918 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2919 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2920 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2922 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2923 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2924 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2929 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2932 ToolkitTestApplication application;
2933 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2935 TextEditor editor = TextEditor::New();
2936 DALI_TEST_CHECK( editor );
2938 application.GetScene().Add( editor );
2940 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2941 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2942 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2943 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2944 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2945 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2947 bool startedCalled = false;
2948 bool finishedCalled = false;
2950 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2951 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2953 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2955 // Render and notify
2956 application.SendNotification();
2957 application.Render();
2959 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2960 application.SendNotification();
2961 application.Render(6000);
2963 application.SendNotification();
2964 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2965 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2970 int UtcDaliToolkitTextEditorTextWrapMode(void)
2972 ToolkitTestApplication application;
2973 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2977 TextEditor editor = TextEditor::New();
2978 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2979 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2981 application.GetScene().Add( editor );
2983 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2984 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2986 application.SendNotification();
2987 application.Render();
2989 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2990 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2992 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2993 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2995 application.SendNotification();
2996 application.Render();
2998 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2999 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3001 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
3002 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
3004 application.SendNotification();
3005 application.Render();
3007 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3008 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
3010 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
3011 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
3013 application.SendNotification();
3014 application.Render();
3016 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3017 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3022 int UtcDaliTextEditorSetPaddingProperty(void)
3024 ToolkitTestApplication application;
3025 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3027 TextEditor editor = TextEditor::New();
3028 DALI_TEST_CHECK( editor );
3029 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3030 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3031 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3032 application.GetScene().Add( editor );
3034 application.SendNotification();
3035 application.Render();
3037 Vector3 originalSize = editor.GetNaturalSize();
3039 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3041 application.SendNotification();
3042 application.Render();
3044 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3046 Vector3 paddingAddedSize = editor.GetNaturalSize();
3048 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3050 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3055 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3057 ToolkitTestApplication application;
3058 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3060 TextEditor editor = TextEditor::New();
3061 DALI_TEST_CHECK( editor );
3062 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3063 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3064 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3065 application.GetScene().Add( editor );
3067 application.SendNotification();
3068 application.Render();
3070 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3071 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3073 // Check the enable shift selection property
3074 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3075 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3077 application.SendNotification();
3078 application.Render();
3083 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3085 ToolkitTestApplication application;
3086 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3088 TextEditor editor = TextEditor::New();
3089 DALI_TEST_CHECK( editor );
3090 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3091 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3092 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3093 application.GetScene().Add( editor );
3095 application.SendNotification();
3096 application.Render();
3098 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3099 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3101 // Check the enable grab handle property
3102 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3103 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3105 application.SendNotification();
3106 application.Render();
3111 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3113 ToolkitTestApplication application;
3114 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3116 TextEditor editor = TextEditor::New();
3117 DALI_TEST_CHECK( editor );
3118 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3119 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3120 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3121 application.GetScene().Add( editor );
3123 application.SendNotification();
3124 application.Render();
3126 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3127 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3129 // Check the disable match system language direction property
3130 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3131 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3133 application.SendNotification();
3134 application.Render();
3139 int UtcDaliTextEditorGetInputMethodContext(void)
3141 ToolkitTestApplication application;
3142 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3144 TextEditor editor = TextEditor::New();
3145 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3150 int utcDaliTextEditorMaxCharactersReached(void)
3152 ToolkitTestApplication application;
3153 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3155 TextEditor editor = TextEditor::New();
3156 DALI_TEST_CHECK( editor );
3158 application.GetScene().Add( editor );
3160 const int maxNumberOfCharacters = 1;
3161 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3162 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3164 editor.SetKeyInputFocus();
3166 // connect to the text changed signal.
3167 ConnectionTracker* testTracker = new ConnectionTracker();
3168 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3169 bool maxLengthReachedSignal = false;
3170 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3172 gMaxCharactersCallBackCalled = false;
3174 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3175 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3177 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3178 DALI_TEST_CHECK( maxLengthReachedSignal );
3183 int utcDaliTextEditorInputFiltered(void)
3185 ToolkitTestApplication application;
3186 tet_infoline(" utcDaliTextEditorInputFiltered");
3187 TextEditor editor = TextEditor::New();
3188 DALI_TEST_CHECK(editor);
3190 application.GetScene().Add(editor);
3192 Property::Map inputFilter;
3194 // Only digit is accepted.
3195 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3197 // Set input filter to TextEditor.
3198 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3200 editor.SetKeyInputFocus();
3202 // connect to the input filtered signal.
3203 ConnectionTracker* testTracker = new ConnectionTracker();
3204 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3205 bool inputFilteredSignal = false;
3206 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3208 gInputFilteredAcceptedCallbackCalled = false;
3210 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3212 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3213 DALI_TEST_CHECK(inputFilteredSignal);
3215 // Word is rejected.
3216 inputFilter[InputFilter::Property::ACCEPTED] = "";
3217 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3219 // Set input filter to TextEditor.
3220 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3222 editor.SetKeyInputFocus();
3224 inputFilteredSignal = false;
3225 gInputFilteredRejectedCallbackCalled = false;
3227 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3229 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3230 DALI_TEST_CHECK(inputFilteredSignal);
3235 int UtcDaliTextEditorSelectWholeText(void)
3237 ToolkitTestApplication application;
3238 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3240 TextEditor textEditor = TextEditor::New();
3242 application.GetScene().Add( textEditor );
3244 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3245 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3246 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3248 // Avoid a crash when core load gl resources.
3249 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3251 application.SendNotification();
3252 application.Render();
3254 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3256 DevelTextEditor::SelectWholeText( textEditor );
3258 application.SendNotification();
3259 application.Render();
3261 // Nothing should have been selected. The number of children is still 1
3262 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3264 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3266 application.SendNotification();
3267 application.Render();
3269 DevelTextEditor::SelectWholeText( textEditor );
3271 application.SendNotification();
3272 application.Render();
3274 // Should be 2 children, the stencil and the layer
3275 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3277 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3278 Actor stencil = textEditor.GetChildAt( 0u );
3280 // The highlight actor is drawn first, so is the first actor in the list
3281 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3282 DALI_TEST_CHECK( highlight );
3287 int UtcDaliTextEditorSelectText(void)
3289 ToolkitTestApplication application;
3290 tet_infoline(" UtcDaliTextEditorSelectText ");
3292 TextEditor textEditor = TextEditor::New();
3294 application.GetScene().Add( textEditor );
3296 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3297 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3298 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3300 // Avoid a crash when core load gl resources.
3301 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3303 application.SendNotification();
3304 application.Render();
3306 DevelTextEditor::SelectText( textEditor ,0, 5 );
3308 application.SendNotification();
3309 application.Render();
3311 // Nothing is selected
3312 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3313 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3315 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3317 application.SendNotification();
3318 application.Render();
3320 DevelTextEditor::SelectText( textEditor, 0, 5 );
3322 application.SendNotification();
3323 application.Render();
3325 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3326 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3328 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3329 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3331 // world is selected
3332 DevelTextEditor::SelectText( textEditor, 6, 11 );
3334 application.SendNotification();
3335 application.Render();
3337 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3338 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3340 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3341 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3346 int UtcDaliTextEditorSelectNone(void)
3348 ToolkitTestApplication application;
3349 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3351 TextEditor textEditor = TextEditor::New();
3353 application.GetScene().Add( textEditor );
3355 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3356 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3357 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3359 // Avoid a crash when core load gl resources.
3360 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3362 application.SendNotification();
3363 application.Render();
3365 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3367 application.SendNotification();
3368 application.Render();
3370 // Nothing is selected
3371 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3372 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3374 DevelTextEditor::SelectWholeText( textEditor );
3376 application.SendNotification();
3377 application.Render();
3379 // whole text is selected
3380 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3381 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3383 DevelTextEditor::SelectNone( textEditor );
3385 application.SendNotification();
3386 application.Render();
3388 // Nothing is selected
3389 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3390 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3395 int UtcDaliTextEditorSelectRange(void)
3397 ToolkitTestApplication application;
3398 tet_infoline("utcDaliTextEditorSelectRange");
3400 TextEditor textEditor = TextEditor::New();
3401 DALI_TEST_CHECK( textEditor );
3403 application.GetScene().Add( textEditor );
3405 // Avoid a crash when core load gl resources.
3406 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3408 application.SendNotification();
3409 application.Render();
3411 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3413 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3414 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3416 // Hello is selected
3417 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3418 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3420 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3421 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3426 int UtcDaliTextEditorEnableEditing(void)
3428 ToolkitTestApplication application;
3429 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3431 TextEditor textEditor = TextEditor::New();
3433 application.GetScene().Add( textEditor );
3435 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3436 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3437 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3439 // Avoid a crash when core load gl resources.
3440 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3442 application.SendNotification();
3443 application.Render();
3445 textEditor.SetKeyInputFocus();
3446 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3447 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3449 // Render and notify
3450 application.SendNotification();
3451 application.Render();
3453 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3454 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3456 textEditor.SetKeyInputFocus();
3457 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3458 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3460 // Render and notify
3461 application.SendNotification();
3462 application.Render();
3464 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3465 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3470 int UtcDaliTextEditorScrolling(void)
3472 ToolkitTestApplication application;
3473 tet_infoline(" UtcDaliTextEditorScrolling ");
3475 TextEditor textEditor = TextEditor::New();
3476 DALI_TEST_CHECK( textEditor );
3478 application.GetScene().Add( textEditor );
3480 // Avoid a crash when core load gl resources.
3481 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3483 application.SendNotification();
3484 application.Render();
3486 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3487 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3488 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3489 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3491 application.SendNotification();
3492 application.Render();
3494 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3495 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3498 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3500 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3501 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3503 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3505 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3506 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3508 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3509 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3511 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3512 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3517 int UtcDaliToolkitTextEditorFontSizeScale(void)
3519 ToolkitTestApplication application;
3520 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3522 TextEditor textEditor = TextEditor::New();
3523 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3524 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3525 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3527 TextEditor textEditorScaled = TextEditor::New();
3528 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3529 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3530 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3531 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3533 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3535 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3536 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3537 nonScaledSize = textEditor.GetNaturalSize();
3539 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3540 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3541 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3542 scaledSize = textEditorScaled.GetNaturalSize();
3544 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3549 int UtcDaliTextEditorPrimaryCursorPosition(void)
3551 ToolkitTestApplication application;
3552 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3554 TextEditor textEditor = TextEditor::New();
3556 application.GetScene().Add( textEditor );
3558 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3559 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3560 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3561 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3563 // Avoid a crash when core load gl resources.
3564 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3566 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3567 application.SendNotification();
3568 application.Render();
3569 textEditor.SetKeyInputFocus();
3571 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3573 // Render and notify
3574 application.SendNotification();
3575 application.Render();
3577 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3578 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3583 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3585 ToolkitTestApplication application;
3586 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3588 TextEditor textEditor = TextEditor::New();
3589 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3590 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3591 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3592 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3593 application.GetScene().Add( textEditor );
3595 application.SendNotification();
3596 application.Render();
3599 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3600 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3602 textEditor.GetNaturalSize();
3604 // Create a tap event to touch the text editor.
3605 TestGenerateTap( application, 18.0f, 25.0f );
3607 application.SendNotification();
3608 application.Render();
3610 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3611 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3617 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3619 ToolkitTestApplication application;
3621 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3623 int lineCountBefore =0 ;
3624 int lineCountAfter =0 ;
3626 // Create a text editor
3627 TextEditor textEditor = TextEditor::New();
3628 //Set very large font-size using point-size
3629 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3630 //Specify font-family
3631 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3633 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3634 //Set text longer than width of textEditor
3635 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3637 application.GetScene().Add( textEditor );
3639 application.SendNotification();
3640 application.Render();
3642 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3643 //GetHeightForWidth is a retrieval method which should not modify object
3644 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3645 textEditor.GetHeightForWidth(200.f);
3647 //This is to simulate focus into text editor after calling GetHeightForWidth
3648 //Create a tap event to touch the text editor.
3649 TestGenerateTap( application, 18.0f, 25.0f );
3651 application.SendNotification();
3652 application.Render();
3654 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3656 //The LineCount must not be changed when calling GetHeightForWidth.
3657 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3662 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3664 ToolkitTestApplication application;
3666 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3668 int lineCountBefore =0 ;
3669 int lineCountAfter =0 ;
3671 // Create a text editor
3672 TextEditor textEditor = TextEditor::New();
3673 //Set very large font-size using point-size
3674 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3675 //Specify font-family
3676 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3678 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3679 //Set text longer than width of textEditor
3680 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3681 //Set line wrap mode Character
3682 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3684 application.GetScene().Add( textEditor );
3686 application.SendNotification();
3687 application.Render();
3689 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3690 //GetHeightForWidth is a retrieval method which should not modify object
3691 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3692 textEditor.GetHeightForWidth(200.f);
3694 //This is to simulate focus into text editor after calling GetHeightForWidth
3695 //Create a tap event to touch the text editor.
3696 TestGenerateTap( application, 18.0f, 25.0f );
3698 application.SendNotification();
3699 application.Render();
3701 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3703 //The LineCount must not be changed when calling GetHeightForWidth.
3704 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3709 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3711 ToolkitTestApplication application;
3713 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3715 int lineCountBefore =0 ;
3716 int lineCountAfter =0 ;
3718 // Create a text editor
3719 TextEditor textEditor = TextEditor::New();
3720 //Set very large font-size using point-size
3721 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3722 //Specify font-family
3723 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3725 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3726 //Set text longer than width of textEditor
3727 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3728 //Set line wrap mode Character
3729 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3731 application.GetScene().Add( textEditor );
3733 application.SendNotification();
3734 application.Render();
3737 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3739 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3740 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3742 // When the text changed, the Line-count should be updated according to new text.
3743 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3744 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3745 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3752 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3754 ToolkitTestApplication application;
3756 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3758 int lineCountBefore =0 ;
3759 int lineCountAfter =0 ;
3761 // Create a text editor
3762 TextEditor textEditor = TextEditor::New();
3763 //Set very large font-size using point-size
3764 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3765 //Specify font-family
3766 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3768 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3769 //Set text longer than width of textEditor
3770 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3772 application.GetScene().Add( textEditor );
3774 application.SendNotification();
3775 application.Render();
3777 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3778 //GetNaturalSize is a retrieval method which should not modify object
3779 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3780 textEditor.GetNaturalSize();
3782 //This is to simulate focus into text editor after calling GetNaturalSize
3783 //Create a tap event to touch the text editor.
3784 TestGenerateTap( application, 18.0f, 25.0f );
3786 application.SendNotification();
3787 application.Render();
3789 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3791 //The LineCount must not be changed when calling GetNaturalSize.
3792 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3797 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3799 ToolkitTestApplication application;
3801 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3803 int lineCountBefore =0 ;
3804 int lineCountAfter =0 ;
3806 // Create a text editor
3807 TextEditor textEditor = TextEditor::New();
3808 //Set very large font-size using point-size
3809 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3810 //Specify font-family
3811 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3813 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3814 //Set text longer than width of textEditor
3815 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3816 //Set line wrap mode Character
3817 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3819 application.GetScene().Add( textEditor );
3821 application.SendNotification();
3822 application.Render();
3824 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3825 //GetNaturalSize is a retrieval method which should not modify object
3826 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3827 textEditor.GetNaturalSize( );
3829 //This is to simulate focus into text editor after calling GetNaturalSize
3830 //Create a tap event to touch the text editor.
3831 TestGenerateTap( application, 18.0f, 25.0f );
3833 application.SendNotification();
3834 application.Render();
3836 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3838 //The LineCount must not be changed when calling GetNaturalSize.
3839 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3844 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3846 ToolkitTestApplication application;
3847 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3849 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3850 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3851 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3853 // Create a text editor
3854 TextEditor textEditor = TextEditor::New();
3856 //Set size to avoid automatic eliding
3857 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3858 //Set very large font-size using point-size
3859 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3860 //Specify font-family
3861 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3862 //Set text to check if appear or not
3863 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3865 application.GetScene().Add( textEditor );
3867 application.SendNotification();
3868 application.Render();
3869 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3870 Vector3 naturalSize = textEditor.GetNaturalSize();
3872 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3873 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3878 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3880 ToolkitTestApplication application;
3881 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3883 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3884 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3885 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3887 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3888 // Create a text editor
3889 TextEditor textEditor = TextEditor::New();
3890 //Set size to avoid automatic eliding
3891 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3892 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3893 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3895 const int numberOfCases = 6;
3896 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3898 for (int index=0; index < numberOfCases; index++)
3900 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3901 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3902 application.GetScene().Add( textEditor );
3903 application.SendNotification();
3904 application.Render();
3905 naturalSize = textEditor.GetNaturalSize();
3906 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3907 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3914 int UtcDaliTextEditorHyphenWrapMode(void)
3916 ToolkitTestApplication application;
3917 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3920 TextEditor textEditor = TextEditor::New();
3922 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3924 application.GetScene().Add( textEditor );
3925 application.SendNotification();
3926 application.Render();
3928 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3929 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3930 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3932 application.SendNotification();
3933 application.Render();
3935 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3941 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3943 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3944 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3945 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3947 application.SendNotification();
3948 application.Render();
3950 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3957 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3962 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
3964 ToolkitTestApplication application;
3965 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
3966 TextEditor textEditor = TextEditor::New();
3968 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
3969 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3971 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
3972 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3973 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3975 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
3976 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3977 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3979 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
3980 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3981 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3983 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
3984 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
3985 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3987 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
3988 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
3989 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3991 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
3992 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
3993 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3995 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3996 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
3997 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3999 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
4000 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
4001 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4003 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
4004 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
4005 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4007 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
4008 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
4009 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4011 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4012 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
4013 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4015 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4016 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
4017 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4022 int UtcDaliTextEditorCopyText(void)
4024 ToolkitTestApplication application;
4025 tet_infoline(" UtcDaliTextEditorCopyText ");
4027 TextEditor textEditor = TextEditor::New();
4029 std::string selectedText = "";
4030 std::string copiedText = "";
4032 application.GetScene().Add( textEditor );
4034 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4035 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4036 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4038 // Avoid a crash when core load gl resources.
4039 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4041 application.SendNotification();
4042 application.Render();
4044 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4046 application.SendNotification();
4047 application.Render();
4049 // Hello is selected
4050 DevelTextEditor::SelectText( textEditor, 0, 5 );
4052 application.SendNotification();
4053 application.Render();
4055 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4056 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4058 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4059 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4062 copiedText = DevelTextEditor::CopyText( textEditor );
4063 DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4065 // world is selected
4066 DevelTextEditor::SelectText( textEditor, 6, 11 );
4068 application.SendNotification();
4069 application.Render();
4071 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4072 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4074 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4075 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4078 copiedText = DevelTextEditor::CopyText( textEditor );
4079 DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4081 // "lo wo" is selected
4082 DevelTextEditor::SelectText( textEditor, 3, 8 );
4084 application.SendNotification();
4085 application.Render();
4087 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4088 DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4090 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4091 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4093 // "lo wo" is copied
4094 copiedText = DevelTextEditor::CopyText( textEditor );
4095 DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4100 int UtcDaliTextEditorCutText(void)
4102 ToolkitTestApplication application;
4103 tet_infoline(" UtcDaliTextEditorCutText ");
4105 TextEditor textEditor = TextEditor::New();
4107 std::string selectedText = "";
4109 application.GetScene().Add( textEditor );
4111 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4112 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4113 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4115 // Avoid a crash when core load gl resources.
4116 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4118 application.SendNotification();
4119 application.Render();
4121 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
4123 application.SendNotification();
4124 application.Render();
4126 // Hello is selected
4127 DevelTextEditor::SelectText( textEditor, 0, 5 );
4129 application.SendNotification();
4130 application.Render();
4132 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4133 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4135 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4136 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4139 DALI_TEST_EQUALS( "Hello", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4141 application.SendNotification();
4142 application.Render();
4144 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4147 DevelTextEditor::SelectText( textEditor, 0, 2 );
4149 application.SendNotification();
4150 application.Render();
4152 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4153 DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4155 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4156 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4159 DALI_TEST_EQUALS( " w", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4161 application.SendNotification();
4162 application.Render();
4164 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4166 // Test Cut from the middle
4169 DevelTextEditor::SelectText( textEditor, 1, 3 );
4171 application.SendNotification();
4172 application.Render();
4174 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4175 DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4177 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4178 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4181 DALI_TEST_EQUALS( "rl", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4183 application.SendNotification();
4184 application.Render();
4186 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4188 // Test Cut from the end
4191 DevelTextEditor::SelectText( textEditor, 1, 2 );
4193 application.SendNotification();
4194 application.Render();
4196 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4197 DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4199 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4200 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4203 DALI_TEST_EQUALS( "d", DevelTextEditor::CutText( textEditor ), TEST_LOCATION );
4205 application.SendNotification();
4206 application.Render();
4208 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4213 int UtcDaliTextEditorPasteText(void)
4215 ToolkitTestApplication application;
4216 tet_infoline(" UtcDaliTextEditorPasteText ");
4218 TextEditor editor = TextEditor::New();
4219 DALI_TEST_CHECK( editor );
4221 application.GetScene().Add( editor );
4223 std::string cutText = "";
4224 std::string copiedText = "";
4226 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4227 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4228 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4229 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4230 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4232 // Avoid a crash when core load gl resources.
4233 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4235 // Render and notify
4236 application.SendNotification();
4237 application.Render();
4239 // Tap on the text editor
4240 TestGenerateTap( application, 3.0f, 25.0f );
4242 // Render and notify
4243 application.SendNotification();
4244 application.Render();
4246 // Move to second line of the text.
4247 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4249 // Render and notify
4250 application.SendNotification();
4251 application.Render();
4253 // Select some text in the right of the current cursor position
4254 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4255 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4256 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4257 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4259 // Render and notify
4260 application.SendNotification();
4261 application.Render();
4263 // Cut the selected text
4264 cutText = DevelTextEditor::CutText(editor);
4266 // Render and notify
4267 application.SendNotification();
4268 application.Render();
4270 DALI_TEST_EQUALS( "wor", cutText, TEST_LOCATION );
4271 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4273 // Select some text in the left of the current cursor position
4274 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4279 // Render and notify
4280 application.SendNotification();
4281 application.Render();
4283 // Copy the selected text
4284 copiedText = DevelTextEditor::CopyText(editor);
4286 // Render and notify
4287 application.SendNotification();
4288 application.Render();
4290 DALI_TEST_EQUALS( "lo\n", copiedText, TEST_LOCATION );
4291 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4294 // Move the cursor to the third line
4295 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4296 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4298 // Render and notify
4299 application.SendNotification();
4300 application.Render();
4302 // Paste the selected text at the current cursor position
4303 DevelTextEditor::PasteText(editor);
4305 // Render and notify
4306 application.SendNotification();
4307 application.Render();
4309 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
4313 int UtcDaliTextEditorLineSpacing(void)
4315 ToolkitTestApplication application;
4316 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4318 TextEditor textEditor = TextEditor::New();
4319 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4320 application.GetScene().Add( textEditor );
4321 application.SendNotification();
4322 application.Render();
4324 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4325 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4327 Vector3 sizeBefore = textEditor.GetNaturalSize();
4329 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4331 //add 20 for each line 20 * 3
4332 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4337 int UtcDaliTextEditorMinLineSize(void)
4339 ToolkitTestApplication application;
4340 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4342 TextEditor textEditor = TextEditor::New();
4343 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4344 application.GetScene().Add( textEditor );
4345 application.SendNotification();
4346 application.Render();
4348 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4349 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4351 Vector3 sizeBefore = textEditor.GetNaturalSize();
4353 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4355 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4358 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4363 int utcDaliTextEditorCursorPositionChangedSignal(void)
4365 ToolkitTestApplication application;
4366 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4368 TextEditor editor = TextEditor::New();
4369 DALI_TEST_CHECK( editor );
4371 application.GetScene().Add( editor );
4373 // connect to the selection changed signal.
4374 ConnectionTracker* testTracker = new ConnectionTracker();
4375 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4376 bool cursorPositionChangedSignal = false;
4377 editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4379 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4380 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4381 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4382 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4383 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4385 // Avoid a crash when core load gl resources.
4386 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4388 // Render and notify
4389 application.SendNotification();
4390 application.Render();
4392 editor.SetKeyInputFocus();
4394 // Tap on the text editor
4395 TestGenerateTap( application, 3.0f, 25.0f );
4397 // Render and notify
4398 application.SendNotification();
4399 application.Render();
4401 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4402 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4404 gCursorPositionChangedCallbackCalled = false;
4407 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4409 // Render and notify
4410 application.SendNotification();
4411 application.Render();
4413 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4414 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4416 gCursorPositionChangedCallbackCalled = false;
4419 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4421 // Render and notify
4422 application.SendNotification();
4423 application.Render();
4425 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4426 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4428 gCursorPositionChangedCallbackCalled = false;
4430 //delete one character
4431 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4433 // Render and notify
4434 application.SendNotification();
4435 application.Render();
4437 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4438 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4440 gCursorPositionChangedCallbackCalled = false;
4442 editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4444 // Render and notify
4445 application.SendNotification();
4446 application.Render();
4448 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4449 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4451 gCursorPositionChangedCallbackCalled = false;
4453 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4455 // Render and notify
4456 application.SendNotification();
4457 application.Render();
4459 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4460 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4465 int utcDaliTextEditorGeometryEllipsisStart(void)
4467 ToolkitTestApplication application;
4468 tet_infoline(" utcDaliTextEditorGeometryEllipsisStart");
4470 TextEditor editor = TextEditor::New();
4471 DALI_TEST_CHECK( editor );
4473 application.GetScene().Add( editor );
4475 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4476 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4477 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4478 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4479 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4480 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4481 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4482 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START );
4483 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4485 // Avoid a crash when core load gl resources.
4486 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4488 // Render and notify
4489 application.SendNotification();
4490 application.Render();
4492 unsigned int expectedCount = 2;
4493 unsigned int startIndex = 0;
4494 unsigned int endIndex = 24;
4496 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4497 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4499 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4500 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4502 Vector<Vector2> expectedSizes;
4503 Vector<Vector2> expectedPositions;
4505 expectedPositions.PushBack(Vector2(37, 0));
4506 expectedSizes.PushBack(Vector2(20, 25));
4508 expectedPositions.PushBack(Vector2(-1, 25));
4509 expectedSizes.PushBack(Vector2(52, 25));
4511 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4516 int utcDaliTextEditorGeometryEllipsisMiddle(void)
4518 ToolkitTestApplication application;
4519 tet_infoline(" utcDaliTextEditorGeometryEllipsisMiddle");
4521 TextEditor editor = TextEditor::New();
4522 DALI_TEST_CHECK( editor );
4524 application.GetScene().Add( editor );
4526 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4527 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4528 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4529 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4530 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4531 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4532 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4533 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE );
4534 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4536 // Avoid a crash when core load gl resources.
4537 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4539 // Render and notify
4540 application.SendNotification();
4541 application.Render();
4543 unsigned int expectedCount = 2;
4544 unsigned int startIndex = 0;
4545 unsigned int endIndex = 24;
4547 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4548 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4550 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4551 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4553 Vector<Vector2> expectedSizes;
4554 Vector<Vector2> expectedPositions;
4556 expectedPositions.PushBack(Vector2(-1, 0));
4557 expectedSizes.PushBack(Vector2(25, 25));
4559 expectedPositions.PushBack(Vector2(-1, 25));
4560 expectedSizes.PushBack(Vector2(52, 25));
4562 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4567 int utcDaliTextEditorGeometryEllipsisEnd(void)
4569 ToolkitTestApplication application;
4570 tet_infoline(" utcDaliTextEditorGeometryEllipsisEnd");
4572 TextEditor editor = TextEditor::New();
4573 DALI_TEST_CHECK( editor );
4575 application.GetScene().Add( editor );
4577 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4578 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4579 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4580 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4581 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4582 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, false );
4583 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS, true );
4584 editor.SetProperty( DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END );
4585 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nline4" );
4587 // Avoid a crash when core load gl resources.
4588 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4590 // Render and notify
4591 application.SendNotification();
4592 application.Render();
4594 unsigned int expectedCount = 2;
4595 unsigned int startIndex = 0;
4596 unsigned int endIndex = 24;
4598 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4599 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4601 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4602 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4604 Vector<Vector2> expectedSizes;
4605 Vector<Vector2> expectedPositions;
4607 expectedPositions.PushBack(Vector2(-1, 0));
4608 expectedSizes.PushBack(Vector2(59, 25));
4610 expectedPositions.PushBack(Vector2(-1, 25));
4611 expectedSizes.PushBack(Vector2(25, 25));
4613 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4618 int utcDaliTextEditorGeometryRTL(void)
4620 ToolkitTestApplication application;
4621 tet_infoline(" utcDaliTextEditorGeometryRTL");
4623 TextEditor editor = TextEditor::New();
4624 DALI_TEST_CHECK( editor );
4626 application.GetScene().Add( editor );
4628 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4629 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4630 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4631 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4632 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4633 editor.SetProperty( TextEditor::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
4635 // Avoid a crash when core load gl resources.
4636 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4638 // Render and notify
4639 application.SendNotification();
4640 application.Render();
4642 unsigned int expectedCount = 4;
4643 unsigned int startIndex = 3;
4644 unsigned int endIndex = 24;
4646 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4647 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4649 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4650 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4652 Vector<Vector2> expectedSizes;
4653 Vector<Vector2> expectedPositions;
4655 expectedPositions.PushBack(Vector2(24, 0));
4656 expectedSizes.PushBack(Vector2(33, 25));
4658 expectedPositions.PushBack(Vector2(-1, 25));
4659 expectedSizes.PushBack(Vector2(52, 25));
4661 expectedPositions.PushBack(Vector2(-1, 50));
4662 expectedSizes.PushBack(Vector2(59, 25));
4664 expectedPositions.PushBack(Vector2(61, 75));
4665 expectedSizes.PushBack(Vector2(37, 25));
4667 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4672 int utcDaliTextEditorGeometryGlyphMiddle(void)
4674 ToolkitTestApplication application;
4675 tet_infoline(" utcDaliTextEditorGeometryGlyphMiddle");
4677 TextEditor editor = TextEditor::New();
4678 DALI_TEST_CHECK( editor );
4680 application.GetScene().Add( editor );
4682 editor.SetProperty( TextEditor::Property::POINT_SIZE, 7.f );
4683 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 200.f ) );
4684 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4685 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4686 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4687 editor.SetProperty( TextEditor::Property::TEXT, "لا تحتوي على لا" );
4689 // Avoid a crash when core load gl resources.
4690 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4692 // Render and notify
4693 application.SendNotification();
4694 application.Render();
4696 unsigned int expectedCount = 1;
4697 unsigned int startIndex = 1;
4698 unsigned int endIndex = 13;
4700 Vector<Vector2> positionsList = DevelTextEditor::GetTextPosition(editor, startIndex, endIndex);
4701 Vector<Vector2> sizeList = DevelTextEditor::GetTextSize(editor, startIndex, endIndex);
4703 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
4704 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
4706 Vector<Vector2> expectedSizes;
4707 Vector<Vector2> expectedPositions;
4709 expectedPositions.PushBack(Vector2(6, 0));
4710 expectedSizes.PushBack(Vector2(124, 25));
4712 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
4717 int utcDaliTextEditorSelectionClearedSignal(void)
4719 ToolkitTestApplication application;
4720 tet_infoline(" utcDaliTextEditorSelectionClearedSignal");
4722 TextEditor editor = TextEditor::New();
4723 DALI_TEST_CHECK( editor );
4725 application.GetScene().Add( editor );
4727 // connect to the selection changed signal.
4728 ConnectionTracker* testTracker = new ConnectionTracker();
4729 DevelTextEditor::SelectionClearedSignal(editor).Connect(&TestSelectionClearedCallback);
4730 bool selectionClearedSignal = false;
4731 editor.ConnectSignal( testTracker, "selectionCleared", CallbackFunctor(&selectionClearedSignal) );
4733 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4734 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4735 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4736 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4737 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4739 // Avoid a crash when core load gl resources.
4740 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4742 // Render and notify
4743 application.SendNotification();
4744 application.Render();
4746 // Tap on the text editor
4747 TestGenerateTap( application, 3.0f, 25.0f );
4749 // Render and notify
4750 application.SendNotification();
4751 application.Render();
4753 // Move to second line of the text & Select some text in the right of the current cursor position
4754 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4755 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4758 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4760 // Render and notify
4761 application.SendNotification();
4762 application.Render();
4764 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4766 // Render and notify
4767 application.SendNotification();
4768 application.Render();
4770 // Tap on the text editor
4771 TestGenerateTap( application, 3.0f, 25.0f );
4773 // Render and notify
4774 application.SendNotification();
4775 application.Render();
4777 gSelectionClearedCallbackCalled = false;
4779 // Move to second line of the text & select.
4780 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4781 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4784 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4786 // Render and notify
4787 application.SendNotification();
4788 application.Render();
4790 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4792 gSelectionClearedCallbackCalled = false;
4794 // Render and notify
4795 application.SendNotification();
4796 application.Render();
4798 // Move to second line of the text & select.
4799 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4800 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4802 // replace C with selected text
4803 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4805 // Render and notify
4806 application.SendNotification();
4807 application.Render();
4809 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4811 gSelectionClearedCallbackCalled = false;
4813 // Render and notify
4814 application.SendNotification();
4815 application.Render();
4817 DevelTextEditor::SelectText( editor ,1, 3 );
4819 // Render and notify
4820 application.SendNotification();
4821 application.Render();
4823 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4825 // Render and notify
4826 application.SendNotification();
4827 application.Render();
4829 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4831 gSelectionClearedCallbackCalled = false;
4833 DevelTextEditor::SelectText( editor ,1, 3 );
4835 // Render and notify
4836 application.SendNotification();
4837 application.Render();
4840 DevelTextEditor::SelectNone(editor);
4842 // Render and notify
4843 application.SendNotification();
4844 application.Render();
4846 DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4851 int utcDaliTextEditorSelectionWithSecondaryCursor(void)
4853 ToolkitTestApplication application;
4854 tet_infoline(" utcDaliTextEditorSelectionWithSecondaryCursor");
4856 // Checks if the actor is created.
4858 TextEditor editor = TextEditor::New();
4859 DALI_TEST_CHECK( editor );
4861 application.GetScene().Add( editor );
4863 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
4864 editor.SetProperty( TextEditor::Property::TEXT, "اللغة العربية\nمرحبا بالجميع\nالسلام عليكم <span font-size='12' font-family='DejaVu Sans' >Hello world</span>" );
4865 editor.SetProperty( TextEditor::Property::POINT_SIZE, 12.f );
4866 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4867 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4868 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4869 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
4870 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
4872 // Avoid a crash when core load gl resources.
4873 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4875 // Render and notify
4876 application.SendNotification();
4877 application.Render();
4879 // Tap on the text editor
4880 TestGenerateTap( application, 3.0f, 25.0f );
4882 // Render and notify
4883 application.SendNotification();
4884 application.Render();
4886 //Select the last Arabic word (RTL) & some the space before the English (LTR) letters.
4887 DevelTextEditor::SelectText( editor, 35, 41 );// This will activate the alternative cursor position and thus 'cursorInfo.isSecondaryCursor' will be true.
4889 application.SendNotification();
4890 application.Render();
4892 std::string selectedText = editor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
4893 DALI_TEST_EQUALS( "عليكم ", selectedText, TEST_LOCATION );
4898 int utcDaliTextEditorSelectionChangedSignal(void)
4900 ToolkitTestApplication application;
4901 tet_infoline(" utcDaliTextEditorSelectionChangedSignal");
4903 TextEditor editor = TextEditor::New();
4904 DALI_TEST_CHECK( editor );
4906 application.GetScene().Add( editor );
4908 // connect to the selection changed signal.
4909 ConnectionTracker* testTracker = new ConnectionTracker();
4910 DevelTextEditor::SelectionChangedSignal(editor).Connect(&TestSelectionChangedCallback);
4911 bool selectionChangedSignal = false;
4912 editor.ConnectSignal( testTracker, "selectionChanged", CallbackFunctor(&selectionChangedSignal) );
4914 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4915 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4916 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4917 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4918 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4920 // Avoid a crash when core load gl resources.
4921 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4923 // Render and notify
4924 application.SendNotification();
4925 application.Render();
4927 // Tap on the text editor
4928 TestGenerateTap( application, 3.0f, 25.0f );
4930 // Render and notify
4931 application.SendNotification();
4932 application.Render();
4934 // Move to second line of the text.
4935 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4937 // Render and notify
4938 application.SendNotification();
4939 application.Render();
4941 // Select some text in the right of the current cursor position
4942 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4943 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4945 // Render and notify
4946 application.SendNotification();
4947 application.Render();
4949 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4950 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4952 gSelectionChangedCallbackCalled = false;
4954 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4956 // Render and notify
4957 application.SendNotification();
4958 application.Render();
4960 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4961 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4962 DALI_TEST_EQUALS(oldSelectionEnd, 7, TEST_LOCATION);
4964 gSelectionChangedCallbackCalled = false;
4966 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4968 // Render and notify
4969 application.SendNotification();
4970 application.Render();
4972 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4973 DALI_TEST_EQUALS(oldSelectionStart, 6, TEST_LOCATION);
4974 DALI_TEST_EQUALS(oldSelectionEnd, 8, TEST_LOCATION);
4976 gSelectionChangedCallbackCalled = false;
4977 editor.SetKeyInputFocus();
4979 // Render and notify
4980 application.SendNotification();
4981 application.Render();
4983 DevelTextEditor::SelectText( editor ,0, 5 );
4985 application.SendNotification();
4986 application.Render();
4988 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4989 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4991 gSelectionChangedCallbackCalled = false;
4993 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4995 // Render and notify
4996 application.SendNotification();
4997 application.Render();
4999 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5000 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5001 DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
5003 gSelectionChangedCallbackCalled = false;
5006 DevelTextEditor::SelectWholeText(editor);
5008 // Render and notify
5009 application.SendNotification();
5010 application.Render();
5012 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5013 DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
5015 gSelectionChangedCallbackCalled = false;
5018 DevelTextEditor::SelectNone(editor);
5020 // Render and notify
5021 application.SendNotification();
5022 application.Render();
5024 DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
5025 DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
5026 DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
5032 int utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize(void)
5035 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5036 //DaliException on vector: "Iterator not inside vector"
5038 ToolkitTestApplication application;
5039 tet_infoline(" utcDaliTextEditorInsertCharacterAfterInitWithResizePolicyNaturalSize");
5041 TextEditor editor = TextEditor::New();
5042 DALI_TEST_CHECK( editor );
5044 application.GetScene().Add( editor );
5046 // Avoid a crash when core load gl resources.
5047 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5049 //Set multilines text
5050 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5051 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5052 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5054 //Set ResizePolicy to NaturalSize
5055 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5057 // Render and notify
5058 application.SendNotification();
5059 application.Render();
5061 // Create a tap event to touch the text editor.
5062 TestGenerateTap( application, 5.0f, 5.0f );
5064 // Render and notify
5065 application.SendNotification();
5066 application.Render();
5068 // Set currsor and add character (in first line)
5069 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5070 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5071 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5073 // Render and notify
5074 application.SendNotification();
5075 application.Render();
5077 //Check the changed text and cursor position
5078 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hellod \n World", TEST_LOCATION );
5079 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 6, TEST_LOCATION );
5081 // Render and notify
5082 application.SendNotification();
5083 application.Render();
5088 int utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize(void)
5091 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5092 //DaliException on vector: "Iterator not inside vector"
5094 ToolkitTestApplication application;
5095 tet_infoline(" utcDaliTextEditorRemoveCharacterAfterInitWithResizePolicyNaturalSize");
5097 TextEditor editor = TextEditor::New();
5098 DALI_TEST_CHECK( editor );
5100 application.GetScene().Add( editor );
5102 // Avoid a crash when core load gl resources.
5103 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5105 //Set multilines text
5106 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5107 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5108 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5110 //Set ResizePolicy to NaturalSize
5111 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5114 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5115 application.SendNotification();
5116 application.Render();
5118 // Set focus and remove character
5119 editor.SetKeyInputFocus();
5120 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5122 // Render and notify
5123 application.SendNotification();
5124 application.Render();
5126 //Check the changed text and cursor position
5127 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hell \n World", TEST_LOCATION );
5128 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
5130 // Render and notify
5131 application.SendNotification();
5132 application.Render();
5137 int utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize(void)
5140 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5141 //DaliException on vector: "Iterator not inside vector"
5143 ToolkitTestApplication application;
5144 tet_infoline(" utcDaliTextEditorCutSelectedTextAfterInitWithResizePolicyNaturalSize");
5146 TextEditor editor = TextEditor::New();
5147 DALI_TEST_CHECK( editor );
5149 application.GetScene().Add( editor );
5151 // Avoid a crash when core load gl resources.
5152 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5154 //Set multilines text
5155 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5156 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5157 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5159 //Set ResizePolicy to NaturalSize
5160 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5162 //Select text at initialization (before the first render)
5163 DevelTextEditor::SelectText( editor ,3, 5 );
5165 // Render and notify
5166 application.SendNotification();
5167 application.Render();
5170 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5171 application.ProcessEvent( GenerateKey( "x", "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
5173 // Render and notify
5174 application.SendNotification();
5175 application.Render();
5177 //Check the changed text and cursor position
5178 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hel \n World", TEST_LOCATION );
5179 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 3, TEST_LOCATION );
5181 // Render and notify
5182 application.SendNotification();
5183 application.Render();
5189 int utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize(void)
5192 //This is to test a crash when used Resize Policy equals USE_NATURAL_SIZE
5193 //DaliException on vector: "Iterator not inside vector"
5195 ToolkitTestApplication application;
5196 tet_infoline(" utcDaliTextEditorDoubleEnterAfterInitWithResizePolicyNaturalSize");
5198 TextEditor editor = TextEditor::New();
5199 DALI_TEST_CHECK( editor );
5201 application.GetScene().Add( editor );
5203 // Avoid a crash when core load gl resources.
5204 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
5206 //Set multilines text
5207 editor.SetProperty(Dali::Toolkit::TextEditor::Property::TEXT, "Hello \n World");
5208 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
5209 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
5211 //Set ResizePolicy to NaturalSize
5212 editor.SetProperty(Dali::Actor::Property::WIDTH_RESIZE_POLICY, ResizePolicy::USE_NATURAL_SIZE);
5215 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 5);
5216 application.SendNotification();
5217 application.Render();
5219 // Set focus and double enter (new line)
5220 editor.SetKeyInputFocus();
5221 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5222 application.ProcessEvent(GenerateKey("Enter", "", "\n", 13, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
5224 // Render and notify
5225 application.SendNotification();
5226 application.Render();
5228 //Check the changed text and cursor position
5229 DALI_TEST_EQUALS( editor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "Hello\n\n \n World", TEST_LOCATION );
5230 DALI_TEST_EQUALS( editor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 7, TEST_LOCATION );
5232 // Render and notify
5233 application.SendNotification();
5234 application.Render();