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 Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
145 struct CallbackFunctor
147 CallbackFunctor(bool* callbackFlag)
148 : mCallbackFlag( callbackFlag )
154 *mCallbackFlag = true;
159 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
161 tet_infoline(" TestAnchorClickedCallback");
163 gAnchorClickedCallBackNotCalled = false;
165 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
167 gAnchorClickedCallBackCalled = true;
171 static void TestTextChangedCallback( TextEditor control )
173 tet_infoline(" TestTextChangedCallback");
175 gTextChangedCallBackCalled = true;
178 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
180 tet_infoline(" TestInputStyleChangedCallback");
182 gInputStyleChangedCallbackCalled = true;
183 gInputStyleMask = mask;
186 static void TestMaxLengthReachedCallback( TextEditor control )
188 tet_infoline(" TestMaxLengthReachedCallback");
190 gMaxCharactersCallBackCalled = true;
193 static void TestInputFilteredCallback(TextEditor control, Toolkit::InputFilter::Property::Type type)
195 tet_infoline(" TestInputFilteredCallback");
197 if(type == Toolkit::InputFilter::Property::ACCEPTED)
199 gInputFilteredAcceptedCallbackCalled = true;
201 else if(type == Toolkit::InputFilter::Property::REJECTED)
203 gInputFilteredRejectedCallbackCalled = true;
207 // Generate a KeyEvent to send to Core.
208 Integration::KeyEvent GenerateKey( const std::string& keyName,
209 const std::string& logicalKey,
210 const std::string& keyString,
213 unsigned long timeStamp,
214 const Integration::KeyEvent::State& keyState,
215 const std::string& compose = "",
216 const std::string& deviceName = DEFAULT_DEVICE_NAME,
217 const Device::Class::Type& deviceClass = Device::Class::NONE,
218 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
220 return Integration::KeyEvent( keyName,
233 Dali::Integration::Point GetPointDownInside( Vector2& pos )
235 Dali::Integration::Point point;
236 point.SetState( PointState::DOWN );
237 point.SetScreenPosition( pos );
241 Dali::Integration::Point GetPointUpInside( Vector2& pos )
243 Dali::Integration::Point point;
244 point.SetState( PointState::UP );
245 point.SetScreenPosition( pos );
249 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
251 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
253 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
255 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
257 Property::Value* valueSet = NULL;
258 if ( valueGet.first.type == Property::Key::INDEX )
260 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
264 // Get Key is a string so searching Set Map for a string key
265 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
268 if( NULL != valueSet )
270 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
272 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
275 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
277 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
280 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
282 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
285 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
287 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
290 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
292 Vector2 vector2Get = valueGet.second.Get<Vector2>();
293 Vector2 vector2Set = valueSet->Get<Vector2>();
294 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
297 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
299 Vector4 vector4Get = valueGet.second.Get<Vector4>();
300 Vector4 vector4Set = valueSet->Get<Vector4>();
301 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 );
307 if ( valueGet.first.type == Property::Key::INDEX )
309 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
313 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
323 class ScrollStateChangeCallback : public Dali::ConnectionTracker
326 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
327 : mStartedCalled( startedCalled ),
328 mFinishedCalled( finishedCalled )
332 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
334 if( type == TextEditor::Scroll::STARTED )
336 mStartedCalled = true;
338 else if( type == TextEditor::Scroll::FINISHED )
340 mFinishedCalled = true;
344 bool& mStartedCalled;
345 bool& mFinishedCalled;
350 int UtcDaliToolkitTextEditorConstructorP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
354 TextEditor textEditor;
355 DALI_TEST_CHECK( !textEditor );
359 int UtcDaliToolkitTextEditorNewP(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitTextEditorNewP");
363 TextEditor textEditor = TextEditor::New();
364 DALI_TEST_CHECK( textEditor );
368 int UtcDaliToolkitTextEditorDownCastP(void)
370 ToolkitTestApplication application;
371 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
372 TextEditor textEditor1 = TextEditor::New();
373 BaseHandle object( textEditor1 );
375 TextEditor textEditor2 = TextEditor::DownCast( object );
376 DALI_TEST_CHECK( textEditor2 );
378 TextEditor textEditor3 = DownCast< TextEditor >( object );
379 DALI_TEST_CHECK( textEditor3 );
383 int UtcDaliToolkitTextEditorDownCastN(void)
385 ToolkitTestApplication application;
386 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
387 BaseHandle uninitializedObject;
388 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
389 DALI_TEST_CHECK( !textEditor1 );
391 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
392 DALI_TEST_CHECK( !textEditor2 );
396 int UtcDaliToolkitTextEditorCopyConstructorP(void)
398 ToolkitTestApplication application;
399 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
400 TextEditor textEditor = TextEditor::New();
401 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
403 TextEditor copy( textEditor );
404 DALI_TEST_CHECK( copy );
405 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
409 int UtcDaliTextEditorMoveConstructor(void)
411 ToolkitTestApplication application;
413 TextEditor textEditor = TextEditor::New();
414 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
415 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
417 TextEditor moved = std::move( textEditor );
418 DALI_TEST_CHECK( moved );
419 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
420 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
421 DALI_TEST_CHECK( !textEditor );
426 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
428 ToolkitTestApplication application;
429 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
430 TextEditor textEditor = TextEditor::New();
431 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
433 TextEditor copy = textEditor;
434 DALI_TEST_CHECK( copy );
435 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
439 int UtcDaliTextEditorMoveAssignment(void)
441 ToolkitTestApplication application;
443 TextEditor textEditor = TextEditor::New();
444 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
445 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
448 moved = std::move( textEditor );
449 DALI_TEST_CHECK( moved );
450 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
451 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
452 DALI_TEST_CHECK( !textEditor );
457 int UtcDaliTextEditorNewP(void)
459 ToolkitTestApplication application;
460 tet_infoline(" UtcDaliToolkitTextEditorNewP");
461 TextEditor textEditor = TextEditor::New();
462 DALI_TEST_CHECK( textEditor );
466 // Positive test case for a method
467 int UtcDaliTextEditorGetPropertyP(void)
469 ToolkitTestApplication application;
470 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
471 TextEditor editor = TextEditor::New();
472 DALI_TEST_CHECK( editor );
474 // Check Property Indices are correct
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextEditor::Property::INPUT_FILTER );
540 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
543 Property::Map imageMap;
544 imageMap[mapKey] =mapValue;
546 editor.SetProperty( property , imageMap );
547 Property::Value propValue = editor.GetProperty( property );
548 Property::Map* resultMap = propValue.GetMap();
550 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
558 // Positive test case for a method
559 int UtcDaliTextEditorSetPropertyP(void)
561 ToolkitTestApplication application;
562 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
563 TextEditor editor = TextEditor::New();
564 DALI_TEST_CHECK( editor );
565 application.GetScene().Add( editor );
567 // Note - we can't check the defaults since the stylesheets are platform-specific
569 // Check the render backend property.
570 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
571 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
573 // Check text property.
574 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
575 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
577 // Check text's color property
578 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
579 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
581 // Check font properties.
582 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
583 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
585 Property::Map fontStyleMapSet;
586 Property::Map fontStyleMapGet;
587 Property::Value* slantValue = NULL;
589 fontStyleMapSet.Insert( "weight", "bold" );
590 fontStyleMapSet.Insert( "width", "condensed" );
591 fontStyleMapSet.Insert( "slant", "italic" );
593 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
594 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
595 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
596 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
598 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
599 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
601 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
602 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
603 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
606 fontStyleMapSet.Clear();
607 fontStyleMapSet.Insert( "weight", "normal" );
608 fontStyleMapSet.Insert( "slant", "oblique" );
609 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
610 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
611 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
612 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
614 fontStyleMapSet.Clear();
615 fontStyleMapSet.Insert( "slant", "roman" );
616 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
617 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
619 // Replace 'roman' for 'normal'.
620 slantValue = fontStyleMapGet.Find( "slant" );
621 if( NULL != slantValue )
623 if( "normal" == slantValue->Get<std::string>() )
625 fontStyleMapGet["slant"] = "roman";
628 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
629 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
631 fontStyleMapSet.Clear();
633 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
634 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
635 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
636 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
638 // Check that the Alignment properties can be correctly set
639 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
640 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
642 // Check scroll properties.
643 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
644 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
645 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
646 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
648 // Check cursor properties
649 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
650 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
651 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
652 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
654 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
655 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
656 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
657 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
658 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
659 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
660 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
661 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
663 // Check handle images
664 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
665 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
666 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
667 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
668 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
670 // Check handle images
671 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
672 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
678 // Check the highlight color
679 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
680 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
682 // Decoration bounding box
683 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
684 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
686 // Check the enable markup property.
687 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
688 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
689 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
691 // Check input color property.
692 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
693 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
695 // Check input font properties.
696 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
697 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
699 fontStyleMapSet.Clear();
700 fontStyleMapSet.Insert( "weight", "bold" );
701 fontStyleMapSet.Insert( "width", "condensed" );
702 fontStyleMapSet.Insert( "slant", "italic" );
704 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
705 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
706 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
707 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
709 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
710 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
712 // Reset input font style.
713 fontStyleMapSet.Clear();
714 fontStyleMapSet.Insert( "weight", "normal" );
715 fontStyleMapSet.Insert( "slant", "oblique" );
717 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
718 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
719 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
720 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
722 fontStyleMapSet.Clear();
723 fontStyleMapSet.Insert( "slant", "roman" );
725 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
726 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
728 // Replace 'roman' for 'normal'.
729 slantValue = fontStyleMapGet.Find( "slant" );
730 if( NULL != slantValue )
732 if( "normal" == slantValue->Get<std::string>() )
734 fontStyleMapGet["slant"] = "roman";
737 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
738 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
740 fontStyleMapSet.Clear();
742 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
743 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
744 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
745 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
747 // Check the line spacing property
748 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
749 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
750 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
752 // Check the input line spacing property
753 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
755 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
757 // Check the underline property
759 Property::Map underlineMapSet;
760 Property::Map underlineMapGet;
762 underlineMapSet.Insert( "enable", true );
763 underlineMapSet.Insert( "color", Color::RED );
764 underlineMapSet.Insert( "height", 1 );
766 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
768 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
769 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
770 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
772 // Check the input underline property
773 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
774 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
776 // Check the shadow property
777 Property::Map shadowMapSet;
778 Property::Map shadowMapGet;
780 shadowMapSet.Insert( "color", Color::GREEN );
781 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
782 shadowMapSet.Insert( "blurRadius", 3.0f );
784 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
786 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
787 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
788 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
790 // Check the input shadow property
791 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
792 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
794 // Check the emboss property
795 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
796 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
798 // Check the input emboss property
799 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
800 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
802 // Check the outline property
804 // Test string type first
805 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
806 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
807 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
809 // Then test the property map type
810 Property::Map outlineMapSet;
811 Property::Map outlineMapGet;
813 outlineMapSet["color"] = Color::RED;
814 outlineMapSet["width"] = 2.0f;
816 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
818 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
819 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
820 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
822 // Check the input outline property
823 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
824 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
826 // Check the smooth scroll property
827 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
828 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
829 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
831 // Check the smooth scroll duration property
832 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
833 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
835 // Check the scroll bar property
836 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
837 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
838 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
840 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
841 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
842 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
843 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
845 // Check the pixel size of font
846 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
847 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
849 // Check placeholder text properties.
850 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
851 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
853 // Check placeholder text's color property.
854 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
855 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
857 // Check the enable selection property
858 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
859 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
861 // Check the placeholder property with pixel size
862 Property::Map placeholderPixelSizeMapSet;
863 Property::Map placeholderPixelSizeMapGet;
864 Property::Map placeholderFontstyleMap;
865 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
866 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
867 placeholderPixelSizeMapSet["color"] = Color::BLUE;
868 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
869 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
871 placeholderFontstyleMap.Insert( "weight", "bold" );
872 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
873 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
875 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
876 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
878 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
879 Property::Map placeholderConversionMap;
880 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
882 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
883 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
884 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
885 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
887 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
889 // Check the placeholder property with point size
890 Property::Map placeholderMapSet;
891 Property::Map placeholderMapGet;
892 placeholderMapSet["text"] = "Setting Placeholder Text";
893 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
894 placeholderMapSet["color"] = Color::RED;
895 placeholderMapSet["fontFamily"] = "Arial";
896 placeholderMapSet["pointSize"] = 12.0f;
897 // Check the placeholder font style property
898 placeholderFontstyleMap.Clear();
900 placeholderFontstyleMap.Insert( "weight", "bold" );
901 placeholderFontstyleMap.Insert( "width", "condensed" );
902 placeholderFontstyleMap.Insert( "slant", "italic" );
903 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
904 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
906 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
907 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
909 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
910 placeholderConversionMap.Clear();
911 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
912 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
913 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
916 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
917 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
920 placeholderFontstyleMap.Clear();
921 placeholderFontstyleMap.Insert( "weight", "normal" );
922 placeholderFontstyleMap.Insert( "slant", "oblique" );
923 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
924 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
926 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
927 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
928 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
929 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
931 placeholderFontstyleMap.Clear();
932 placeholderFontstyleMap.Insert( "slant", "roman" );
933 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
934 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
936 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
938 placeholderFontstyleMap.Clear();
939 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
941 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
942 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
943 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
944 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
945 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
947 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
948 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
950 // Check handle color
951 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
952 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
954 // Test the ENABLE_GRAB_HANDLE_POPUP property
955 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
956 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
958 // Check the input method setting
959 Property::Map propertyMap;
960 InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
961 InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
962 InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
963 int inputVariation = 1;
964 propertyMap["PANEL_LAYOUT"] = panelLayout;
965 propertyMap["AUTO_CAPITALIZE"] = autoCapital;
966 propertyMap["BUTTON_ACTION"] = buttonAction;
967 propertyMap["VARIATION"] = inputVariation;
968 editor.SetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS, propertyMap );
970 Property::Value value = editor.GetProperty( DevelTextEditor::Property::INPUT_METHOD_SETTINGS );
972 DALI_TEST_CHECK( value.Get( map ) );
975 DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
976 DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
979 DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
980 DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
983 DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
984 DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
987 DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
988 DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
990 // Check the input filter property
991 Property::Map inputFilterMapSet;
992 Property::Map inputFilterMapGet;
993 inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
994 inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
996 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
998 inputFilterMapGet = editor.GetProperty<Property::Map>(DevelTextEditor::Property::INPUT_FILTER);
999 DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1002 inputFilterMapSet.Clear();
1003 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilterMapSet);
1005 application.SendNotification();
1006 application.Render();
1011 // Positive Atlas Text Renderer test
1012 int utcDaliTextEditorAtlasRenderP(void)
1014 ToolkitTestApplication application;
1015 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
1016 StyleManager styleManager = StyleManager::Get();
1017 styleManager.ApplyDefaultTheme();
1018 TextEditor editor = TextEditor::New();
1019 DALI_TEST_CHECK( editor );
1021 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1023 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1025 application.GetScene().Add( editor );
1029 // Render some text with the shared atlas backend
1030 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1031 application.SendNotification();
1032 application.Render();
1036 tet_result(TET_FAIL);
1041 // Positive test for the anchorClicked signal.
1042 int utcDaliTextEditorAnchorClickedP(void)
1044 ToolkitTestApplication application;
1045 tet_infoline(" utcDaliTextEditorAnchorClickedP");
1046 TextEditor editor = TextEditor::New();
1047 DALI_TEST_CHECK(editor);
1049 application.GetScene().Add(editor);
1051 // connect to the anchor clicked signal.
1052 ConnectionTracker* testTracker = new ConnectionTracker();
1053 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
1054 bool anchorClickedSignal = false;
1055 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1057 gAnchorClickedCallBackCalled = false;
1058 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1059 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
1060 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1061 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1062 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1064 application.SendNotification();
1065 application.Render();
1066 editor.SetKeyInputFocus();
1068 // Create a tap event to touch the text editor.
1069 TestGenerateTap(application, 5.0f, 5.0f);
1070 application.SendNotification();
1071 application.Render();
1073 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1074 DALI_TEST_CHECK(anchorClickedSignal);
1076 gAnchorClickedCallBackNotCalled = true;
1077 // Tap the outside of anchor, callback should not be called.
1078 TestGenerateTap(application, 150.f, 100.f);
1079 application.SendNotification();
1080 application.Render();
1082 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1087 // Positive test for the textChanged signal.
1088 int utcDaliTextEditorTextChangedP(void)
1090 ToolkitTestApplication application;
1091 tet_infoline(" utcDaliTextEditorTextChangedP");
1092 TextEditor editor = TextEditor::New();
1093 DALI_TEST_CHECK( editor );
1095 application.GetScene().Add( editor );
1097 // connect to the text changed signal.
1098 ConnectionTracker* testTracker = new ConnectionTracker();
1099 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1100 bool textChangedSignal = false;
1101 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1103 gTextChangedCallBackCalled = false;
1104 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1105 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1106 DALI_TEST_CHECK( textChangedSignal );
1108 application.SendNotification();
1109 editor.SetKeyInputFocus();
1111 gTextChangedCallBackCalled = false;
1112 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1113 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1116 editor.SetProperty( TextField::Property::TEXT, "" );
1118 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1119 gTextChangedCallBackCalled = false;
1120 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1121 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1123 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1124 gTextChangedCallBackCalled = false;
1125 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1126 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1131 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1133 ToolkitTestApplication application;
1134 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1135 TextEditor editor = TextEditor::New();
1136 DALI_TEST_CHECK( editor );
1139 application.GetScene().Add( editor );
1141 // connect to the text changed signal.
1142 ConnectionTracker* testTracker = new ConnectionTracker();
1143 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1144 bool textChangedSignal = false;
1145 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1148 // get InputMethodContext
1150 InputMethodContext::EventData imfEvent;
1151 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1153 editor.SetKeyInputFocus();
1154 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1157 gTextChangedCallBackCalled = false;
1158 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1159 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1160 application.SendNotification();
1161 application.Render();
1162 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1163 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1165 gTextChangedCallBackCalled = false;
1166 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1167 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1168 application.SendNotification();
1169 application.Render();
1170 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1171 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1173 gTextChangedCallBackCalled = false;
1174 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1175 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1176 application.SendNotification();
1177 application.Render();
1178 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1179 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1181 gTextChangedCallBackCalled = false;
1182 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1183 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1184 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1186 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1187 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1188 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1190 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1191 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1192 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1194 application.SendNotification();
1195 application.Render();
1196 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1197 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1203 int utcDaliTextEditorInputStyleChanged01(void)
1205 // The text-editor emits signals when the input style changes. These changes of style are
1206 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1207 // can't be emitted during the size negotiation as the callbacks may update the UI.
1208 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1209 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1210 ToolkitTestApplication application;
1211 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1215 char* pathNamePtr = get_current_dir_name();
1216 const std::string pathName( pathNamePtr );
1217 free( pathNamePtr );
1219 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1220 fontClient.SetDpi( 93u, 93u );
1222 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1223 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1225 TextEditor editor = TextEditor::New();
1226 DALI_TEST_CHECK( editor );
1229 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1230 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1231 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1233 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1234 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1236 // connect to the text changed signal.
1237 ConnectionTracker* testTracker = new ConnectionTracker();
1238 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1239 bool inputStyleChangedSignal = false;
1240 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1242 application.GetScene().Add( editor );
1244 // Render and notify
1245 application.SendNotification();
1246 application.Render();
1248 // Executes the idle callbacks added by the text control on the change of input style.
1249 application.RunIdles();
1251 gInputStyleChangedCallbackCalled = false;
1252 gInputStyleMask = TextEditor::InputStyle::NONE;
1253 inputStyleChangedSignal = false;
1255 // Create a tap event to touch the text editor.
1256 TestGenerateTap( application, 18.0f, 25.0f );
1258 // Render and notify
1259 application.SendNotification();
1260 application.Render();
1262 // Executes the idle callbacks added by the text control on the change of input style.
1263 application.RunIdles();
1265 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1266 if( gInputStyleChangedCallbackCalled )
1268 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1270 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1271 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1273 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1274 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1276 DALI_TEST_CHECK( inputStyleChangedSignal );
1278 gInputStyleChangedCallbackCalled = false;
1279 gInputStyleMask = TextEditor::InputStyle::NONE;
1280 inputStyleChangedSignal = false;
1282 // Create a tap event to touch the text editor.
1283 TestGenerateTap( application, 30.0f, 25.0f );
1285 // Render and notify
1286 application.SendNotification();
1287 application.Render();
1289 // Executes the idle callbacks added by the text control on the change of input style.
1290 application.RunIdles();
1292 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1293 DALI_TEST_CHECK( !inputStyleChangedSignal );
1295 gInputStyleChangedCallbackCalled = false;
1296 gInputStyleMask = TextEditor::InputStyle::NONE;
1297 inputStyleChangedSignal = false;
1299 // Create a tap event to touch the text editor.
1300 TestGenerateTap( application, 43.0f, 25.0f );
1302 // Render and notify
1303 application.SendNotification();
1304 application.Render();
1306 // Executes the idle callbacks added by the text control on the change of input style.
1307 application.RunIdles();
1309 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1310 if( gInputStyleChangedCallbackCalled )
1312 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1314 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1315 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1317 DALI_TEST_CHECK( inputStyleChangedSignal );
1319 gInputStyleChangedCallbackCalled = false;
1320 gInputStyleMask = TextEditor::InputStyle::NONE;
1321 inputStyleChangedSignal = false;
1323 // Create a tap event to touch the text editor.
1324 TestGenerateTap( application, 88.0f, 25.0f );
1326 // Render and notify
1327 application.SendNotification();
1328 application.Render();
1330 // Executes the idle callbacks added by the text control on the change of input style.
1331 application.RunIdles();
1333 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1334 if( gInputStyleChangedCallbackCalled )
1336 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1338 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1339 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1341 Property::Map fontStyleMapSet;
1342 Property::Map fontStyleMapGet;
1344 fontStyleMapSet.Insert( "weight", "bold" );
1346 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1347 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1348 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1350 DALI_TEST_CHECK( inputStyleChangedSignal );
1352 gInputStyleChangedCallbackCalled = false;
1353 gInputStyleMask = TextEditor::InputStyle::NONE;
1354 inputStyleChangedSignal = false;
1356 // Create a tap event to touch the text editor.
1357 TestGenerateTap( application, 115.0f, 25.0f );
1359 // Render and notify
1360 application.SendNotification();
1361 application.Render();
1363 // Executes the idle callbacks added by the text control on the change of input style.
1364 application.RunIdles();
1366 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1367 DALI_TEST_CHECK( !inputStyleChangedSignal );
1369 gInputStyleChangedCallbackCalled = false;
1370 gInputStyleMask = TextEditor::InputStyle::NONE;
1371 inputStyleChangedSignal = false;
1373 // Create a tap event to touch the text editor.
1374 TestGenerateTap( application, 164.0f, 25.0f );
1376 // Render and notify
1377 application.SendNotification();
1378 application.Render();
1380 // Executes the idle callbacks added by the text control on the change of input style.
1381 application.RunIdles();
1383 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1384 if( gInputStyleChangedCallbackCalled )
1386 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1388 Property::Map fontStyleMapSet;
1389 Property::Map fontStyleMapGet;
1391 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1392 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1393 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1395 DALI_TEST_CHECK( inputStyleChangedSignal );
1397 gInputStyleChangedCallbackCalled = false;
1398 gInputStyleMask = TextEditor::InputStyle::NONE;
1399 inputStyleChangedSignal = false;
1401 // Create a tap event to touch the text editor.
1402 TestGenerateTap( application, 191.0f, 25.0f );
1404 // Render and notify
1405 application.SendNotification();
1406 application.Render();
1408 // Executes the idle callbacks added by the text control on the change of input style.
1409 application.RunIdles();
1411 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1412 DALI_TEST_CHECK( !inputStyleChangedSignal );
1417 int utcDaliTextEditorInputStyleChanged02(void)
1419 // The text-editor emits signals when the input style changes. These changes of style are
1420 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1421 // can't be emitted during the size negotiation as the callbacks may update the UI.
1422 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1423 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1424 ToolkitTestApplication application;
1425 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1429 char* pathNamePtr = get_current_dir_name();
1430 const std::string pathName( pathNamePtr );
1431 free( pathNamePtr );
1433 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1434 fontClient.SetDpi( 93u, 93u );
1436 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1437 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1439 TextEditor editor = TextEditor::New();
1440 DALI_TEST_CHECK( editor );
1443 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1444 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1445 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1447 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1448 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>" );
1450 // connect to the text changed signal.
1451 ConnectionTracker* testTracker = new ConnectionTracker();
1452 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1453 bool inputStyleChangedSignal = false;
1454 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1456 application.GetScene().Add( editor );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 // Executes the idle callbacks added by the text control on the change of input style.
1463 application.RunIdles();
1465 gInputStyleChangedCallbackCalled = false;
1466 gInputStyleMask = TextEditor::InputStyle::NONE;
1467 inputStyleChangedSignal = false;
1469 // Create a tap event to touch the text editor.
1470 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1471 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1473 // Render and notify
1474 application.SendNotification();
1475 application.Render();
1477 // Executes the idle callbacks added by the text control on the change of input style.
1478 application.RunIdles();
1480 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1481 if( gInputStyleChangedCallbackCalled )
1483 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1484 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1485 TextEditor::InputStyle::POINT_SIZE |
1486 TextEditor::InputStyle::COLOR ),
1489 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1490 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1492 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1493 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1495 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1496 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1498 DALI_TEST_CHECK( inputStyleChangedSignal );
1500 gInputStyleChangedCallbackCalled = false;
1501 gInputStyleMask = TextEditor::InputStyle::NONE;
1502 inputStyleChangedSignal = false;
1504 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1506 // Render and notify
1507 application.SendNotification();
1508 application.Render();
1510 // Executes the idle callbacks added by the text control on the change of input style.
1511 application.RunIdles();
1513 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1514 if( gInputStyleChangedCallbackCalled )
1516 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1517 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1520 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1521 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1523 DALI_TEST_CHECK( inputStyleChangedSignal );
1525 gInputStyleChangedCallbackCalled = false;
1526 gInputStyleMask = TextEditor::InputStyle::NONE;
1527 inputStyleChangedSignal = false;
1529 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // Executes the idle callbacks added by the text control on the change of input style.
1536 application.RunIdles();
1538 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1539 DALI_TEST_CHECK( !inputStyleChangedSignal );
1541 gInputStyleChangedCallbackCalled = false;
1542 gInputStyleMask = TextEditor::InputStyle::NONE;
1543 inputStyleChangedSignal = false;
1545 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 // Executes the idle callbacks added by the text control on the change of input style.
1552 application.RunIdles();
1554 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1555 if( gInputStyleChangedCallbackCalled )
1557 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1558 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1561 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1562 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1564 DALI_TEST_CHECK( inputStyleChangedSignal );
1566 gInputStyleChangedCallbackCalled = false;
1567 gInputStyleMask = TextEditor::InputStyle::NONE;
1568 inputStyleChangedSignal = false;
1570 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1572 Property::Map fontStyleMapSet;
1573 fontStyleMapSet.Insert( "weight", "thin" );
1574 fontStyleMapSet.Insert( "width", "condensed" );
1575 fontStyleMapSet.Insert( "slant", "italic" );
1577 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1578 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1579 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1581 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1582 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1583 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1584 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1586 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1588 // Render and notify
1589 application.SendNotification();
1590 application.Render();
1592 // Executes the idle callbacks added by the text control on the change of input style.
1593 application.RunIdles();
1595 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1596 DALI_TEST_CHECK( !inputStyleChangedSignal );
1598 // Create a tap event to touch the text editor.
1599 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1601 // Render and notify
1602 application.SendNotification();
1603 application.Render();
1605 // Executes the idle callbacks added by the text control on the change of input style.
1606 application.RunIdles();
1608 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1609 if( gInputStyleChangedCallbackCalled )
1611 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1612 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1613 TextEditor::InputStyle::POINT_SIZE |
1614 TextEditor::InputStyle::FONT_STYLE |
1615 TextEditor::InputStyle::LINE_SPACING |
1616 TextEditor::InputStyle::UNDERLINE |
1617 TextEditor::InputStyle::SHADOW |
1618 TextEditor::InputStyle::EMBOSS |
1619 TextEditor::InputStyle::OUTLINE ),
1622 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1623 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1625 DALI_TEST_CHECK( inputStyleChangedSignal );
1627 gInputStyleChangedCallbackCalled = false;
1628 gInputStyleMask = TextEditor::InputStyle::NONE;
1629 inputStyleChangedSignal = false;
1631 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1633 fontStyleMapSet.Clear();
1634 fontStyleMapSet.Insert( "weight", "black" );
1635 fontStyleMapSet.Insert( "width", "expanded" );
1636 fontStyleMapSet.Insert( "slant", "oblique" );
1638 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1640 // Create a tap event to touch the text editor.
1641 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Executes the idle callbacks added by the text control on the change of input style.
1648 application.RunIdles();
1650 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1651 if( gInputStyleChangedCallbackCalled )
1653 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1654 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1655 TextEditor::InputStyle::POINT_SIZE |
1656 TextEditor::InputStyle::FONT_STYLE ),
1659 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1660 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1662 DALI_TEST_CHECK( inputStyleChangedSignal );
1667 int utcDaliTextEditorEvent01(void)
1669 ToolkitTestApplication application;
1670 tet_infoline(" utcDaliTextEditorEvent01");
1672 // Creates a tap event. After creating a tap event the text editor should
1673 // have the focus and add text with key events should be possible.
1675 TextEditor editor = TextEditor::New();
1676 DALI_TEST_CHECK( editor );
1678 application.GetScene().Add( editor );
1680 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1681 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1682 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1684 // Avoid a crash when core load gl resources.
1685 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1691 // Add a key event but as the text editor has not the focus it should do nothing.
1692 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1694 // Render and notify
1695 application.SendNotification();
1696 application.Render();
1698 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1700 // Create a tap event to touch the text editor.
1701 TestGenerateTap( application, 150.0f, 25.0f );
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 // Now the text editor has the focus, so it can handle the key events.
1708 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1709 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1711 // Render and notify
1712 application.SendNotification();
1713 application.Render();
1715 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1717 // Create a second text editor and send key events to it.
1718 TextEditor editor2 = TextEditor::New();
1720 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1721 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1722 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1723 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1725 application.GetScene().Add( editor2 );
1727 // Render and notify
1728 application.SendNotification();
1729 application.Render();
1731 // Create a tap event on the second text editor.
1732 TestGenerateTap( application, 150.0f, 125.0f );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 // The second text editor has the focus. It should handle the key events.
1739 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1740 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1746 // Check the text has been added to the second text editor.
1747 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1752 int utcDaliTextEditorEvent02(void)
1754 ToolkitTestApplication application;
1755 tet_infoline(" utcDaliTextEditorEvent02");
1757 // Checks if the right number of actors are created.
1759 TextEditor editor = TextEditor::New();
1760 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1761 DALI_TEST_CHECK( editor );
1763 application.GetScene().Add( editor );
1765 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1766 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1767 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1769 // Avoid a crash when core load gl resources.
1770 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1772 // Render and notify
1773 application.SendNotification();
1774 application.Render();
1776 // Check there are the expected number of children (the stencil).
1777 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1779 Actor stencil = editor.GetChildAt( 0u );
1781 // Create a tap event to touch the text editor.
1782 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1788 Actor layer = editor.GetChildAt( 1u );
1789 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1790 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1792 // Now the text editor has the focus, so it can handle the key events.
1793 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1794 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // Checks the cursor and the renderer have been created.
1801 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1802 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1804 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1805 DALI_TEST_CHECK( cursor );
1807 // The stencil actor has a container with all the actors which contain the text renderers.
1808 Actor container = stencil.GetChildAt( 0u );
1809 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1811 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1812 DALI_TEST_CHECK( renderer );
1815 // Move the cursor and check the position changes.
1816 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1818 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1827 DALI_TEST_CHECK( position2.x < position1.x );
1829 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1830 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1832 // Render and notify
1833 application.SendNotification();
1834 application.Render();
1836 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1838 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1840 // Send some taps and check the cursor positions.
1842 // Try to tap at the beginning.
1843 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Cursor position should be the same than position1.
1850 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1852 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1854 // Tap away from the start position.
1855 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1863 DALI_TEST_CHECK( position5.x > position4.x );
1865 // Remove all the text.
1866 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1867 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1868 editor.SetProperty( TextEditor::Property::TEXT, "" );
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1874 // Cursor position should be the same than position2.
1875 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1877 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1879 // Should not be a renderer.
1880 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1885 int utcDaliTextEditorEvent03(void)
1887 ToolkitTestApplication application;
1888 tet_infoline(" utcDaliTextEditorEvent03");
1890 // Checks if the highlight actor is created.
1892 TextEditor editor = TextEditor::New();
1893 DALI_TEST_CHECK( editor );
1895 application.GetScene().Add( editor );
1897 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1898 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1899 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1900 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1901 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1903 // Avoid a crash when core load gl resources.
1904 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Send some taps and check text controller with clipboard window
1911 Dali::Clipboard clipboard = Clipboard::Get();
1912 clipboard.ShowClipboard();
1913 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1914 clipboard.HideClipboard();
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 // Tap first to get the focus.
1921 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 // Double tap to select a word.
1928 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 // The stencil actor should have two actors: the renderer and the highlight actor.
1935 Actor stencil = editor.GetChildAt( 0u );
1937 // Highlight needs to be drawn before text, so should come first in child order
1938 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1939 DALI_TEST_CHECK( highlight );
1941 // The stencil actor has a container with all the actors which contain the text renderers.
1942 Actor container = stencil.GetChildAt( 1u );
1943 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1945 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1946 DALI_TEST_CHECK( renderer );
1949 // Double tap out of bounds
1950 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1951 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1953 // Render and notify
1954 application.SendNotification();
1955 application.Render();
1957 // The stencil actor should have one actors: the renderer actor.
1958 stencil = editor.GetChildAt( 0u );
1960 // The stencil actor has a container with all the actors which contain the text renderers.
1961 container = stencil.GetChildAt( 0u );
1962 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1964 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1965 DALI_TEST_CHECK( renderer );
1969 TestGenerateLongPress(application, 1.0f, 25.0f);
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1976 TestGenerateMiniPan(application);
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1985 int utcDaliTextEditorEvent04(void)
1987 ToolkitTestApplication application;
1988 tet_infoline(" utcDaliTextEditorEvent04");
1990 // Checks if the highlight actor is created.
1992 TextEditor editor = TextEditor::New();
1993 DALI_TEST_CHECK( editor );
1995 application.GetScene().Add( editor );
1997 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1998 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1999 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2000 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2001 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2003 // Avoid a crash when core load gl resources.
2004 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2006 // Render and notify
2007 application.SendNotification();
2008 application.Render();
2010 // Tap on the text editor
2011 TestGenerateTap( application, 3.0f, 25.0f );
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2017 // Move at the end of the text.
2018 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2019 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2021 // Render and notify
2022 application.SendNotification();
2023 application.Render();
2025 for( unsigned int index = 0u; index < 10u; ++index )
2027 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2028 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2036 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2042 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2044 // Add some key events
2045 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 for( unsigned int index = 0u; index < 10u; ++index )
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2063 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2069 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2074 int utcDaliTextEditorEvent05(void)
2076 ToolkitTestApplication application;
2077 tet_infoline(" utcDaliTextEditorEvent05");
2079 // Checks if the highlight actor is created.
2081 TextEditor editor = TextEditor::New();
2082 DALI_TEST_CHECK( editor );
2084 application.GetScene().Add( editor );
2086 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2087 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2088 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2089 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2090 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2091 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2092 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2093 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2094 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2095 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2097 // Avoid a crash when core load gl resources.
2098 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2100 // Render and notify
2101 application.SendNotification();
2102 application.Render();
2104 // Tap on the text editor
2105 TestGenerateTap( application, 3.0f, 25.0f );
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2111 // Move at the end of the text.
2112 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2113 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2115 // Render and notify
2116 application.SendNotification();
2117 application.Render();
2119 for( unsigned int index = 0u; index < 10u; ++index )
2122 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2124 // Render and notify
2125 application.SendNotification();
2126 application.Render();
2128 // Modify duration after scroll is enabled
2129 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2131 // Continuous scroll left to increase coverage
2132 for( unsigned int index = 0u; index < 10u; ++index )
2134 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2141 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2142 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2143 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2144 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2146 // Press Escape to increase coverage
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.SendNotification();
2149 application.Render();
2151 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2156 int utcDaliTextEditorEvent06(void)
2158 ToolkitTestApplication application;
2159 tet_infoline(" utcDaliTextEditorEvent06");
2161 // Checks if the highlight actor is created.
2163 TextEditor editor = TextEditor::New();
2164 DALI_TEST_CHECK( editor );
2166 application.GetScene().Add( editor );
2168 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2169 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2170 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2171 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2172 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2174 // Avoid a crash when core load gl resources.
2175 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 // Tap on the text editor
2182 TestGenerateTap( application, 3.0f, 25.0f );
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2188 // Move to seconds line of the text.
2189 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 // Render and notify
2192 application.SendNotification();
2193 application.Render();
2195 float layoutHeight = editor.GetHeightForWidth( 100.f );
2198 // Add another script characters ( glyph height is defferent )
2199 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2200 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 // Delete characters
2203 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2204 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2206 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2208 // Render and notify
2209 application.SendNotification();
2210 application.Render();
2212 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2215 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2216 application.SendNotification();
2217 application.Render();
2219 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 application.SendNotification();
2221 application.Render();
2223 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2224 application.SendNotification();
2225 application.Render();
2227 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2228 application.SendNotification();
2229 application.Render();
2231 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2232 application.SendNotification();
2233 application.Render();
2235 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.SendNotification();
2237 application.Render();
2239 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.SendNotification();
2241 application.Render();
2246 int utcDaliTextEditorEvent07(void)
2248 ToolkitTestApplication application;
2249 tet_infoline(" utcDaliTextEditorEvent07");
2251 // Checks if the highlight actor is created.
2253 TextEditor editor = TextEditor::New();
2254 DALI_TEST_CHECK( editor );
2256 application.GetScene().Add( editor );
2258 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2259 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2260 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2261 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2262 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2264 // Avoid a crash when core load gl resources.
2265 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Tap on the text editor
2272 TestGenerateTap( application, 3.0f, 25.0f );
2274 // Render and notify
2275 application.SendNotification();
2276 application.Render();
2278 // Move to second line of the text.
2279 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 // Render and notify
2282 application.SendNotification();
2283 application.Render();
2285 // Select some text in the right of the current cursor position
2286 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2287 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 // Render and notify
2292 application.SendNotification();
2293 application.Render();
2295 // Cut the selected text
2296 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2297 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 ) );
2299 // Render and notify
2300 application.SendNotification();
2301 application.Render();
2303 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2305 // Select some text in the left of the current cursor position
2306 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2307 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2309 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2311 // Render and notify
2312 application.SendNotification();
2313 application.Render();
2315 // Copy the selected text
2316 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2317 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 ) );
2319 // Render and notify
2320 application.SendNotification();
2321 application.Render();
2323 // Move the cursor to the third line
2324 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Paste the selected text at the current cursor position
2332 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 application.ProcessEvent( GenerateKey( "v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2342 // Disable Shift Selection
2343 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2345 // Test to select some text in the right of the current cursor position
2346 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2347 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2348 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2349 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2351 // Render and notify
2352 application.SendNotification();
2353 application.Render();
2355 // Cut the selected text
2356 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2357 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 ) );
2359 // Render and notify
2360 application.SendNotification();
2361 application.Render();
2363 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2364 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2366 // Test to select some text in the left of the current cursor position
2367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 // Copy the selected text
2377 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 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 ) );
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2385 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2388 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 ) );
2390 // Render and notify
2391 application.SendNotification();
2392 application.Render();
2394 // replace text with "c"
2395 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2402 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2405 DevelTextEditor::SelectWholeText(editor);
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // Copy the selected text using logical keys
2412 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2413 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2420 DevelTextEditor::SelectNone(editor);
2422 // Render and notify
2423 application.SendNotification();
2424 application.Render();
2426 // Paste the selected 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( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2431 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2433 // select all using logical keys
2434 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2435 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // cut text 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( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2450 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2455 int utcDaliTextEditorEvent08(void)
2457 ToolkitTestApplication application;
2458 tet_infoline(" utcDaliTextEditorEvent08");
2460 // Checks if the highlight actor is released correctly.
2462 TextEditor editor = TextEditor::New();
2463 DALI_TEST_CHECK( editor );
2465 application.GetScene().Add( editor );
2467 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2468 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2469 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2470 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2471 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2473 // Avoid a crash when core load gl resources.
2474 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2476 // Render and notify
2477 application.SendNotification();
2478 application.Render();
2480 // Tap on the text editor
2481 TestGenerateTap( application, 3.0f, 25.0f );
2483 // Render and notify
2484 application.SendNotification();
2485 application.Render();
2487 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2488 // Test to select some text in the left of the current cursor position
2489 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2490 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2491 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2492 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2498 // Test to the left selection handle position and the right selection handle position
2499 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2500 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2501 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2502 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2504 // Render and notify
2505 application.SendNotification();
2506 application.Render();
2508 // Test to select full text in the left of the current cursor position
2509 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2510 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2511 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2512 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2513 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2514 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2520 // Test to release the current full text selection
2521 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2522 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2528 // Test to move the current cursor position correctly
2529 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2536 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2542 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2544 // Test to select some text in the right of the current cursor position
2545 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2546 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2547 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // Test the cursor position with right arrow key
2554 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2561 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2563 // Render and notify
2564 application.SendNotification();
2565 application.Render();
2567 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2569 // Test to select some text in the left of the current cursor position
2570 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2571 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2572 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2573 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2574 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2576 // Render and notify
2577 application.SendNotification();
2578 application.Render();
2580 // Test the cursor position with left arrow key
2581 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2583 // Render and notify
2584 application.SendNotification();
2585 application.Render();
2588 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2590 // Render and notify
2591 application.SendNotification();
2592 application.Render();
2594 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2596 // Test to select some text in the right of the current cursor position
2597 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2598 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2599 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2600 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2602 // Render and notify
2603 application.SendNotification();
2604 application.Render();
2606 // Test the cursor position with left arrow key
2607 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2609 // Render and notify
2610 application.SendNotification();
2611 application.Render();
2614 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2616 // Render and notify
2617 application.SendNotification();
2618 application.Render();
2620 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2622 // Test to select some text in the left of the current cursor position
2623 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2624 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2625 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2626 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2628 // Render and notify
2629 application.SendNotification();
2630 application.Render();
2632 // Test the cursor position with right arrow key
2633 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2635 // Render and notify
2636 application.SendNotification();
2637 application.Render();
2640 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2642 // Render and notify
2643 application.SendNotification();
2644 application.Render();
2646 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2651 int utcDaliTextEditorHandles(void)
2653 ToolkitTestApplication application;
2654 tet_infoline(" utcDaliTextEditorHandles");
2656 TextEditor editor = TextEditor::New();
2657 DALI_TEST_CHECK( editor );
2659 application.GetScene().Add( editor );
2661 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2662 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2663 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2664 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2666 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2667 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2668 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2669 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2671 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2672 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2673 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2675 // Avoid a crash when core load gl resources.
2676 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2678 // Render and notify
2679 application.SendNotification();
2680 application.Render();
2682 // Tap first to get the focus.
2683 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2685 // Render and notify
2686 application.SendNotification();
2687 application.Render();
2689 // Tap to create the grab handle.
2690 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2692 // Render and notify
2693 application.SendNotification();
2694 application.Render();
2696 // Get the active layer where the text's decoration is added.
2697 Actor activeLayer = editor.GetChildAt( 1u );
2699 // Get the handle's actor.
2700 Actor handle = activeLayer.GetChildAt( 1u );
2701 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2703 // Render and notify
2704 application.SendNotification();
2705 application.Render();
2707 // Touch the grab handle to set it as pressed.
2708 Vector2 touchPos( 10.0f, 50.0f );
2709 Dali::Integration::TouchEvent event;
2710 event = Dali::Integration::TouchEvent();
2711 event.AddPoint( GetPointDownInside( touchPos ) );
2712 application.ProcessEvent( event );
2714 // Render and notify
2715 application.SendNotification();
2716 application.Render();
2718 // Pan the grab handle
2719 uint32_t time = 100;
2720 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2721 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2722 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2723 application.SendNotification();
2724 application.Render();
2727 // Release the grab handle.
2728 event = Dali::Integration::TouchEvent();
2729 event.AddPoint( GetPointUpInside( touchPos ) );
2730 application.ProcessEvent( event );
2732 // Render and notify
2733 application.SendNotification();
2734 application.Render();
2736 // Tap first to get the focus.
2737 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2739 // Render and notify
2740 application.SendNotification();
2741 application.Render();
2743 // Double tap to select a word and create the selection handles.
2744 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2746 // Render and notify
2747 application.SendNotification();
2748 application.Render();
2750 touchPos = Vector2( 10.0f, 50.0f );
2752 // Touch the left selection handle to set it as pressed.
2753 event = Dali::Integration::TouchEvent();
2754 event.AddPoint( GetPointDownInside( touchPos ) );
2755 application.ProcessEvent( event );
2757 // Render and notify
2758 application.SendNotification();
2759 application.Render();
2761 // Release the left selection handle.
2762 event = Dali::Integration::TouchEvent();
2763 event.AddPoint( GetPointUpInside( touchPos ) );
2764 application.ProcessEvent( event );
2766 // Render and notify
2767 application.SendNotification();
2768 application.Render();
2773 int utcDaliTextEditorUnderPropertyStringP(void)
2775 ToolkitTestApplication application;
2776 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2777 TextEditor editor = TextEditor::New();
2778 DALI_TEST_CHECK( editor );
2780 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2782 application.GetScene().Add( editor );
2784 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2785 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2787 tet_infoline("Set underline settings with a map");
2788 // Check the input underline property
2789 Property::Map underlineMapSet;
2790 Property::Map underlineMapGet;
2791 underlineMapSet.Insert( "enable", true );
2792 underlineMapSet.Insert( "color", Color::BLUE );
2793 underlineMapSet.Insert( "height", 2 );
2795 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2796 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2797 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2798 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2800 tet_infoline("Set underline settings with a string");
2801 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2802 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2805 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2807 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2808 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2809 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2810 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2812 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2817 int utcDaliTextEditorShadowPropertyStringP(void)
2819 ToolkitTestApplication application;
2820 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2822 TextEditor editor = TextEditor::New();
2824 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2826 application.GetScene().Add( editor );
2828 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2830 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2834 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2839 int utcDaliTextEditorFontStylePropertyStringP(void)
2841 ToolkitTestApplication application;
2842 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2844 TextEditor editor = TextEditor::New();
2846 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2848 application.GetScene().Add( editor );
2850 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2852 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2856 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2861 int utcDaliTextEditorGetPropertyLinecountP(void)
2863 ToolkitTestApplication application;
2865 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2869 TextEditor editor = TextEditor::New();
2870 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2871 editor.SetProperty( TextEditor::Property::TEXT,
2872 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2874 application.GetScene().Add( editor );
2876 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2877 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2878 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2880 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2881 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2882 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2887 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2890 ToolkitTestApplication application;
2891 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2893 TextEditor editor = TextEditor::New();
2894 DALI_TEST_CHECK( editor );
2896 application.GetScene().Add( editor );
2898 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2899 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2900 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2901 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2902 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2903 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2905 bool startedCalled = false;
2906 bool finishedCalled = false;
2908 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2909 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2911 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2913 // Render and notify
2914 application.SendNotification();
2915 application.Render();
2917 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2918 application.SendNotification();
2919 application.Render(6000);
2921 application.SendNotification();
2922 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2923 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2928 int UtcDaliToolkitTextEditorTextWrapMode(void)
2930 ToolkitTestApplication application;
2931 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2935 TextEditor editor = TextEditor::New();
2936 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2937 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2939 application.GetScene().Add( editor );
2941 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2942 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2944 application.SendNotification();
2945 application.Render();
2947 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2948 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2950 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2951 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2953 application.SendNotification();
2954 application.Render();
2956 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2957 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2959 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2960 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2962 application.SendNotification();
2963 application.Render();
2965 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2966 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2968 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2969 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2971 application.SendNotification();
2972 application.Render();
2974 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2975 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2980 int UtcDaliTextEditorSetPaddingProperty(void)
2982 ToolkitTestApplication application;
2983 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2985 TextEditor editor = TextEditor::New();
2986 DALI_TEST_CHECK( editor );
2987 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2988 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2989 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2990 application.GetScene().Add( editor );
2992 application.SendNotification();
2993 application.Render();
2995 Vector3 originalSize = editor.GetNaturalSize();
2997 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2999 application.SendNotification();
3000 application.Render();
3002 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3004 Vector3 paddingAddedSize = editor.GetNaturalSize();
3006 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3008 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3013 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
3015 ToolkitTestApplication application;
3016 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
3018 TextEditor editor = TextEditor::New();
3019 DALI_TEST_CHECK( editor );
3020 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3021 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3022 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3023 application.GetScene().Add( editor );
3025 application.SendNotification();
3026 application.Render();
3028 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3029 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3031 // Check the enable shift selection property
3032 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
3033 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3035 application.SendNotification();
3036 application.Render();
3041 int UtcDaliTextEditorEnableGrabHandleProperty(void)
3043 ToolkitTestApplication application;
3044 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
3046 TextEditor editor = TextEditor::New();
3047 DALI_TEST_CHECK( editor );
3048 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3049 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3050 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3051 application.GetScene().Add( editor );
3053 application.SendNotification();
3054 application.Render();
3056 // The default value of ENABLE_GRAB_HANDLE is 'true'.
3057 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3059 // Check the enable grab handle property
3060 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
3061 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3063 application.SendNotification();
3064 application.Render();
3069 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3071 ToolkitTestApplication application;
3072 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3074 TextEditor editor = TextEditor::New();
3075 DALI_TEST_CHECK( editor );
3076 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3077 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3078 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3079 application.GetScene().Add( editor );
3081 application.SendNotification();
3082 application.Render();
3084 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3085 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3087 // Check the disable match system language direction property
3088 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3089 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3091 application.SendNotification();
3092 application.Render();
3097 int UtcDaliTextEditorGetInputMethodContext(void)
3099 ToolkitTestApplication application;
3100 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3102 TextEditor editor = TextEditor::New();
3103 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3108 int utcDaliTextEditorMaxCharactersReached(void)
3110 ToolkitTestApplication application;
3111 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3113 TextEditor editor = TextEditor::New();
3114 DALI_TEST_CHECK( editor );
3116 application.GetScene().Add( editor );
3118 const int maxNumberOfCharacters = 1;
3119 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3120 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3122 editor.SetKeyInputFocus();
3124 // connect to the text changed signal.
3125 ConnectionTracker* testTracker = new ConnectionTracker();
3126 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3127 bool maxLengthReachedSignal = false;
3128 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3130 gMaxCharactersCallBackCalled = false;
3132 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3133 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3135 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3136 DALI_TEST_CHECK( maxLengthReachedSignal );
3141 int utcDaliTextEditorInputFiltered(void)
3143 ToolkitTestApplication application;
3144 tet_infoline(" utcDaliTextEditorInputFiltered");
3145 TextEditor editor = TextEditor::New();
3146 DALI_TEST_CHECK(editor);
3148 application.GetScene().Add(editor);
3150 Property::Map inputFilter;
3152 // Only digit is accepted.
3153 inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
3155 // Set input filter to TextEditor.
3156 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3158 editor.SetKeyInputFocus();
3160 // connect to the input filtered signal.
3161 ConnectionTracker* testTracker = new ConnectionTracker();
3162 DevelTextEditor::InputFilteredSignal(editor).Connect(&TestInputFilteredCallback);
3163 bool inputFilteredSignal = false;
3164 editor.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
3166 gInputFilteredAcceptedCallbackCalled = false;
3168 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
3170 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3171 DALI_TEST_CHECK(inputFilteredSignal);
3173 // Word is rejected.
3174 inputFilter[InputFilter::Property::ACCEPTED] = "";
3175 inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
3177 // Set input filter to TextEditor.
3178 editor.SetProperty(DevelTextEditor::Property::INPUT_FILTER, inputFilter);
3180 editor.SetKeyInputFocus();
3182 inputFilteredSignal = false;
3183 gInputFilteredRejectedCallbackCalled = false;
3185 application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
3187 DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
3188 DALI_TEST_CHECK(inputFilteredSignal);
3193 int UtcDaliTextEditorSelectWholeText(void)
3195 ToolkitTestApplication application;
3196 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3198 TextEditor textEditor = TextEditor::New();
3200 application.GetScene().Add( textEditor );
3202 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3203 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3204 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3206 // Avoid a crash when core load gl resources.
3207 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3209 application.SendNotification();
3210 application.Render();
3212 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3214 DevelTextEditor::SelectWholeText( textEditor );
3216 application.SendNotification();
3217 application.Render();
3219 // Nothing should have been selected. The number of children is still 1
3220 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3222 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3224 application.SendNotification();
3225 application.Render();
3227 DevelTextEditor::SelectWholeText( textEditor );
3229 application.SendNotification();
3230 application.Render();
3232 // Should be 2 children, the stencil and the layer
3233 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3235 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3236 Actor stencil = textEditor.GetChildAt( 0u );
3238 // The highlight actor is drawn first, so is the first actor in the list
3239 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3240 DALI_TEST_CHECK( highlight );
3245 int UtcDaliTextEditorSelectNone(void)
3247 ToolkitTestApplication application;
3248 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3250 TextEditor textEditor = TextEditor::New();
3252 application.GetScene().Add( textEditor );
3254 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3255 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3256 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3258 // Avoid a crash when core load gl resources.
3259 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3261 application.SendNotification();
3262 application.Render();
3264 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3266 application.SendNotification();
3267 application.Render();
3269 // Nothing is selected
3270 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3271 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3273 DevelTextEditor::SelectWholeText( textEditor );
3275 application.SendNotification();
3276 application.Render();
3278 // whole text is selected
3279 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3280 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3282 DevelTextEditor::SelectNone( textEditor );
3284 application.SendNotification();
3285 application.Render();
3287 // Nothing is selected
3288 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3289 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3294 int UtcDaliTextEditorSelectRange(void)
3296 ToolkitTestApplication application;
3297 tet_infoline("utcDaliTextEditorSelectRange");
3299 TextEditor textEditor = TextEditor::New();
3300 DALI_TEST_CHECK( textEditor );
3302 application.GetScene().Add( textEditor );
3304 // Avoid a crash when core load gl resources.
3305 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3307 application.SendNotification();
3308 application.Render();
3310 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3312 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3313 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3315 // Hello is selected
3316 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3317 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3319 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3320 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3325 int UtcDaliTextEditorEnableEditing(void)
3327 ToolkitTestApplication application;
3328 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3330 TextEditor textEditor = TextEditor::New();
3332 application.GetScene().Add( textEditor );
3334 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3335 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3336 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3338 // Avoid a crash when core load gl resources.
3339 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3341 application.SendNotification();
3342 application.Render();
3344 textEditor.SetKeyInputFocus();
3345 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3346 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3348 // Render and notify
3349 application.SendNotification();
3350 application.Render();
3352 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3353 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3355 textEditor.SetKeyInputFocus();
3356 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3357 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3359 // Render and notify
3360 application.SendNotification();
3361 application.Render();
3363 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3364 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3369 int UtcDaliTextEditorScrolling(void)
3371 ToolkitTestApplication application;
3372 tet_infoline(" UtcDaliTextEditorScrolling ");
3374 TextEditor textEditor = TextEditor::New();
3375 DALI_TEST_CHECK( textEditor );
3377 application.GetScene().Add( textEditor );
3379 // Avoid a crash when core load gl resources.
3380 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3382 application.SendNotification();
3383 application.Render();
3385 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3386 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3387 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3388 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3390 application.SendNotification();
3391 application.Render();
3393 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3394 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3397 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3399 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3400 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3402 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3404 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3405 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3407 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3408 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3410 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3411 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3416 int UtcDaliToolkitTextEditorFontSizeScale(void)
3418 ToolkitTestApplication application;
3419 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3421 TextEditor textEditor = TextEditor::New();
3422 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3423 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3424 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3426 TextEditor textEditorScaled = TextEditor::New();
3427 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3428 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3429 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3430 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3432 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3434 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3435 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3436 nonScaledSize = textEditor.GetNaturalSize();
3438 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3439 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3440 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3441 scaledSize = textEditorScaled.GetNaturalSize();
3443 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3448 int UtcDaliTextEditorPrimaryCursorPosition(void)
3450 ToolkitTestApplication application;
3451 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3453 TextEditor textEditor = TextEditor::New();
3455 application.GetScene().Add( textEditor );
3457 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3458 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3459 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3460 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3462 // Avoid a crash when core load gl resources.
3463 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3465 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3466 application.SendNotification();
3467 application.Render();
3469 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3471 // Render and notify
3472 application.SendNotification();
3473 application.Render();
3475 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3476 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3481 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3483 ToolkitTestApplication application;
3484 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3486 TextEditor textEditor = TextEditor::New();
3487 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3488 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3489 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3490 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3491 application.GetScene().Add( textEditor );
3493 application.SendNotification();
3494 application.Render();
3497 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3498 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3500 textEditor.GetNaturalSize();
3502 // Create a tap event to touch the text editor.
3503 TestGenerateTap( application, 18.0f, 25.0f );
3505 application.SendNotification();
3506 application.Render();
3508 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3509 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3515 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3517 ToolkitTestApplication application;
3519 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3521 int lineCountBefore =0 ;
3522 int lineCountAfter =0 ;
3524 // Create a text editor
3525 TextEditor textEditor = TextEditor::New();
3526 //Set very large font-size using point-size
3527 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3528 //Specify font-family
3529 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3531 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3532 //Set text longer than width of textEditor
3533 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3535 application.GetScene().Add( textEditor );
3537 application.SendNotification();
3538 application.Render();
3540 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3541 //GetHeightForWidth is a retrieval method which should not modify object
3542 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3543 textEditor.GetHeightForWidth(200.f);
3545 //This is to simulate focus into text editor after calling GetHeightForWidth
3546 //Create a tap event to touch the text editor.
3547 TestGenerateTap( application, 18.0f, 25.0f );
3549 application.SendNotification();
3550 application.Render();
3552 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3554 //The LineCount must not be changed when calling GetHeightForWidth.
3555 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3560 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3562 ToolkitTestApplication application;
3564 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3566 int lineCountBefore =0 ;
3567 int lineCountAfter =0 ;
3569 // Create a text editor
3570 TextEditor textEditor = TextEditor::New();
3571 //Set very large font-size using point-size
3572 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3573 //Specify font-family
3574 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3576 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3577 //Set text longer than width of textEditor
3578 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3579 //Set line wrap mode Character
3580 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3582 application.GetScene().Add( textEditor );
3584 application.SendNotification();
3585 application.Render();
3587 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3588 //GetHeightForWidth is a retrieval method which should not modify object
3589 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3590 textEditor.GetHeightForWidth(200.f);
3592 //This is to simulate focus into text editor after calling GetHeightForWidth
3593 //Create a tap event to touch the text editor.
3594 TestGenerateTap( application, 18.0f, 25.0f );
3596 application.SendNotification();
3597 application.Render();
3599 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3601 //The LineCount must not be changed when calling GetHeightForWidth.
3602 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3607 int utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged(void)
3609 ToolkitTestApplication application;
3611 tet_infoline(" utcDaliTextEditorGetHeightForWidthChangeLineCountWhenTextChanged ");
3613 int lineCountBefore =0 ;
3614 int lineCountAfter =0 ;
3616 // Create a text editor
3617 TextEditor textEditor = TextEditor::New();
3618 //Set very large font-size using point-size
3619 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3620 //Specify font-family
3621 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3623 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
3624 //Set text longer than width of textEditor
3625 textEditor.SetProperty( TextEditor::Property::TEXT, "Short text");
3626 //Set line wrap mode Character
3627 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3629 application.GetScene().Add( textEditor );
3631 application.SendNotification();
3632 application.Render();
3635 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3637 textEditor.SetProperty( TextEditor::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
3638 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3640 // When the text changed, the Line-count should be updated according to new text.
3641 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
3642 DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
3643 DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
3650 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3652 ToolkitTestApplication application;
3654 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3656 int lineCountBefore =0 ;
3657 int lineCountAfter =0 ;
3659 // Create a text editor
3660 TextEditor textEditor = TextEditor::New();
3661 //Set very large font-size using point-size
3662 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3663 //Specify font-family
3664 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3666 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3667 //Set text longer than width of textEditor
3668 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3670 application.GetScene().Add( textEditor );
3672 application.SendNotification();
3673 application.Render();
3675 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3676 //GetNaturalSize is a retrieval method which should not modify object
3677 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3678 textEditor.GetNaturalSize();
3680 //This is to simulate focus into text editor after calling GetNaturalSize
3681 //Create a tap event to touch the text editor.
3682 TestGenerateTap( application, 18.0f, 25.0f );
3684 application.SendNotification();
3685 application.Render();
3687 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3689 //The LineCount must not be changed when calling GetNaturalSize.
3690 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3695 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3697 ToolkitTestApplication application;
3699 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3701 int lineCountBefore =0 ;
3702 int lineCountAfter =0 ;
3704 // Create a text editor
3705 TextEditor textEditor = TextEditor::New();
3706 //Set very large font-size using point-size
3707 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3708 //Specify font-family
3709 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3711 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3712 //Set text longer than width of textEditor
3713 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3714 //Set line wrap mode Character
3715 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3717 application.GetScene().Add( textEditor );
3719 application.SendNotification();
3720 application.Render();
3722 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3723 //GetNaturalSize is a retrieval method which should not modify object
3724 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3725 textEditor.GetNaturalSize( );
3727 //This is to simulate focus into text editor after calling GetNaturalSize
3728 //Create a tap event to touch the text editor.
3729 TestGenerateTap( application, 18.0f, 25.0f );
3731 application.SendNotification();
3732 application.Render();
3734 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3736 //The LineCount must not be changed when calling GetNaturalSize.
3737 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3742 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3744 ToolkitTestApplication application;
3745 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3747 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3748 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3749 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3751 // Create a text editor
3752 TextEditor textEditor = TextEditor::New();
3754 //Set size to avoid automatic eliding
3755 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3756 //Set very large font-size using point-size
3757 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3758 //Specify font-family
3759 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3760 //Set text to check if appear or not
3761 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3763 application.GetScene().Add( textEditor );
3765 application.SendNotification();
3766 application.Render();
3767 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3768 Vector3 naturalSize = textEditor.GetNaturalSize();
3770 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3771 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3776 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3778 ToolkitTestApplication application;
3779 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3781 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3782 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3783 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3785 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3786 // Create a text editor
3787 TextEditor textEditor = TextEditor::New();
3788 //Set size to avoid automatic eliding
3789 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3790 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3791 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3793 const int numberOfCases = 6;
3794 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3796 for (int index=0; index < numberOfCases; index++)
3798 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3799 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3800 application.GetScene().Add( textEditor );
3801 application.SendNotification();
3802 application.Render();
3803 naturalSize = textEditor.GetNaturalSize();
3804 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3805 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3812 int UtcDaliTextEditorHyphenWrapMode(void)
3814 ToolkitTestApplication application;
3815 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3818 TextEditor textEditor = TextEditor::New();
3820 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3822 application.GetScene().Add( textEditor );
3823 application.SendNotification();
3824 application.Render();
3826 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3827 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3828 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3830 application.SendNotification();
3831 application.Render();
3833 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3839 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3841 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3842 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3843 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3845 application.SendNotification();
3846 application.Render();
3848 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3855 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
3860 int UtcDaliToolkitTextEditorEllipsisPositionProperty(void)
3862 ToolkitTestApplication application;
3863 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty ");
3864 TextEditor textEditor = TextEditor::New();
3866 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Default is END");
3867 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3869 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START");
3870 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3871 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3873 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE");
3874 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3875 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3877 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END");
3878 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3879 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3881 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to START using integer");
3882 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 1);
3883 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3885 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to MIDDLE using integer");
3886 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 2);
3887 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3889 tet_infoline(" UtcDaliToolkitTextEditorEllipsisPositionProperty - Change to END using integer");
3890 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, 0);
3891 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3893 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3894 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "START");
3895 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3897 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3898 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "MIDDLE");
3899 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3901 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3902 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "END");
3903 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3905 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3906 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "start");
3907 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3909 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3910 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "middle");
3911 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3913 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3914 textEditor.SetProperty(DevelTextEditor::Property::ELLIPSIS_POSITION, "end");
3915 DALI_TEST_EQUALS( textEditor.GetProperty< int >( DevelTextEditor::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );