2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
31 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
106 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
107 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
108 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP = "enableGrabHandlePopup";
109 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS = "inputMethodSettings";
110 const char* const PROPERTY_NAME_INPUT_FILTER = "inputFilter";
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
115 const float RENDER_FRAME_INTERVAL = 16.66f;
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
120 const int KEY_A_CODE = 38;
121 const int KEY_D_CODE = 40;
122 const int KEY_C_CODE = 54;
123 const int KEY_V_CODE = 55;
124 const int KEY_X_CODE = 53;
125 const int KEY_WHITE_SPACE_CODE = 65;
127 const int KEY_SHIFT_MODIFIER = 257;
128 const int KEY_CONTROL_MODIFIER = 258;
130 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
131 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
132 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
134 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
136 static bool gAnchorClickedCallBackCalled;
137 static bool gAnchorClickedCallBackNotCalled;
138 static bool gTextChangedCallBackCalled;
139 static bool gInputFilteredAcceptedCallbackCalled;
140 static bool gInputFilteredRejectedCallbackCalled;
141 static bool gInputStyleChangedCallbackCalled;
142 static bool gMaxCharactersCallBackCalled;
143 static bool gCursorPositionChangedCallbackCalled;
144 static uint32_t oldCursorPos;
145 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
147 struct CallbackFunctor
149 CallbackFunctor(bool* callbackFlag)
150 : mCallbackFlag( callbackFlag )
156 *mCallbackFlag = true;
161 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
163 tet_infoline(" TestAnchorClickedCallback");
165 gAnchorClickedCallBackNotCalled = false;
167 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
169 gAnchorClickedCallBackCalled = true;
173 static void TestCursorPositionChangedCallback( TextEditor control, unsigned int oldPos )
175 tet_infoline(" TestCursorPositionChangedCallback");
177 gCursorPositionChangedCallbackCalled = true;
178 oldCursorPos = oldPos;
181 static void TestTextChangedCallback( TextEditor control )
183 tet_infoline(" TestTextChangedCallback");
185 gTextChangedCallBackCalled = true;
188 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
190 tet_infoline(" TestInputStyleChangedCallback");
192 gInputStyleChangedCallbackCalled = true;
193 gInputStyleMask = mask;
196 static void TestMaxLengthReachedCallback( TextEditor control )
198 tet_infoline(" TestMaxLengthReachedCallback");
200 gMaxCharactersCallBackCalled = true;
203 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
205 tet_infoline(" TestInputFilteredCallback");
207 if(type == Toolkit::InputFilter::Property::ACCEPTED)
209 gInputFilteredAcceptedCallbackCalled = true;
211 else if(type == Toolkit::InputFilter::Property::REJECTED)
213 gInputFilteredRejectedCallbackCalled = true;
217 // Generate a KeyEvent to send to Core.
218 Integration::KeyEvent GenerateKey( const std::string& keyName,
219 const std::string& logicalKey,
220 const std::string& keyString,
223 unsigned long timeStamp,
224 const Integration::KeyEvent::State& keyState,
225 const std::string& compose = "",
226 const std::string& deviceName = DEFAULT_DEVICE_NAME,
227 const Device::Class::Type& deviceClass = Device::Class::NONE,
228 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
230 return Integration::KeyEvent( keyName,
243 Dali::Integration::Point GetPointDownInside( Vector2& pos )
245 Dali::Integration::Point point;
246 point.SetState( PointState::DOWN );
247 point.SetScreenPosition( pos );
251 Dali::Integration::Point GetPointUpInside( Vector2& pos )
253 Dali::Integration::Point point;
254 point.SetState( PointState::UP );
255 point.SetScreenPosition( pos );
259 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
261 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
263 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
265 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
267 Property::Value* valueSet = NULL;
268 if ( valueGet.first.type == Property::Key::INDEX )
270 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
274 // Get Key is a string so searching Set Map for a string key
275 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
278 if( NULL != valueSet )
280 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
282 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
285 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
287 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
290 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
292 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
295 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
297 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
300 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
302 Vector2 vector2Get = valueGet.second.Get<Vector2>();
303 Vector2 vector2Set = valueSet->Get<Vector2>();
304 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
307 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
309 Vector4 vector4Get = valueGet.second.Get<Vector4>();
310 Vector4 vector4Set = valueSet->Get<Vector4>();
311 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 );
317 if ( valueGet.first.type == Property::Key::INDEX )
319 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
323 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
333 class ScrollStateChangeCallback : public Dali::ConnectionTracker
336 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
337 : mStartedCalled( startedCalled ),
338 mFinishedCalled( finishedCalled )
342 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
344 if( type == TextEditor::Scroll::STARTED )
346 mStartedCalled = true;
348 else if( type == TextEditor::Scroll::FINISHED )
350 mFinishedCalled = true;
354 bool& mStartedCalled;
355 bool& mFinishedCalled;
360 int UtcDaliToolkitTextEditorConstructorP(void)
362 ToolkitTestApplication application;
363 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
364 TextEditor textEditor;
365 DALI_TEST_CHECK( !textEditor );
369 int UtcDaliToolkitTextEditorNewP(void)
371 ToolkitTestApplication application;
372 tet_infoline(" UtcDaliToolkitTextEditorNewP");
373 TextEditor textEditor = TextEditor::New();
374 DALI_TEST_CHECK( textEditor );
378 int UtcDaliToolkitTextEditorDownCastP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
382 TextEditor textEditor1 = TextEditor::New();
383 BaseHandle object( textEditor1 );
385 TextEditor textEditor2 = TextEditor::DownCast( object );
386 DALI_TEST_CHECK( textEditor2 );
388 TextEditor textEditor3 = DownCast< TextEditor >( object );
389 DALI_TEST_CHECK( textEditor3 );
393 int UtcDaliToolkitTextEditorDownCastN(void)
395 ToolkitTestApplication application;
396 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
397 BaseHandle uninitializedObject;
398 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
399 DALI_TEST_CHECK( !textEditor1 );
401 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
402 DALI_TEST_CHECK( !textEditor2 );
406 int UtcDaliToolkitTextEditorCopyConstructorP(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
410 TextEditor textEditor = TextEditor::New();
411 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
413 TextEditor copy( textEditor );
414 DALI_TEST_CHECK( copy );
415 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
419 int UtcDaliTextEditorMoveConstructor(void)
421 ToolkitTestApplication application;
423 TextEditor textEditor = TextEditor::New();
424 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
425 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
427 TextEditor moved = std::move( textEditor );
428 DALI_TEST_CHECK( moved );
429 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
430 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
431 DALI_TEST_CHECK( !textEditor );
436 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
438 ToolkitTestApplication application;
439 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
440 TextEditor textEditor = TextEditor::New();
441 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
443 TextEditor copy = textEditor;
444 DALI_TEST_CHECK( copy );
445 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
449 int UtcDaliTextEditorMoveAssignment(void)
451 ToolkitTestApplication application;
453 TextEditor textEditor = TextEditor::New();
454 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
455 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
458 moved = std::move( textEditor );
459 DALI_TEST_CHECK( moved );
460 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
461 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
462 DALI_TEST_CHECK( !textEditor );
467 int UtcDaliTextEditorNewP(void)
469 ToolkitTestApplication application;
470 tet_infoline(" UtcDaliToolkitTextEditorNewP");
471 TextEditor textEditor = TextEditor::New();
472 DALI_TEST_CHECK( textEditor );
476 // Positive test case for a method
477 int UtcDaliTextEditorGetPropertyP(void)
479 ToolkitTestApplication application;
480 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
481 TextEditor editor = TextEditor::New();
482 DALI_TEST_CHECK( editor );
484 // Check Property Indices are correct
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
550 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
553 Property::Map imageMap;
554 imageMap[mapKey] =mapValue;
556 editor.SetProperty( property , imageMap );
557 Property::Value propValue = editor.GetProperty( property );
558 Property::Map* resultMap = propValue.GetMap();
560 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
568 // Positive test case for a method
569 int UtcDaliTextEditorSetPropertyP(void)
571 ToolkitTestApplication application;
572 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
573 TextEditor editor = TextEditor::New();
574 DALI_TEST_CHECK( editor );
575 application.GetScene().Add( editor );
577 // Note - we can't check the defaults since the stylesheets are platform-specific
579 // Check the render backend property.
580 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
581 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
583 // Check text property.
584 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
585 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
587 // Check text's color property
588 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
589 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
591 // Check font properties.
592 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
593 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
595 Property::Map fontStyleMapSet;
596 Property::Map fontStyleMapGet;
597 Property::Value* slantValue = NULL;
599 fontStyleMapSet.Insert( "weight", "bold" );
600 fontStyleMapSet.Insert( "width", "condensed" );
601 fontStyleMapSet.Insert( "slant", "italic" );
603 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
604 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
605 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
606 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
608 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
609 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
611 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
612 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
613 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
616 fontStyleMapSet.Clear();
617 fontStyleMapSet.Insert( "weight", "normal" );
618 fontStyleMapSet.Insert( "slant", "oblique" );
619 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
620 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
621 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
622 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
624 fontStyleMapSet.Clear();
625 fontStyleMapSet.Insert( "slant", "roman" );
626 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
627 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
629 // Replace 'roman' for 'normal'.
630 slantValue = fontStyleMapGet.Find( "slant" );
631 if( NULL != slantValue )
633 if( "normal" == slantValue->Get<std::string>() )
635 fontStyleMapGet["slant"] = "roman";
638 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
639 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
641 fontStyleMapSet.Clear();
643 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
644 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
645 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
646 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
648 // Check that the Alignment properties can be correctly set
649 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
650 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
652 // Check scroll properties.
653 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
654 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
655 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
656 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
658 // Check cursor properties
659 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
660 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
661 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
662 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
664 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
665 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
666 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
667 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
669 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
670 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
671 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
673 // Check handle images
674 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
675 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
676 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
677 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
678 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
680 // Check handle images
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
682 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
683 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
684 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
685 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
686 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
688 // Check the highlight color
689 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
690 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
692 // Decoration bounding box
693 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
694 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
696 // Check the enable markup property.
697 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
698 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
699 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
701 // Check input color property.
702 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
703 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
705 // Check input font properties.
706 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
707 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
709 fontStyleMapSet.Clear();
710 fontStyleMapSet.Insert( "weight", "bold" );
711 fontStyleMapSet.Insert( "width", "condensed" );
712 fontStyleMapSet.Insert( "slant", "italic" );
714 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
715 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
716 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
717 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
719 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
720 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
722 // Reset input font style.
723 fontStyleMapSet.Clear();
724 fontStyleMapSet.Insert( "weight", "normal" );
725 fontStyleMapSet.Insert( "slant", "oblique" );
727 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
728 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
729 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
730 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
732 fontStyleMapSet.Clear();
733 fontStyleMapSet.Insert( "slant", "roman" );
735 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
736 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
738 // Replace 'roman' for 'normal'.
739 slantValue = fontStyleMapGet.Find( "slant" );
740 if( NULL != slantValue )
742 if( "normal" == slantValue->Get<std::string>() )
744 fontStyleMapGet["slant"] = "roman";
747 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
748 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
750 fontStyleMapSet.Clear();
752 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
753 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
754 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
755 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
757 // Check the line spacing property
758 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
759 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
760 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
762 // Check the input line spacing property
763 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
764 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
765 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
767 // Check the underline property
769 Property::Map underlineMapSet;
770 Property::Map underlineMapGet;
772 underlineMapSet.Insert( "enable", true );
773 underlineMapSet.Insert( "color", Color::RED );
774 underlineMapSet.Insert( "height", 1 );
776 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
778 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
779 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
780 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
782 // Check the input underline property
783 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
784 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
786 // Check the shadow property
787 Property::Map shadowMapSet;
788 Property::Map shadowMapGet;
790 shadowMapSet.Insert( "color", Color::GREEN );
791 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
792 shadowMapSet.Insert( "blurRadius", 3.0f );
794 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
796 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
797 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
798 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
800 // Check the input shadow property
801 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
802 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
804 // Check the emboss property
805 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
806 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
808 // Check the input emboss property
809 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
810 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
812 // Check the outline property
814 // Test string type first
815 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
816 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
817 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
819 // Then test the property map type
820 Property::Map outlineMapSet;
821 Property::Map outlineMapGet;
823 outlineMapSet["color"] = Color::RED;
824 outlineMapSet["width"] = 2.0f;
826 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
828 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
829 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
830 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
832 // Check the input outline property
833 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
834 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
836 // Check the smooth scroll property
837 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
838 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
839 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
841 // Check the smooth scroll duration property
842 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
843 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
845 // Check the scroll bar property
846 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
847 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
848 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
850 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
851 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
852 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
853 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
855 // Check the pixel size of font
856 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
857 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
859 // Check placeholder text properties.
860 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
861 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
863 // Check placeholder text's color property.
864 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
865 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
867 // Check the enable selection property
868 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
869 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
871 // Check the placeholder property with pixel size
872 Property::Map placeholderPixelSizeMapSet;
873 Property::Map placeholderPixelSizeMapGet;
874 Property::Map placeholderFontstyleMap;
875 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
876 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
877 placeholderPixelSizeMapSet["color"] = Color::BLUE;
878 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
879 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
881 placeholderFontstyleMap.Insert( "weight", "bold" );
882 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
883 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
885 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
886 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
888 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
889 Property::Map placeholderConversionMap;
890 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
891 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
892 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
893 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
894 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
895 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
897 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
899 // Check the placeholder property with point size
900 Property::Map placeholderMapSet;
901 Property::Map placeholderMapGet;
902 placeholderMapSet["text"] = "Setting Placeholder Text";
903 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
904 placeholderMapSet["color"] = Color::RED;
905 placeholderMapSet["fontFamily"] = "Arial";
906 placeholderMapSet["pointSize"] = 12.0f;
907 // Check the placeholder font style property
908 placeholderFontstyleMap.Clear();
910 placeholderFontstyleMap.Insert( "weight", "bold" );
911 placeholderFontstyleMap.Insert( "width", "condensed" );
912 placeholderFontstyleMap.Insert( "slant", "italic" );
913 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
914 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
916 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
917 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
919 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
920 placeholderConversionMap.Clear();
921 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
923 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
924 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
925 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
926 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
927 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
930 placeholderFontstyleMap.Clear();
931 placeholderFontstyleMap.Insert( "weight", "normal" );
932 placeholderFontstyleMap.Insert( "slant", "oblique" );
933 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
934 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
936 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
937 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
938 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
939 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
941 placeholderFontstyleMap.Clear();
942 placeholderFontstyleMap.Insert( "slant", "roman" );
943 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
944 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
946 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
948 placeholderFontstyleMap.Clear();
949 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
951 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
952 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
953 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
954 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
955 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
957 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
958 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
960 // Check handle color
961 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
962 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
964 // Test the ENABLE_GRAB_HANDLE_POPUP property
965 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
966 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
968 // Check the input method setting
969 Property::Map propertyMap;
970 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
971 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
972 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
973 int inputVariation = 1;
974 propertyMap["PANEL_LAYOUT"] = panelLayout;
975 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
976 propertyMap["BUTTON_ACTION"] = buttonAction;
977 propertyMap["VARIATION"] = inputVariation;
978 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
980 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
982 DALI_TEST_CHECK( value.Get( map ) );
985 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
986 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
989 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
990 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
993 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
994 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
997 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
998 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
1000 // Check the input filter property
1001 Property::Map inputFilterMapSet;
1002 Property::Map inputFilterMapGet;
1003 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1004 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1006 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1008 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
1009 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1012 inputFilterMapSet.Clear();
1013 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1015 application.SendNotification();
1016 application.Render();
1018 // Check the line size property
1019 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1020 editor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 50.f );
1021 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1026 // Positive Atlas Text Renderer test
1027 int utcDaliTextEditorAtlasRenderP(void)
1029 ToolkitTestApplication application;
1030 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1031 StyleManager styleManager = StyleManager::Get();
1032 styleManager.ApplyDefaultTheme();
1033 TextEditor editor = TextEditor::New();
1034 DALI_TEST_CHECK( editor );
1036 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1038 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1040 application.GetScene().Add( editor );
1044 // Render some text with the shared atlas backend
1045 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1046 application.SendNotification();
1047 application.Render();
1051 tet_result(TET_FAIL);
1056 // Positive test for the anchorClicked signal.
1057 int utcDaliTextEditorAnchorClickedP(void)
1059 ToolkitTestApplication application;
1060 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1061 TextEditor editor = TextEditor::New();
1062 DALI_TEST_CHECK(editor);
1064 application.GetScene().Add(editor);
1066 // connect to the anchor clicked signal.
1067 ConnectionTracker* testTracker = new ConnectionTracker();
1068 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1069 bool anchorClickedSignal = false;
1070 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1072 gAnchorClickedCallBackCalled = false;
1073 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1074 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1075 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1076 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1077 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1079 application.SendNotification();
1080 application.Render();
1081 editor.SetKeyInputFocus();
1083 // Create a tap event to touch the text editor.
1084 TestGenerateTap(application, 5.0f, 5.0f);
1085 application.SendNotification();
1086 application.Render();
1088 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1089 DALI_TEST_CHECK(anchorClickedSignal);
1091 gAnchorClickedCallBackNotCalled = true;
1092 // Tap the outside of anchor, callback should not be called.
1093 TestGenerateTap(application, 150.f, 100.f);
1094 application.SendNotification();
1095 application.Render();
1097 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1102 // Positive test for the textChanged signal.
1103 int utcDaliTextEditorTextChangedP(void)
1105 ToolkitTestApplication application;
1106 tet_infoline(" utcDaliTextEditorTextChangedP");
1107 TextEditor editor = TextEditor::New();
1108 DALI_TEST_CHECK( editor );
1110 application.GetScene().Add( editor );
1112 // connect to the text changed signal.
1113 ConnectionTracker* testTracker = new ConnectionTracker();
1114 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1115 bool textChangedSignal = false;
1116 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1118 gTextChangedCallBackCalled = false;
1119 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1120 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1121 DALI_TEST_CHECK( textChangedSignal );
1123 application.SendNotification();
1124 editor.SetKeyInputFocus();
1126 gTextChangedCallBackCalled = false;
1127 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1128 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1131 editor.SetProperty( TextField::Property::TEXT, "" );
1133 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1134 gTextChangedCallBackCalled = false;
1135 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1136 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1138 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1139 gTextChangedCallBackCalled = false;
1140 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1141 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1146 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1148 ToolkitTestApplication application;
1149 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1150 TextEditor editor = TextEditor::New();
1151 DALI_TEST_CHECK( editor );
1154 application.GetScene().Add( editor );
1156 // connect to the text changed signal.
1157 ConnectionTracker* testTracker = new ConnectionTracker();
1158 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1159 bool textChangedSignal = false;
1160 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1163 // get InputMethodContext
1165 InputMethodContext::EventData imfEvent;
1166 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1168 editor.SetKeyInputFocus();
1169 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1172 gTextChangedCallBackCalled = false;
1173 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1174 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1175 application.SendNotification();
1176 application.Render();
1177 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1178 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1180 gTextChangedCallBackCalled = false;
1181 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1182 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1183 application.SendNotification();
1184 application.Render();
1185 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1186 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1188 gTextChangedCallBackCalled = false;
1189 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1190 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1191 application.SendNotification();
1192 application.Render();
1193 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1194 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1196 gTextChangedCallBackCalled = false;
1197 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1198 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1199 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1201 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1202 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1203 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1205 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1206 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1207 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1209 application.SendNotification();
1210 application.Render();
1211 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1212 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1218 int utcDaliTextEditorInputStyleChanged01(void)
1220 // The text-editor emits signals when the input style changes. These changes of style are
1221 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1222 // can't be emitted during the size negotiation as the callbacks may update the UI.
1223 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1224 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1225 ToolkitTestApplication application;
1226 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1230 char* pathNamePtr = get_current_dir_name();
1231 const std::string pathName( pathNamePtr );
1232 free( pathNamePtr );
1234 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1235 fontClient.SetDpi( 93u, 93u );
1237 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1238 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1240 TextEditor editor = TextEditor::New();
1241 DALI_TEST_CHECK( editor );
1244 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1245 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1246 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1248 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1249 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1251 // connect to the text changed signal.
1252 ConnectionTracker* testTracker = new ConnectionTracker();
1253 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1254 bool inputStyleChangedSignal = false;
1255 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1257 application.GetScene().Add( editor );
1259 // Render and notify
1260 application.SendNotification();
1261 application.Render();
1263 // Executes the idle callbacks added by the text control on the change of input style.
1264 application.RunIdles();
1266 gInputStyleChangedCallbackCalled = false;
1267 gInputStyleMask = TextEditor::InputStyle::NONE;
1268 inputStyleChangedSignal = false;
1270 // Create a tap event to touch the text editor.
1271 TestGenerateTap( application, 18.0f, 25.0f );
1273 // Render and notify
1274 application.SendNotification();
1275 application.Render();
1277 // Executes the idle callbacks added by the text control on the change of input style.
1278 application.RunIdles();
1280 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1281 if( gInputStyleChangedCallbackCalled )
1283 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1285 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1286 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1288 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1289 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1291 DALI_TEST_CHECK( inputStyleChangedSignal );
1293 gInputStyleChangedCallbackCalled = false;
1294 gInputStyleMask = TextEditor::InputStyle::NONE;
1295 inputStyleChangedSignal = false;
1297 // Create a tap event to touch the text editor.
1298 TestGenerateTap( application, 30.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 DALI_TEST_CHECK( !inputStyleChangedSignal );
1310 gInputStyleChangedCallbackCalled = false;
1311 gInputStyleMask = TextEditor::InputStyle::NONE;
1312 inputStyleChangedSignal = false;
1314 // Create a tap event to touch the text editor.
1315 TestGenerateTap( application, 43.0f, 25.0f );
1317 // Render and notify
1318 application.SendNotification();
1319 application.Render();
1321 // Executes the idle callbacks added by the text control on the change of input style.
1322 application.RunIdles();
1324 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1325 if( gInputStyleChangedCallbackCalled )
1327 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1329 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1330 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1332 DALI_TEST_CHECK( inputStyleChangedSignal );
1334 gInputStyleChangedCallbackCalled = false;
1335 gInputStyleMask = TextEditor::InputStyle::NONE;
1336 inputStyleChangedSignal = false;
1338 // Create a tap event to touch the text editor.
1339 TestGenerateTap( application, 88.0f, 25.0f );
1341 // Render and notify
1342 application.SendNotification();
1343 application.Render();
1345 // Executes the idle callbacks added by the text control on the change of input style.
1346 application.RunIdles();
1348 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1349 if( gInputStyleChangedCallbackCalled )
1351 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1353 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1354 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1356 Property::Map fontStyleMapSet;
1357 Property::Map fontStyleMapGet;
1359 fontStyleMapSet.Insert( "weight", "bold" );
1361 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1362 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1363 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1365 DALI_TEST_CHECK( inputStyleChangedSignal );
1367 gInputStyleChangedCallbackCalled = false;
1368 gInputStyleMask = TextEditor::InputStyle::NONE;
1369 inputStyleChangedSignal = false;
1371 // Create a tap event to touch the text editor.
1372 TestGenerateTap( application, 115.0f, 25.0f );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Executes the idle callbacks added by the text control on the change of input style.
1379 application.RunIdles();
1381 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1382 DALI_TEST_CHECK( !inputStyleChangedSignal );
1384 gInputStyleChangedCallbackCalled = false;
1385 gInputStyleMask = TextEditor::InputStyle::NONE;
1386 inputStyleChangedSignal = false;
1388 // Create a tap event to touch the text editor.
1389 TestGenerateTap( application, 164.0f, 25.0f );
1391 // Render and notify
1392 application.SendNotification();
1393 application.Render();
1395 // Executes the idle callbacks added by the text control on the change of input style.
1396 application.RunIdles();
1398 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1399 if( gInputStyleChangedCallbackCalled )
1401 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1403 Property::Map fontStyleMapSet;
1404 Property::Map fontStyleMapGet;
1406 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1407 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1408 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1410 DALI_TEST_CHECK( inputStyleChangedSignal );
1412 gInputStyleChangedCallbackCalled = false;
1413 gInputStyleMask = TextEditor::InputStyle::NONE;
1414 inputStyleChangedSignal = false;
1416 // Create a tap event to touch the text editor.
1417 TestGenerateTap( application, 191.0f, 25.0f );
1419 // Render and notify
1420 application.SendNotification();
1421 application.Render();
1423 // Executes the idle callbacks added by the text control on the change of input style.
1424 application.RunIdles();
1426 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1427 DALI_TEST_CHECK( !inputStyleChangedSignal );
1432 int utcDaliTextEditorInputStyleChanged02(void)
1434 // The text-editor emits signals when the input style changes. These changes of style are
1435 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1436 // can't be emitted during the size negotiation as the callbacks may update the UI.
1437 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1438 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1439 ToolkitTestApplication application;
1440 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1444 char* pathNamePtr = get_current_dir_name();
1445 const std::string pathName( pathNamePtr );
1446 free( pathNamePtr );
1448 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1449 fontClient.SetDpi( 93u, 93u );
1451 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1452 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1454 TextEditor editor = TextEditor::New();
1455 DALI_TEST_CHECK( editor );
1458 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1459 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1460 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1462 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1463 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>" );
1465 // connect to the text changed signal.
1466 ConnectionTracker* testTracker = new ConnectionTracker();
1467 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1468 bool inputStyleChangedSignal = false;
1469 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1471 application.GetScene().Add( editor );
1473 // Render and notify
1474 application.SendNotification();
1475 application.Render();
1477 // Executes the idle callbacks added by the text control on the change of input style.
1478 application.RunIdles();
1480 gInputStyleChangedCallbackCalled = false;
1481 gInputStyleMask = TextEditor::InputStyle::NONE;
1482 inputStyleChangedSignal = false;
1484 // Create a tap event to touch the text editor.
1485 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1486 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 // Executes the idle callbacks added by the text control on the change of input style.
1493 application.RunIdles();
1495 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1496 if( gInputStyleChangedCallbackCalled )
1498 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1499 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1500 TextEditor::InputStyle::POINT_SIZE |
1501 TextEditor::InputStyle::COLOR ),
1504 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1505 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1507 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1508 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1510 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1511 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1513 DALI_TEST_CHECK( inputStyleChangedSignal );
1515 gInputStyleChangedCallbackCalled = false;
1516 gInputStyleMask = TextEditor::InputStyle::NONE;
1517 inputStyleChangedSignal = false;
1519 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 // Executes the idle callbacks added by the text control on the change of input style.
1526 application.RunIdles();
1528 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1529 if( gInputStyleChangedCallbackCalled )
1531 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1532 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1535 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1536 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1538 DALI_TEST_CHECK( inputStyleChangedSignal );
1540 gInputStyleChangedCallbackCalled = false;
1541 gInputStyleMask = TextEditor::InputStyle::NONE;
1542 inputStyleChangedSignal = false;
1544 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1546 // Render and notify
1547 application.SendNotification();
1548 application.Render();
1550 // Executes the idle callbacks added by the text control on the change of input style.
1551 application.RunIdles();
1553 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1554 DALI_TEST_CHECK( !inputStyleChangedSignal );
1556 gInputStyleChangedCallbackCalled = false;
1557 gInputStyleMask = TextEditor::InputStyle::NONE;
1558 inputStyleChangedSignal = false;
1560 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1562 // Render and notify
1563 application.SendNotification();
1564 application.Render();
1566 // Executes the idle callbacks added by the text control on the change of input style.
1567 application.RunIdles();
1569 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1570 if( gInputStyleChangedCallbackCalled )
1572 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1573 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1576 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1577 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1579 DALI_TEST_CHECK( inputStyleChangedSignal );
1581 gInputStyleChangedCallbackCalled = false;
1582 gInputStyleMask = TextEditor::InputStyle::NONE;
1583 inputStyleChangedSignal = false;
1585 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1587 Property::Map fontStyleMapSet;
1588 fontStyleMapSet.Insert( "weight", "thin" );
1589 fontStyleMapSet.Insert( "width", "condensed" );
1590 fontStyleMapSet.Insert( "slant", "italic" );
1592 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1593 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1594 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1596 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1597 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1598 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1599 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1601 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 // Executes the idle callbacks added by the text control on the change of input style.
1608 application.RunIdles();
1610 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1611 DALI_TEST_CHECK( !inputStyleChangedSignal );
1613 // Create a tap event to touch the text editor.
1614 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 // Executes the idle callbacks added by the text control on the change of input style.
1621 application.RunIdles();
1623 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1624 if( gInputStyleChangedCallbackCalled )
1626 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1627 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1628 TextEditor::InputStyle::POINT_SIZE |
1629 TextEditor::InputStyle::FONT_STYLE |
1630 TextEditor::InputStyle::LINE_SPACING |
1631 TextEditor::InputStyle::UNDERLINE |
1632 TextEditor::InputStyle::SHADOW |
1633 TextEditor::InputStyle::EMBOSS |
1634 TextEditor::InputStyle::OUTLINE ),
1637 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1638 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1640 DALI_TEST_CHECK( inputStyleChangedSignal );
1642 gInputStyleChangedCallbackCalled = false;
1643 gInputStyleMask = TextEditor::InputStyle::NONE;
1644 inputStyleChangedSignal = false;
1646 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1648 fontStyleMapSet.Clear();
1649 fontStyleMapSet.Insert( "weight", "black" );
1650 fontStyleMapSet.Insert( "width", "expanded" );
1651 fontStyleMapSet.Insert( "slant", "oblique" );
1653 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1655 // Create a tap event to touch the text editor.
1656 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1658 // Render and notify
1659 application.SendNotification();
1660 application.Render();
1662 // Executes the idle callbacks added by the text control on the change of input style.
1663 application.RunIdles();
1665 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1666 if( gInputStyleChangedCallbackCalled )
1668 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1669 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1670 TextEditor::InputStyle::POINT_SIZE |
1671 TextEditor::InputStyle::FONT_STYLE ),
1674 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1675 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1677 DALI_TEST_CHECK( inputStyleChangedSignal );
1682 int utcDaliTextEditorEvent01(void)
1684 ToolkitTestApplication application;
1685 tet_infoline(" utcDaliTextEditorEvent01");
1687 // Creates a tap event. After creating a tap event the text editor should
1688 // have the focus and add text with key events should be possible.
1690 TextEditor editor = TextEditor::New();
1691 DALI_TEST_CHECK( editor );
1693 application.GetScene().Add( editor );
1695 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1696 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1697 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1699 // Avoid a crash when core load gl resources.
1700 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 // Add a key event but as the text editor has not the focus it should do nothing.
1707 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1715 // Create a tap event to touch the text editor.
1716 TestGenerateTap( application, 150.0f, 25.0f );
1718 // Render and notify
1719 application.SendNotification();
1720 application.Render();
1722 // Now the text editor has the focus, so it can handle the key events.
1723 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1724 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1732 // Create a second text editor and send key events to it.
1733 TextEditor editor2 = TextEditor::New();
1735 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1736 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1737 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1738 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1740 application.GetScene().Add( editor2 );
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1746 // Create a tap event on the second text editor.
1747 TestGenerateTap( application, 150.0f, 125.0f );
1749 // Render and notify
1750 application.SendNotification();
1751 application.Render();
1753 // The second text editor has the focus. It should handle the key events.
1754 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1755 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1757 // Render and notify
1758 application.SendNotification();
1759 application.Render();
1761 // Check the text has been added to the second text editor.
1762 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1767 int utcDaliTextEditorEvent02(void)
1769 ToolkitTestApplication application;
1770 tet_infoline(" utcDaliTextEditorEvent02");
1772 // Checks if the right number of actors are created.
1774 TextEditor editor = TextEditor::New();
1775 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1776 DALI_TEST_CHECK( editor );
1778 application.GetScene().Add( editor );
1780 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1781 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1782 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1784 // Avoid a crash when core load gl resources.
1785 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 // Check there are the expected number of children (the stencil).
1792 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1794 Actor stencil = editor.GetChildAt( 0u );
1796 // Create a tap event to touch the text editor.
1797 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1799 // Render and notify
1800 application.SendNotification();
1801 application.Render();
1803 Actor layer = editor.GetChildAt( 1u );
1804 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1805 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1807 // Now the text editor has the focus, so it can handle the key events.
1808 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1809 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1811 // Render and notify
1812 application.SendNotification();
1813 application.Render();
1815 // Checks the cursor and the renderer have been created.
1816 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1817 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1819 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1820 DALI_TEST_CHECK( cursor );
1822 // The stencil actor has a container with all the actors which contain the text renderers.
1823 Actor container = stencil.GetChildAt( 0u );
1824 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1826 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1827 DALI_TEST_CHECK( renderer );
1830 // Move the cursor and check the position changes.
1831 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1833 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1834 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1842 DALI_TEST_CHECK( position2.x < position1.x );
1844 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1845 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1851 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1853 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1855 // Send some taps and check the cursor positions.
1857 // Try to tap at the beginning.
1858 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1860 // Render and notify
1861 application.SendNotification();
1862 application.Render();
1864 // Cursor position should be the same than position1.
1865 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1867 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1869 // Tap away from the start position.
1870 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1876 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1878 DALI_TEST_CHECK( position5.x > position4.x );
1880 // Remove all the text.
1881 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1882 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1883 editor.SetProperty( TextEditor::Property::TEXT, "" );
1885 // Render and notify
1886 application.SendNotification();
1887 application.Render();
1889 // Cursor position should be the same than position2.
1890 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1892 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1894 // Should not be a renderer.
1895 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1900 int utcDaliTextEditorEvent03(void)
1902 ToolkitTestApplication application;
1903 tet_infoline(" utcDaliTextEditorEvent03");
1905 // Checks if the highlight actor is created.
1907 TextEditor editor = TextEditor::New();
1908 DALI_TEST_CHECK( editor );
1910 application.GetScene().Add( editor );
1912 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1913 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1914 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1915 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1916 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1918 // Avoid a crash when core load gl resources.
1919 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1921 // Render and notify
1922 application.SendNotification();
1923 application.Render();
1925 // Send some taps and check text controller with clipboard window
1926 Dali::Clipboard clipboard = Clipboard::Get();
1927 clipboard.ShowClipboard();
1928 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1929 clipboard.HideClipboard();
1931 // Render and notify
1932 application.SendNotification();
1933 application.Render();
1935 // Tap first to get the focus.
1936 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 // Double tap to select a word.
1943 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 // The stencil actor should have two actors: the renderer and the highlight actor.
1950 Actor stencil = editor.GetChildAt( 0u );
1952 // Highlight needs to be drawn before text, so should come first in child order
1953 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1954 DALI_TEST_CHECK( highlight );
1956 // The stencil actor has a container with all the actors which contain the text renderers.
1957 Actor container = stencil.GetChildAt( 1u );
1958 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1960 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1961 DALI_TEST_CHECK( renderer );
1964 // Double tap out of bounds
1965 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1966 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1968 // Render and notify
1969 application.SendNotification();
1970 application.Render();
1972 // The stencil actor should have one actors: the renderer actor.
1973 stencil = editor.GetChildAt( 0u );
1975 // The stencil actor has a container with all the actors which contain the text renderers.
1976 container = stencil.GetChildAt( 0u );
1977 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1979 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1980 DALI_TEST_CHECK( renderer );
1984 TestGenerateLongPress(application, 1.0f, 25.0f);
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1991 TestGenerateMiniPan(application);
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
2000 int utcDaliTextEditorEvent04(void)
2002 ToolkitTestApplication application;
2003 tet_infoline(" utcDaliTextEditorEvent04");
2005 // Checks if the highlight actor is created.
2007 TextEditor editor = TextEditor::New();
2008 DALI_TEST_CHECK( editor );
2010 application.GetScene().Add( editor );
2012 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2013 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2014 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2015 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2016 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2018 // Avoid a crash when core load gl resources.
2019 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2021 // Render and notify
2022 application.SendNotification();
2023 application.Render();
2025 // Tap on the text editor
2026 TestGenerateTap( application, 3.0f, 25.0f );
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2032 // Move at the end of the text.
2033 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2034 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2036 // Render and notify
2037 application.SendNotification();
2038 application.Render();
2040 for( unsigned int index = 0u; index < 10u; ++index )
2042 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2043 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2051 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2059 // Add some key events
2060 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2061 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 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_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 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( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", 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 );
2089 int utcDaliTextEditorEvent05(void)
2091 ToolkitTestApplication application;
2092 tet_infoline(" utcDaliTextEditorEvent05");
2094 // Checks if the highlight actor is created.
2096 TextEditor editor = TextEditor::New();
2097 DALI_TEST_CHECK( editor );
2099 application.GetScene().Add( editor );
2101 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2102 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2103 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2104 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2105 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2106 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2107 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2108 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2109 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2110 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2112 // Avoid a crash when core load gl resources.
2113 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2115 // Render and notify
2116 application.SendNotification();
2117 application.Render();
2119 // Tap on the text editor
2120 TestGenerateTap( application, 3.0f, 25.0f );
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Move at the end of the text.
2127 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2130 // Render and notify
2131 application.SendNotification();
2132 application.Render();
2134 for( unsigned int index = 0u; index < 10u; ++index )
2137 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2139 // Render and notify
2140 application.SendNotification();
2141 application.Render();
2143 // Modify duration after scroll is enabled
2144 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2146 // Continuous scroll left to increase coverage
2147 for( unsigned int index = 0u; index < 10u; ++index )
2149 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2156 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2157 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2158 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2159 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2161 // Press Escape to increase coverage
2162 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163 application.SendNotification();
2164 application.Render();
2166 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2171 int utcDaliTextEditorEvent06(void)
2173 ToolkitTestApplication application;
2174 tet_infoline(" utcDaliTextEditorEvent06");
2176 // Checks if the highlight actor is created.
2178 TextEditor editor = TextEditor::New();
2179 DALI_TEST_CHECK( editor );
2181 application.GetScene().Add( editor );
2183 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2184 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2185 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2186 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2187 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2189 // Avoid a crash when core load gl resources.
2190 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 // Tap on the text editor
2197 TestGenerateTap( application, 3.0f, 25.0f );
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // Move to seconds line of the text.
2204 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 float layoutHeight = editor.GetHeightForWidth( 100.f );
2213 // Add another script characters ( glyph height is defferent )
2214 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 // Delete characters
2218 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2227 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2230 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2231 application.SendNotification();
2232 application.Render();
2234 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235 application.SendNotification();
2236 application.Render();
2238 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 application.SendNotification();
2240 application.Render();
2242 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2243 application.SendNotification();
2244 application.Render();
2246 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2247 application.SendNotification();
2248 application.Render();
2250 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2251 application.SendNotification();
2252 application.Render();
2254 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 application.SendNotification();
2256 application.Render();
2261 int utcDaliTextEditorEvent07(void)
2263 ToolkitTestApplication application;
2264 tet_infoline(" utcDaliTextEditorEvent07");
2266 // Checks if the highlight actor is created.
2268 TextEditor editor = TextEditor::New();
2269 DALI_TEST_CHECK( editor );
2271 application.GetScene().Add( editor );
2273 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2274 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2275 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2276 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2277 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2279 // Avoid a crash when core load gl resources.
2280 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2286 // Tap on the text editor
2287 TestGenerateTap( application, 3.0f, 25.0f );
2289 // Render and notify
2290 application.SendNotification();
2291 application.Render();
2293 // Move to second line of the text.
2294 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2296 // Render and notify
2297 application.SendNotification();
2298 application.Render();
2300 // Select some text in the right of the current cursor position
2301 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2304 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 // Cut the selected text
2311 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2312 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 ) );
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2318 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2320 // Select some text in the left of the current cursor position
2321 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2330 // Copy the selected text
2331 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 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 ) );
2334 // Render and notify
2335 application.SendNotification();
2336 application.Render();
2338 // Move the cursor to the third line
2339 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2340 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 // Render and notify
2343 application.SendNotification();
2344 application.Render();
2346 // Paste the selected text at the current cursor position
2347 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2348 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 ) );
2350 // Render and notify
2351 application.SendNotification();
2352 application.Render();
2354 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2357 // Disable Shift Selection
2358 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2360 // Test to select some text in the right of the current cursor position
2361 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2366 // Render and notify
2367 application.SendNotification();
2368 application.Render();
2370 // Cut the selected text
2371 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 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 ) );
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2378 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2379 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2381 // Test to select some text in the left of the current cursor position
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 // Copy the selected text
2392 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2400 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2403 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 ) );
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // replace text with "c"
2410 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2417 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2420 DevelTextEditor::SelectWholeText(editor);
2422 // Render and notify
2423 application.SendNotification();
2424 application.Render();
2426 // Copy the selected text using logical keys
2427 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2428 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2430 // Render and notify
2431 application.SendNotification();
2432 application.Render();
2435 DevelTextEditor::SelectNone(editor);
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // Paste the selected using logical keys
2442 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2446 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2448 // select all using logical keys
2449 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2450 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2452 // Render and notify
2453 application.SendNotification();
2454 application.Render();
2456 // cut text using logical keys
2457 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2458 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2460 // Render and notify
2461 application.SendNotification();
2462 application.Render();
2465 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2470 int utcDaliTextEditorEvent08(void)
2472 ToolkitTestApplication application;
2473 tet_infoline(" utcDaliTextEditorEvent08");
2475 // Checks if the highlight actor is released correctly.
2477 TextEditor editor = TextEditor::New();
2478 DALI_TEST_CHECK( editor );
2480 application.GetScene().Add( editor );
2482 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2483 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2484 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2485 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2486 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2488 // Avoid a crash when core load gl resources.
2489 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2491 // Render and notify
2492 application.SendNotification();
2493 application.Render();
2495 // Tap on the text editor
2496 TestGenerateTap( application, 3.0f, 25.0f );
2498 // Render and notify
2499 application.SendNotification();
2500 application.Render();
2502 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2503 // Test to select some text in the left of the current cursor position
2504 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2505 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2506 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2507 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Test to the left selection handle position and the right selection handle position
2514 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2515 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2516 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2517 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 // Test to select full text in the left of the current cursor position
2524 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2525 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2529 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Test to release the current full text selection
2536 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2539 // Render and notify
2540 application.SendNotification();
2541 application.Render();
2543 // Test to move the current cursor position correctly
2544 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546 // Render and notify
2547 application.SendNotification();
2548 application.Render();
2551 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553 // Render and notify
2554 application.SendNotification();
2555 application.Render();
2557 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2559 // Test to select some text in the right of the current cursor position
2560 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2561 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2562 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2564 // Render and notify
2565 application.SendNotification();
2566 application.Render();
2568 // Test the cursor position with right arrow key
2569 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2571 // Render and notify
2572 application.SendNotification();
2573 application.Render();
2576 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2578 // Render and notify
2579 application.SendNotification();
2580 application.Render();
2582 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2584 // Test to select some text in the left of the current cursor position
2585 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2586 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2587 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2588 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2589 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 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 left arrow key
2596 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 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( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2611 // Test to select some text in the right 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_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2614 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2615 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2617 // Render and notify
2618 application.SendNotification();
2619 application.Render();
2621 // Test the cursor position with left arrow key
2622 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2624 // Render and notify
2625 application.SendNotification();
2626 application.Render();
2629 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2631 // Render and notify
2632 application.SendNotification();
2633 application.Render();
2635 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2637 // Test to select some text in the left of the current cursor position
2638 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2639 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2640 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2641 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2643 // Render and notify
2644 application.SendNotification();
2645 application.Render();
2647 // Test the cursor position with right arrow key
2648 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2650 // Render and notify
2651 application.SendNotification();
2652 application.Render();
2655 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2657 // Render and notify
2658 application.SendNotification();
2659 application.Render();
2661 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2666 int utcDaliTextEditorHandles(void)
2668 ToolkitTestApplication application;
2669 tet_infoline(" utcDaliTextEditorHandles");
2671 TextEditor editor = TextEditor::New();
2672 DALI_TEST_CHECK( editor );
2674 application.GetScene().Add( editor );
2676 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2677 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2678 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2679 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2681 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2682 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2683 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2684 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2686 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2687 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2688 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2690 // Avoid a crash when core load gl resources.
2691 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2693 // Render and notify
2694 application.SendNotification();
2695 application.Render();
2697 // Tap first to get the focus.
2698 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2700 // Render and notify
2701 application.SendNotification();
2702 application.Render();
2704 // Tap to create the grab handle.
2705 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2707 // Render and notify
2708 application.SendNotification();
2709 application.Render();
2711 // Get the active layer where the text's decoration is added.
2712 Actor activeLayer = editor.GetChildAt( 1u );
2714 // Get the handle's actor.
2715 Actor handle = activeLayer.GetChildAt( 1u );
2716 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2718 // Render and notify
2719 application.SendNotification();
2720 application.Render();
2722 // Touch the grab handle to set it as pressed.
2723 Vector2 touchPos( 10.0f, 50.0f );
2724 Dali::Integration::TouchEvent event;
2725 event = Dali::Integration::TouchEvent();
2726 event.AddPoint( GetPointDownInside( touchPos ) );
2727 application.ProcessEvent( event );
2729 // Render and notify
2730 application.SendNotification();
2731 application.Render();
2733 // Pan the grab handle
2734 uint32_t time = 100;
2735 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2736 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2737 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2738 application.SendNotification();
2739 application.Render();
2742 // Release the grab handle.
2743 event = Dali::Integration::TouchEvent();
2744 event.AddPoint( GetPointUpInside( touchPos ) );
2745 application.ProcessEvent( event );
2747 // Render and notify
2748 application.SendNotification();
2749 application.Render();
2751 // Tap first to get the focus.
2752 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2754 // Render and notify
2755 application.SendNotification();
2756 application.Render();
2758 // Double tap to select a word and create the selection handles.
2759 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2761 // Render and notify
2762 application.SendNotification();
2763 application.Render();
2765 touchPos = Vector2( 10.0f, 50.0f );
2767 // Touch the left selection handle to set it as pressed.
2768 event = Dali::Integration::TouchEvent();
2769 event.AddPoint( GetPointDownInside( touchPos ) );
2770 application.ProcessEvent( event );
2772 // Render and notify
2773 application.SendNotification();
2774 application.Render();
2776 // Release the left selection handle.
2777 event = Dali::Integration::TouchEvent();
2778 event.AddPoint( GetPointUpInside( touchPos ) );
2779 application.ProcessEvent( event );
2781 // Render and notify
2782 application.SendNotification();
2783 application.Render();
2788 int utcDaliTextEditorUnderPropertyStringP(void)
2790 ToolkitTestApplication application;
2791 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2792 TextEditor editor = TextEditor::New();
2793 DALI_TEST_CHECK( editor );
2795 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2797 application.GetScene().Add( editor );
2799 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2800 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2802 tet_infoline("Set underline settings with a map");
2803 // Check the input underline property
2804 Property::Map underlineMapSet;
2805 Property::Map underlineMapGet;
2806 underlineMapSet.Insert( "enable", true );
2807 underlineMapSet.Insert( "color", Color::BLUE );
2808 underlineMapSet.Insert( "height", 2 );
2810 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2811 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2812 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2813 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2815 tet_infoline("Set underline settings with a string");
2816 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2817 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2820 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2822 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2823 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2824 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2825 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2827 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2832 int utcDaliTextEditorShadowPropertyStringP(void)
2834 ToolkitTestApplication application;
2835 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2837 TextEditor editor = TextEditor::New();
2839 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2841 application.GetScene().Add( editor );
2843 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2845 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2849 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2854 int utcDaliTextEditorFontStylePropertyStringP(void)
2856 ToolkitTestApplication application;
2857 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2859 TextEditor editor = TextEditor::New();
2861 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2863 application.GetScene().Add( editor );
2865 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2867 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2871 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2876 int utcDaliTextEditorGetPropertyLinecountP(void)
2878 ToolkitTestApplication application;
2880 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2884 TextEditor editor = TextEditor::New();
2885 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2886 editor.SetProperty( TextEditor::Property::TEXT,
2887 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2889 application.GetScene().Add( editor );
2891 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2892 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2893 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2895 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2896 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2897 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2902 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2905 ToolkitTestApplication application;
2906 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2908 TextEditor editor = TextEditor::New();
2909 DALI_TEST_CHECK( editor );
2911 application.GetScene().Add( editor );
2913 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2914 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2915 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2916 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2917 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2918 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2920 bool startedCalled = false;
2921 bool finishedCalled = false;
2923 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2924 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2926 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2928 // Render and notify
2929 application.SendNotification();
2930 application.Render();
2932 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2933 application.SendNotification();
2934 application.Render(6000);
2936 application.SendNotification();
2937 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2938 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2943 int UtcDaliToolkitTextEditorTextWrapMode(void)
2945 ToolkitTestApplication application;
2946 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2950 TextEditor editor = TextEditor::New();
2951 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2952 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2954 application.GetScene().Add( editor );
2956 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2957 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2959 application.SendNotification();
2960 application.Render();
2962 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2963 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2965 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2966 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2968 application.SendNotification();
2969 application.Render();
2971 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2972 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2974 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2975 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2977 application.SendNotification();
2978 application.Render();
2980 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2981 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2983 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2984 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2986 application.SendNotification();
2987 application.Render();
2989 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2990 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2995 int UtcDaliTextEditorSetPaddingProperty(void)
2997 ToolkitTestApplication application;
2998 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
3000 TextEditor editor = TextEditor::New();
3001 DALI_TEST_CHECK( editor );
3002 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3003 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3004 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3005 application.GetScene().Add( editor );
3007 application.SendNotification();
3008 application.Render();
3010 Vector3 originalSize = editor.GetNaturalSize();
3012 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3014 application.SendNotification();
3015 application.Render();
3017 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3019 Vector3 paddingAddedSize = editor.GetNaturalSize();
3021 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3023 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3028 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3030 ToolkitTestApplication application;
3031 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3033 TextEditor editor = TextEditor::New();
3034 DALI_TEST_CHECK( editor );
3035 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3036 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3037 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3038 application.GetScene().Add( editor );
3040 application.SendNotification();
3041 application.Render();
3043 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3044 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3046 // Check the enable shift selection property
3047 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3048 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3050 application.SendNotification();
3051 application.Render();
3056 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3058 ToolkitTestApplication application;
3059 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3061 TextEditor editor = TextEditor::New();
3062 DALI_TEST_CHECK( editor );
3063 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3064 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3065 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3066 application.GetScene().Add( editor );
3068 application.SendNotification();
3069 application.Render();
3071 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3072 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3074 // Check the enable grab handle property
3075 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3076 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3078 application.SendNotification();
3079 application.Render();
3084 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3086 ToolkitTestApplication application;
3087 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3089 TextEditor editor = TextEditor::New();
3090 DALI_TEST_CHECK( editor );
3091 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3092 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3093 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3094 application.GetScene().Add( editor );
3096 application.SendNotification();
3097 application.Render();
3099 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3100 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3102 // Check the disable match system language direction property
3103 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3104 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3106 application.SendNotification();
3107 application.Render();
3112 int UtcDaliTextEditorGetInputMethodContext(void)
3114 ToolkitTestApplication application;
3115 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3117 TextEditor editor = TextEditor::New();
3118 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3123 int utcDaliTextEditorMaxCharactersReached(void)
3125 ToolkitTestApplication application;
3126 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3128 TextEditor editor = TextEditor::New();
3129 DALI_TEST_CHECK( editor );
3131 application.GetScene().Add( editor );
3133 const int maxNumberOfCharacters = 1;
3134 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3135 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3137 editor.SetKeyInputFocus();
3139 // connect to the text changed signal.
3140 ConnectionTracker* testTracker = new ConnectionTracker();
3141 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3142 bool maxLengthReachedSignal = false;
3143 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3145 gMaxCharactersCallBackCalled = false;
3147 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3148 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3150 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3151 DALI_TEST_CHECK( maxLengthReachedSignal );
3156 int utcDaliTextEditorInputFiltered(void)
3158 ToolkitTestApplication application;
3159 tet_infoline(" utcDaliTextEditorInputFiltered");
3160 TextEditor editor = TextEditor::New();
3161 DALI_TEST_CHECK(editor);
3163 application.GetScene().Add(editor);
3165 Property::Map inputFilter;
3167 // Only digit is accepted.
3168 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3170 // Set input filter to TextEditor.
3171 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3173 editor.SetKeyInputFocus();
3175 // connect to the input filtered signal.
3176 ConnectionTracker* testTracker = new ConnectionTracker();
3177 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3178 bool inputFilteredSignal = false;
3179 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3181 gInputFilteredAcceptedCallbackCalled = false;
3183 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3185 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3186 DALI_TEST_CHECK(inputFilteredSignal);
3188 // Word is rejected.
3189 inputFilter[InputFilter::Property::ACCEPTED] = "";
3190 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3192 // Set input filter to TextEditor.
3193 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3195 editor.SetKeyInputFocus();
3197 inputFilteredSignal = false;
3198 gInputFilteredRejectedCallbackCalled = false;
3200 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3202 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3203 DALI_TEST_CHECK(inputFilteredSignal);
3208 int UtcDaliTextEditorSelectWholeText(void)
3210 ToolkitTestApplication application;
3211 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3213 TextEditor textEditor = TextEditor::New();
3215 application.GetScene().Add( textEditor );
3217 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3218 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3219 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3221 // Avoid a crash when core load gl resources.
3222 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3224 application.SendNotification();
3225 application.Render();
3227 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3229 DevelTextEditor::SelectWholeText( textEditor );
3231 application.SendNotification();
3232 application.Render();
3234 // Nothing should have been selected. The number of children is still 1
3235 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3237 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3239 application.SendNotification();
3240 application.Render();
3242 DevelTextEditor::SelectWholeText( textEditor );
3244 application.SendNotification();
3245 application.Render();
3247 // Should be 2 children, the stencil and the layer
3248 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3250 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3251 Actor stencil = textEditor.GetChildAt( 0u );
3253 // The highlight actor is drawn first, so is the first actor in the list
3254 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3255 DALI_TEST_CHECK( highlight );
3260 int UtcDaliTextEditorSelectText(void)
3262 ToolkitTestApplication application;
3263 tet_infoline(" UtcDaliTextEditorSelectText ");
3265 TextEditor textEditor = TextEditor::New();
3267 application.GetScene().Add( textEditor );
3269 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3270 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3271 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3273 // Avoid a crash when core load gl resources.
3274 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3276 application.SendNotification();
3277 application.Render();
3279 DevelTextEditor::SelectText( textEditor ,0, 5 );
3281 application.SendNotification();
3282 application.Render();
3284 // Nothing is selected
3285 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3286 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3288 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3290 application.SendNotification();
3291 application.Render();
3293 DevelTextEditor::SelectText( textEditor, 0, 5 );
3295 application.SendNotification();
3296 application.Render();
3298 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3299 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3301 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3302 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3304 // world is selected
3305 DevelTextEditor::SelectText( textEditor, 6, 11 );
3307 application.SendNotification();
3308 application.Render();
3310 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3311 DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3313 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3314 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3319 int UtcDaliTextEditorSelectNone(void)
3321 ToolkitTestApplication application;
3322 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3324 TextEditor textEditor = TextEditor::New();
3326 application.GetScene().Add( textEditor );
3328 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3329 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3330 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3332 // Avoid a crash when core load gl resources.
3333 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3335 application.SendNotification();
3336 application.Render();
3338 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3340 application.SendNotification();
3341 application.Render();
3343 // Nothing is selected
3344 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3345 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3347 DevelTextEditor::SelectWholeText( textEditor );
3349 application.SendNotification();
3350 application.Render();
3352 // whole text is selected
3353 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3354 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3356 DevelTextEditor::SelectNone( textEditor );
3358 application.SendNotification();
3359 application.Render();
3361 // Nothing is selected
3362 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3363 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3368 int UtcDaliTextEditorSelectRange(void)
3370 ToolkitTestApplication application;
3371 tet_infoline("utcDaliTextEditorSelectRange");
3373 TextEditor textEditor = TextEditor::New();
3374 DALI_TEST_CHECK( textEditor );
3376 application.GetScene().Add( textEditor );
3378 // Avoid a crash when core load gl resources.
3379 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3381 application.SendNotification();
3382 application.Render();
3384 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3386 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3387 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3389 // Hello is selected
3390 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3391 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3393 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3394 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3399 int UtcDaliTextEditorEnableEditing(void)
3401 ToolkitTestApplication application;
3402 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3404 TextEditor textEditor = TextEditor::New();
3406 application.GetScene().Add( textEditor );
3408 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3409 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3410 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3412 // Avoid a crash when core load gl resources.
3413 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3415 application.SendNotification();
3416 application.Render();
3418 textEditor.SetKeyInputFocus();
3419 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3420 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3422 // Render and notify
3423 application.SendNotification();
3424 application.Render();
3426 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3427 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3429 textEditor.SetKeyInputFocus();
3430 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3431 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3433 // Render and notify
3434 application.SendNotification();
3435 application.Render();
3437 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3438 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3443 int UtcDaliTextEditorScrolling(void)
3445 ToolkitTestApplication application;
3446 tet_infoline(" UtcDaliTextEditorScrolling ");
3448 TextEditor textEditor = TextEditor::New();
3449 DALI_TEST_CHECK( textEditor );
3451 application.GetScene().Add( textEditor );
3453 // Avoid a crash when core load gl resources.
3454 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3456 application.SendNotification();
3457 application.Render();
3459 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3460 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3461 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3462 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3464 application.SendNotification();
3465 application.Render();
3467 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3468 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3471 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3473 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3474 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3476 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3478 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3479 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3481 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3482 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3484 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3485 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3490 int UtcDaliToolkitTextEditorFontSizeScale(void)
3492 ToolkitTestApplication application;
3493 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3495 TextEditor textEditor = TextEditor::New();
3496 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3497 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3498 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3500 TextEditor textEditorScaled = TextEditor::New();
3501 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3502 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3503 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3504 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3506 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3508 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3509 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3510 nonScaledSize = textEditor.GetNaturalSize();
3512 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3513 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3514 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3515 scaledSize = textEditorScaled.GetNaturalSize();
3517 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3522 int UtcDaliTextEditorPrimaryCursorPosition(void)
3524 ToolkitTestApplication application;
3525 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3527 TextEditor textEditor = TextEditor::New();
3529 application.GetScene().Add( textEditor );
3531 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3532 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3533 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3534 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3536 // Avoid a crash when core load gl resources.
3537 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3539 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3540 application.SendNotification();
3541 application.Render();
3542 textEditor.SetKeyInputFocus();
3544 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3546 // Render and notify
3547 application.SendNotification();
3548 application.Render();
3550 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3551 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3556 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3558 ToolkitTestApplication application;
3559 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3561 TextEditor textEditor = TextEditor::New();
3562 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3563 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3564 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3565 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3566 application.GetScene().Add( textEditor );
3568 application.SendNotification();
3569 application.Render();
3572 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3573 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3575 textEditor.GetNaturalSize();
3577 // Create a tap event to touch the text editor.
3578 TestGenerateTap( application, 18.0f, 25.0f );
3580 application.SendNotification();
3581 application.Render();
3583 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3584 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3590 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3592 ToolkitTestApplication application;
3594 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3596 int lineCountBefore =0 ;
3597 int lineCountAfter =0 ;
3599 // Create a text editor
3600 TextEditor textEditor = TextEditor::New();
3601 //Set very large font-size using point-size
3602 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3603 //Specify font-family
3604 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3606 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3607 //Set text longer than width of textEditor
3608 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3610 application.GetScene().Add( textEditor );
3612 application.SendNotification();
3613 application.Render();
3615 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3616 //GetHeightForWidth is a retrieval method which should not modify object
3617 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3618 textEditor.GetHeightForWidth(200.f);
3620 //This is to simulate focus into text editor after calling GetHeightForWidth
3621 //Create a tap event to touch the text editor.
3622 TestGenerateTap( application, 18.0f, 25.0f );
3624 application.SendNotification();
3625 application.Render();
3627 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3629 //The LineCount must not be changed when calling GetHeightForWidth.
3630 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3635 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3637 ToolkitTestApplication application;
3639 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3641 int lineCountBefore =0 ;
3642 int lineCountAfter =0 ;
3644 // Create a text editor
3645 TextEditor textEditor = TextEditor::New();
3646 //Set very large font-size using point-size
3647 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3648 //Specify font-family
3649 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3651 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3652 //Set text longer than width of textEditor
3653 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3654 //Set line wrap mode Character
3655 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3657 application.GetScene().Add( textEditor );
3659 application.SendNotification();
3660 application.Render();
3662 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3663 //GetHeightForWidth is a retrieval method which should not modify object
3664 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3665 textEditor.GetHeightForWidth(200.f);
3667 //This is to simulate focus into text editor after calling GetHeightForWidth
3668 //Create a tap event to touch the text editor.
3669 TestGenerateTap( application, 18.0f, 25.0f );
3671 application.SendNotification();
3672 application.Render();
3674 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3676 //The LineCount must not be changed when calling GetHeightForWidth.
3677 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3682 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3684 ToolkitTestApplication application;
3686 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3688 int lineCountBefore =0 ;
3689 int lineCountAfter =0 ;
3691 // Create a text editor
3692 TextEditor textEditor = TextEditor::New();
3693 //Set very large font-size using point-size
3694 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3695 //Specify font-family
3696 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3698 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3699 //Set text longer than width of textEditor
3700 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3701 //Set line wrap mode Character
3702 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3704 application.GetScene().Add( textEditor );
3706 application.SendNotification();
3707 application.Render();
3710 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3712 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3713 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3715 // When the text changed, the Line-count should be updated according to new text.
3716 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3717 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3718 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3725 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3727 ToolkitTestApplication application;
3729 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3731 int lineCountBefore =0 ;
3732 int lineCountAfter =0 ;
3734 // Create a text editor
3735 TextEditor textEditor = TextEditor::New();
3736 //Set very large font-size using point-size
3737 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3738 //Specify font-family
3739 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3741 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3742 //Set text longer than width of textEditor
3743 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3745 application.GetScene().Add( textEditor );
3747 application.SendNotification();
3748 application.Render();
3750 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3751 //GetNaturalSize is a retrieval method which should not modify object
3752 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3753 textEditor.GetNaturalSize();
3755 //This is to simulate focus into text editor after calling GetNaturalSize
3756 //Create a tap event to touch the text editor.
3757 TestGenerateTap( application, 18.0f, 25.0f );
3759 application.SendNotification();
3760 application.Render();
3762 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3764 //The LineCount must not be changed when calling GetNaturalSize.
3765 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3770 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3772 ToolkitTestApplication application;
3774 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3776 int lineCountBefore =0 ;
3777 int lineCountAfter =0 ;
3779 // Create a text editor
3780 TextEditor textEditor = TextEditor::New();
3781 //Set very large font-size using point-size
3782 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3783 //Specify font-family
3784 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3786 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3787 //Set text longer than width of textEditor
3788 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3789 //Set line wrap mode Character
3790 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3792 application.GetScene().Add( textEditor );
3794 application.SendNotification();
3795 application.Render();
3797 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3798 //GetNaturalSize is a retrieval method which should not modify object
3799 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3800 textEditor.GetNaturalSize( );
3802 //This is to simulate focus into text editor after calling GetNaturalSize
3803 //Create a tap event to touch the text editor.
3804 TestGenerateTap( application, 18.0f, 25.0f );
3806 application.SendNotification();
3807 application.Render();
3809 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3811 //The LineCount must not be changed when calling GetNaturalSize.
3812 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3817 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3819 ToolkitTestApplication application;
3820 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3822 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3823 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3824 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3826 // Create a text editor
3827 TextEditor textEditor = TextEditor::New();
3829 //Set size to avoid automatic eliding
3830 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3831 //Set very large font-size using point-size
3832 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3833 //Specify font-family
3834 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3835 //Set text to check if appear or not
3836 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3838 application.GetScene().Add( textEditor );
3840 application.SendNotification();
3841 application.Render();
3842 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3843 Vector3 naturalSize = textEditor.GetNaturalSize();
3845 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3846 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3851 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3853 ToolkitTestApplication application;
3854 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3856 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3857 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3858 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3860 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3861 // Create a text editor
3862 TextEditor textEditor = TextEditor::New();
3863 //Set size to avoid automatic eliding
3864 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3865 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3866 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3868 const int numberOfCases = 6;
3869 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3871 for (int index=0; index < numberOfCases; index++)
3873 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3874 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3875 application.GetScene().Add( textEditor );
3876 application.SendNotification();
3877 application.Render();
3878 naturalSize = textEditor.GetNaturalSize();
3879 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3880 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3887 int UtcDaliTextEditorHyphenWrapMode(void)
3889 ToolkitTestApplication application;
3890 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3893 TextEditor textEditor = TextEditor::New();
3895 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3897 application.GetScene().Add( textEditor );
3898 application.SendNotification();
3899 application.Render();
3901 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3902 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3903 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3905 application.SendNotification();
3906 application.Render();
3908 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3914 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3916 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3917 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3918 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3920 application.SendNotification();
3921 application.Render();
3923 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3930 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3935 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
3937 ToolkitTestApplication application;
3938 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
3939 TextEditor textEditor = TextEditor::New();
3941 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
3942 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3944 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
3945 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3946 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3948 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
3949 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3950 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3952 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
3953 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3954 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3956 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
3957 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
3958 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3960 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
3961 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
3962 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3964 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
3965 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
3966 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3968 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3969 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
3970 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3972 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3973 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
3974 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3976 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3977 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
3978 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3980 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3981 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
3982 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3984 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3985 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
3986 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3988 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3989 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
3990 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3995 int UtcDaliTextEditorLineSpacing(void)
3997 ToolkitTestApplication application;
3998 tet_infoline(" UtcDaliTextEditorLineSpacing ");
4000 TextEditor textEditor = TextEditor::New();
4001 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4002 application.GetScene().Add( textEditor );
4003 application.SendNotification();
4004 application.Render();
4006 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4007 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 0 );
4009 Vector3 sizeBefore = textEditor.GetNaturalSize();
4011 textEditor.SetProperty( DevelTextEditor::Property::LINE_SPACING, 20 );
4013 //add 20 for each line 20 * 3
4014 DALI_TEST_EQUALS(sizeBefore.height + 60.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4019 int UtcDaliTextEditorMinLineSize(void)
4021 ToolkitTestApplication application;
4022 tet_infoline(" UtcDaliTextEditorMinLineSize ");
4024 TextEditor textEditor = TextEditor::New();
4025 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 400.f ) );
4026 application.GetScene().Add( textEditor );
4027 application.SendNotification();
4028 application.Render();
4030 textEditor.SetProperty( TextEditor::Property::TEXT, "Line #1\nLine #2\nLine #3" );
4031 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 0 );
4033 Vector3 sizeBefore = textEditor.GetNaturalSize();
4035 textEditor.SetProperty( DevelTextEditor::Property::MIN_LINE_SIZE, 60 );
4037 DALI_TEST_NOT_EQUALS( sizeBefore, textEditor.GetNaturalSize(), 0.0f, TEST_LOCATION);
4040 DALI_TEST_EQUALS(180.0f, textEditor.GetNaturalSize().height, TEST_LOCATION);
4045 int utcDaliTextEditorCursorPositionChangedSignal(void)
4047 ToolkitTestApplication application;
4048 tet_infoline(" utcDaliTextEditorCursorPositionChangedSignal");
4050 TextEditor editor = TextEditor::New();
4051 DALI_TEST_CHECK( editor );
4053 application.GetScene().Add( editor );
4055 // connect to the selection changed signal.
4056 ConnectionTracker* testTracker = new ConnectionTracker();
4057 DevelTextEditor::CursorPositionChangedSignal(editor).Connect(&TestCursorPositionChangedCallback);
4058 bool cursorPositionChangedSignal = false;
4059 editor.ConnectSignal( testTracker, "cursorPositionChanged", CallbackFunctor(&cursorPositionChangedSignal) );
4061 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
4062 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
4063 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4064 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4065 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4067 // Avoid a crash when core load gl resources.
4068 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4070 // Render and notify
4071 application.SendNotification();
4072 application.Render();
4074 editor.SetKeyInputFocus();
4076 // Tap on the text editor
4077 TestGenerateTap( application, 3.0f, 25.0f );
4079 // Render and notify
4080 application.SendNotification();
4081 application.Render();
4083 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4084 DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4086 gCursorPositionChangedCallbackCalled = false;
4089 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4091 // Render and notify
4092 application.SendNotification();
4093 application.Render();
4095 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4096 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4098 gCursorPositionChangedCallbackCalled = false;
4101 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4103 // Render and notify
4104 application.SendNotification();
4105 application.Render();
4107 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4108 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4110 gCursorPositionChangedCallbackCalled = false;
4112 //delete one character
4113 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4115 // Render and notify
4116 application.SendNotification();
4117 application.Render();
4119 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4120 DALI_TEST_EQUALS(oldCursorPos, 18, TEST_LOCATION);
4122 gCursorPositionChangedCallbackCalled = false;
4124 editor.SetProperty( TextEditor::Property::TEXT, "Hello" );
4126 // Render and notify
4127 application.SendNotification();
4128 application.Render();
4130 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4131 DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4133 gCursorPositionChangedCallbackCalled = false;
4135 editor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
4137 // Render and notify
4138 application.SendNotification();
4139 application.Render();
4141 DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4142 DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);