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";
110 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
111 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
113 const float RENDER_FRAME_INTERVAL = 16.66f;
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
118 const int KEY_A_CODE = 38;
119 const int KEY_D_CODE = 40;
120 const int KEY_C_CODE = 54;
121 const int KEY_V_CODE = 55;
122 const int KEY_X_CODE = 53;
123 const int KEY_WHITE_SPACE_CODE = 65;
125 const int KEY_SHIFT_MODIFIER = 257;
126 const int KEY_CONTROL_MODIFIER = 258;
128 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
129 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
130 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
132 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
134 static bool gAnchorClickedCallBackCalled;
135 static bool gAnchorClickedCallBackNotCalled;
136 static bool gTextChangedCallBackCalled;
137 static bool gInputStyleChangedCallbackCalled;
138 static bool gMaxCharactersCallBackCalled;
139 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
141 struct CallbackFunctor
143 CallbackFunctor(bool* callbackFlag)
144 : mCallbackFlag( callbackFlag )
150 *mCallbackFlag = true;
155 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
157 tet_infoline(" TestAnchorClickedCallback");
159 gAnchorClickedCallBackNotCalled = false;
161 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
163 gAnchorClickedCallBackCalled = true;
167 static void TestTextChangedCallback( TextEditor control )
169 tet_infoline(" TestTextChangedCallback");
171 gTextChangedCallBackCalled = true;
174 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
176 tet_infoline(" TestInputStyleChangedCallback");
178 gInputStyleChangedCallbackCalled = true;
179 gInputStyleMask = mask;
182 static void TestMaxLengthReachedCallback( TextEditor control )
184 tet_infoline(" TestMaxLengthReachedCallback");
186 gMaxCharactersCallBackCalled = true;
189 // Generate a KeyEvent to send to Core.
190 Integration::KeyEvent GenerateKey( const std::string& keyName,
191 const std::string& logicalKey,
192 const std::string& keyString,
195 unsigned long timeStamp,
196 const Integration::KeyEvent::State& keyState,
197 const std::string& compose = "",
198 const std::string& deviceName = DEFAULT_DEVICE_NAME,
199 const Device::Class::Type& deviceClass = Device::Class::NONE,
200 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
202 return Integration::KeyEvent( keyName,
215 Dali::Integration::Point GetPointDownInside( Vector2& pos )
217 Dali::Integration::Point point;
218 point.SetState( PointState::DOWN );
219 point.SetScreenPosition( pos );
223 Dali::Integration::Point GetPointUpInside( Vector2& pos )
225 Dali::Integration::Point point;
226 point.SetState( PointState::UP );
227 point.SetScreenPosition( pos );
231 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
233 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
235 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
237 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
239 Property::Value* valueSet = NULL;
240 if ( valueGet.first.type == Property::Key::INDEX )
242 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
246 // Get Key is a string so searching Set Map for a string key
247 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
250 if( NULL != valueSet )
252 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
254 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
257 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
259 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
262 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
264 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
267 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
269 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
272 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
274 Vector2 vector2Get = valueGet.second.Get<Vector2>();
275 Vector2 vector2Set = valueSet->Get<Vector2>();
276 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
279 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
281 Vector4 vector4Get = valueGet.second.Get<Vector4>();
282 Vector4 vector4Set = valueSet->Get<Vector4>();
283 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 );
289 if ( valueGet.first.type == Property::Key::INDEX )
291 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
295 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
305 class ScrollStateChangeCallback : public Dali::ConnectionTracker
308 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
309 : mStartedCalled( startedCalled ),
310 mFinishedCalled( finishedCalled )
314 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
316 if( type == TextEditor::Scroll::STARTED )
318 mStartedCalled = true;
320 else if( type == TextEditor::Scroll::FINISHED )
322 mFinishedCalled = true;
326 bool& mStartedCalled;
327 bool& mFinishedCalled;
332 int UtcDaliToolkitTextEditorConstructorP(void)
334 ToolkitTestApplication application;
335 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
336 TextEditor textEditor;
337 DALI_TEST_CHECK( !textEditor );
341 int UtcDaliToolkitTextEditorNewP(void)
343 ToolkitTestApplication application;
344 tet_infoline(" UtcDaliToolkitTextEditorNewP");
345 TextEditor textEditor = TextEditor::New();
346 DALI_TEST_CHECK( textEditor );
350 int UtcDaliToolkitTextEditorDownCastP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
354 TextEditor textEditor1 = TextEditor::New();
355 BaseHandle object( textEditor1 );
357 TextEditor textEditor2 = TextEditor::DownCast( object );
358 DALI_TEST_CHECK( textEditor2 );
360 TextEditor textEditor3 = DownCast< TextEditor >( object );
361 DALI_TEST_CHECK( textEditor3 );
365 int UtcDaliToolkitTextEditorDownCastN(void)
367 ToolkitTestApplication application;
368 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
369 BaseHandle uninitializedObject;
370 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
371 DALI_TEST_CHECK( !textEditor1 );
373 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
374 DALI_TEST_CHECK( !textEditor2 );
378 int UtcDaliToolkitTextEditorCopyConstructorP(void)
380 ToolkitTestApplication application;
381 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
382 TextEditor textEditor = TextEditor::New();
383 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
385 TextEditor copy( textEditor );
386 DALI_TEST_CHECK( copy );
387 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
391 int UtcDaliTextEditorMoveConstructor(void)
393 ToolkitTestApplication application;
395 TextEditor textEditor = TextEditor::New();
396 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
397 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
399 TextEditor moved = std::move( textEditor );
400 DALI_TEST_CHECK( moved );
401 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
402 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
403 DALI_TEST_CHECK( !textEditor );
408 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
412 TextEditor textEditor = TextEditor::New();
413 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
415 TextEditor copy = textEditor;
416 DALI_TEST_CHECK( copy );
417 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
421 int UtcDaliTextEditorMoveAssignment(void)
423 ToolkitTestApplication application;
425 TextEditor textEditor = TextEditor::New();
426 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
427 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
430 moved = std::move( textEditor );
431 DALI_TEST_CHECK( moved );
432 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
433 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
434 DALI_TEST_CHECK( !textEditor );
439 int UtcDaliTextEditorNewP(void)
441 ToolkitTestApplication application;
442 tet_infoline(" UtcDaliToolkitTextEditorNewP");
443 TextEditor textEditor = TextEditor::New();
444 DALI_TEST_CHECK( textEditor );
448 // Positive test case for a method
449 int UtcDaliTextEditorGetPropertyP(void)
451 ToolkitTestApplication application;
452 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
453 TextEditor editor = TextEditor::New();
454 DALI_TEST_CHECK( editor );
456 // Check Property Indices are correct
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP );
520 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
523 Property::Map imageMap;
524 imageMap[mapKey] =mapValue;
526 editor.SetProperty( property , imageMap );
527 Property::Value propValue = editor.GetProperty( property );
528 Property::Map* resultMap = propValue.GetMap();
530 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
538 // Positive test case for a method
539 int UtcDaliTextEditorSetPropertyP(void)
541 ToolkitTestApplication application;
542 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
543 TextEditor editor = TextEditor::New();
544 DALI_TEST_CHECK( editor );
545 application.GetScene().Add( editor );
547 // Note - we can't check the defaults since the stylesheets are platform-specific
549 // Check the render backend property.
550 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
551 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
553 // Check text property.
554 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
555 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
557 // Check text's color property
558 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
559 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
561 // Check font properties.
562 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
563 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
565 Property::Map fontStyleMapSet;
566 Property::Map fontStyleMapGet;
567 Property::Value* slantValue = NULL;
569 fontStyleMapSet.Insert( "weight", "bold" );
570 fontStyleMapSet.Insert( "width", "condensed" );
571 fontStyleMapSet.Insert( "slant", "italic" );
573 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
574 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
575 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
576 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
578 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
579 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
581 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
582 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
583 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
586 fontStyleMapSet.Clear();
587 fontStyleMapSet.Insert( "weight", "normal" );
588 fontStyleMapSet.Insert( "slant", "oblique" );
589 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
590 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
591 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
594 fontStyleMapSet.Clear();
595 fontStyleMapSet.Insert( "slant", "roman" );
596 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
597 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
599 // Replace 'roman' for 'normal'.
600 slantValue = fontStyleMapGet.Find( "slant" );
601 if( NULL != slantValue )
603 if( "normal" == slantValue->Get<std::string>() )
605 fontStyleMapGet["slant"] = "roman";
608 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
609 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
611 fontStyleMapSet.Clear();
613 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
614 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
615 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
616 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
618 // Check that the Alignment properties can be correctly set
619 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
620 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
622 // Check scroll properties.
623 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
624 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
625 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
626 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
628 // Check cursor properties
629 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
630 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
631 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
632 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
634 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
635 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
636 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
637 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
638 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
639 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
640 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
641 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
643 // Check handle images
644 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
645 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
646 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
647 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
648 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
650 // Check handle images
651 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
652 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
653 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
654 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
655 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
656 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
658 // Check the highlight color
659 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
660 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
662 // Decoration bounding box
663 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
664 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
666 // Check the enable markup property.
667 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
668 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
669 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
671 // Check input color property.
672 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
673 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
675 // Check input font properties.
676 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
677 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
679 fontStyleMapSet.Clear();
680 fontStyleMapSet.Insert( "weight", "bold" );
681 fontStyleMapSet.Insert( "width", "condensed" );
682 fontStyleMapSet.Insert( "slant", "italic" );
684 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
685 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
686 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
687 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
689 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
690 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
692 // Reset input font style.
693 fontStyleMapSet.Clear();
694 fontStyleMapSet.Insert( "weight", "normal" );
695 fontStyleMapSet.Insert( "slant", "oblique" );
697 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
698 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
699 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
700 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
702 fontStyleMapSet.Clear();
703 fontStyleMapSet.Insert( "slant", "roman" );
705 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
706 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
708 // Replace 'roman' for 'normal'.
709 slantValue = fontStyleMapGet.Find( "slant" );
710 if( NULL != slantValue )
712 if( "normal" == slantValue->Get<std::string>() )
714 fontStyleMapGet["slant"] = "roman";
717 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
718 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
720 fontStyleMapSet.Clear();
722 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
723 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
724 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
725 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
727 // Check the line spacing property
728 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
729 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
730 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
732 // Check the input line spacing property
733 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
734 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
735 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
737 // Check the underline property
739 Property::Map underlineMapSet;
740 Property::Map underlineMapGet;
742 underlineMapSet.Insert( "enable", true );
743 underlineMapSet.Insert( "color", Color::RED );
744 underlineMapSet.Insert( "height", 1 );
746 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
748 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
749 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
750 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
752 // Check the input underline property
753 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
754 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
756 // Check the shadow property
757 Property::Map shadowMapSet;
758 Property::Map shadowMapGet;
760 shadowMapSet.Insert( "color", Color::GREEN );
761 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
762 shadowMapSet.Insert( "blurRadius", 3.0f );
764 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
766 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
767 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
768 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
770 // Check the input shadow property
771 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
772 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
774 // Check the emboss property
775 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
776 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
778 // Check the input emboss property
779 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
780 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
782 // Check the outline property
784 // Test string type first
785 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
786 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
787 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
789 // Then test the property map type
790 Property::Map outlineMapSet;
791 Property::Map outlineMapGet;
793 outlineMapSet["color"] = Color::RED;
794 outlineMapSet["width"] = 2.0f;
796 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
798 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
799 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
800 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
802 // Check the input outline property
803 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
804 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
806 // Check the smooth scroll property
807 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
808 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
809 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
811 // Check the smooth scroll duration property
812 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
813 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
815 // Check the scroll bar property
816 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
817 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
818 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
820 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
821 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
822 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
823 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
825 // Check the pixel size of font
826 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
827 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
829 // Check placeholder text properties.
830 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
831 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
833 // Check placeholder text's color property.
834 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
835 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
837 // Check the enable selection property
838 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
839 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
841 // Check the placeholder property with pixel size
842 Property::Map placeholderPixelSizeMapSet;
843 Property::Map placeholderPixelSizeMapGet;
844 Property::Map placeholderFontstyleMap;
845 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
846 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
847 placeholderPixelSizeMapSet["color"] = Color::BLUE;
848 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
849 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
851 placeholderFontstyleMap.Insert( "weight", "bold" );
852 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
853 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
855 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
856 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
858 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
859 Property::Map placeholderConversionMap;
860 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
861 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
862 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
863 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
864 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
865 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
867 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
869 // Check the placeholder property with point size
870 Property::Map placeholderMapSet;
871 Property::Map placeholderMapGet;
872 placeholderMapSet["text"] = "Setting Placeholder Text";
873 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
874 placeholderMapSet["color"] = Color::RED;
875 placeholderMapSet["fontFamily"] = "Arial";
876 placeholderMapSet["pointSize"] = 12.0f;
877 // Check the placeholder font style property
878 placeholderFontstyleMap.Clear();
880 placeholderFontstyleMap.Insert( "weight", "bold" );
881 placeholderFontstyleMap.Insert( "width", "condensed" );
882 placeholderFontstyleMap.Insert( "slant", "italic" );
883 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
884 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
886 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
887 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
889 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
890 placeholderConversionMap.Clear();
891 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
892 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
893 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
894 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
895 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
896 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
897 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
900 placeholderFontstyleMap.Clear();
901 placeholderFontstyleMap.Insert( "weight", "normal" );
902 placeholderFontstyleMap.Insert( "slant", "oblique" );
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 );
908 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
909 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
911 placeholderFontstyleMap.Clear();
912 placeholderFontstyleMap.Insert( "slant", "roman" );
913 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
914 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
916 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
918 placeholderFontstyleMap.Clear();
919 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
921 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
922 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
923 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
924 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
925 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
927 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
928 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
930 // Check handle color
931 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
932 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
934 // Test the ENABLE_GRAB_HANDLE_POPUP property
935 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP, false );
936 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE_POPUP ), false, TEST_LOCATION);
938 application.SendNotification();
939 application.Render();
944 // Positive Atlas Text Renderer test
945 int utcDaliTextEditorAtlasRenderP(void)
947 ToolkitTestApplication application;
948 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
949 StyleManager styleManager = StyleManager::Get();
950 styleManager.ApplyDefaultTheme();
951 TextEditor editor = TextEditor::New();
952 DALI_TEST_CHECK( editor );
954 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
956 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
958 application.GetScene().Add( editor );
962 // Render some text with the shared atlas backend
963 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
964 application.SendNotification();
965 application.Render();
969 tet_result(TET_FAIL);
974 // Positive test for the anchorClicked signal.
975 int utcDaliTextEditorAnchorClickedP(void)
977 ToolkitTestApplication application;
978 tet_infoline(" utcDaliTextEditorAnchorClickedP");
979 TextEditor editor = TextEditor::New();
980 DALI_TEST_CHECK(editor);
982 application.GetScene().Add(editor);
984 // connect to the anchor clicked signal.
985 ConnectionTracker* testTracker = new ConnectionTracker();
986 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
987 bool anchorClickedSignal = false;
988 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
990 gAnchorClickedCallBackCalled = false;
991 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
992 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
993 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
994 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
995 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
997 application.SendNotification();
998 application.Render();
999 editor.SetKeyInputFocus();
1001 // Create a tap event to touch the text editor.
1002 TestGenerateTap(application, 5.0f, 5.0f);
1003 application.SendNotification();
1004 application.Render();
1006 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1007 DALI_TEST_CHECK(anchorClickedSignal);
1009 gAnchorClickedCallBackNotCalled = true;
1010 // Tap the outside of anchor, callback should not be called.
1011 TestGenerateTap(application, 150.f, 100.f);
1012 application.SendNotification();
1013 application.Render();
1015 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1020 // Positive test for the textChanged signal.
1021 int utcDaliTextEditorTextChangedP(void)
1023 ToolkitTestApplication application;
1024 tet_infoline(" utcDaliTextEditorTextChangedP");
1025 TextEditor editor = TextEditor::New();
1026 DALI_TEST_CHECK( editor );
1028 application.GetScene().Add( editor );
1030 // connect to the text changed signal.
1031 ConnectionTracker* testTracker = new ConnectionTracker();
1032 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1033 bool textChangedSignal = false;
1034 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1036 gTextChangedCallBackCalled = false;
1037 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1038 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1039 DALI_TEST_CHECK( textChangedSignal );
1041 application.SendNotification();
1042 editor.SetKeyInputFocus();
1044 gTextChangedCallBackCalled = false;
1045 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1046 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1049 editor.SetProperty( TextField::Property::TEXT, "" );
1051 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1052 gTextChangedCallBackCalled = false;
1053 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1054 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1056 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1057 gTextChangedCallBackCalled = false;
1058 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1059 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1064 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1066 ToolkitTestApplication application;
1067 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1068 TextEditor editor = TextEditor::New();
1069 DALI_TEST_CHECK( editor );
1072 application.GetScene().Add( editor );
1074 // connect to the text changed signal.
1075 ConnectionTracker* testTracker = new ConnectionTracker();
1076 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1077 bool textChangedSignal = false;
1078 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1081 // get InputMethodContext
1083 InputMethodContext::EventData imfEvent;
1084 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1086 editor.SetKeyInputFocus();
1087 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1090 gTextChangedCallBackCalled = false;
1091 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1092 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1093 application.SendNotification();
1094 application.Render();
1095 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1096 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1098 gTextChangedCallBackCalled = false;
1099 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1100 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1101 application.SendNotification();
1102 application.Render();
1103 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1104 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1106 gTextChangedCallBackCalled = false;
1107 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1108 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1109 application.SendNotification();
1110 application.Render();
1111 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1112 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1114 gTextChangedCallBackCalled = false;
1115 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1116 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1117 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1119 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1120 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1121 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1123 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1124 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1125 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1127 application.SendNotification();
1128 application.Render();
1129 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1130 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1136 int utcDaliTextEditorInputStyleChanged01(void)
1138 // The text-editor emits signals when the input style changes. These changes of style are
1139 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1140 // can't be emitted during the size negotiation as the callbacks may update the UI.
1141 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1142 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1143 ToolkitTestApplication application;
1144 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1148 char* pathNamePtr = get_current_dir_name();
1149 const std::string pathName( pathNamePtr );
1150 free( pathNamePtr );
1152 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1153 fontClient.SetDpi( 93u, 93u );
1155 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1156 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1158 TextEditor editor = TextEditor::New();
1159 DALI_TEST_CHECK( editor );
1162 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1163 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1164 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1166 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1167 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1169 // connect to the text changed signal.
1170 ConnectionTracker* testTracker = new ConnectionTracker();
1171 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1172 bool inputStyleChangedSignal = false;
1173 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1175 application.GetScene().Add( editor );
1177 // Render and notify
1178 application.SendNotification();
1179 application.Render();
1181 // Executes the idle callbacks added by the text control on the change of input style.
1182 application.RunIdles();
1184 gInputStyleChangedCallbackCalled = false;
1185 gInputStyleMask = TextEditor::InputStyle::NONE;
1186 inputStyleChangedSignal = false;
1188 // Create a tap event to touch the text editor.
1189 TestGenerateTap( application, 18.0f, 25.0f );
1191 // Render and notify
1192 application.SendNotification();
1193 application.Render();
1195 // Executes the idle callbacks added by the text control on the change of input style.
1196 application.RunIdles();
1198 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1199 if( gInputStyleChangedCallbackCalled )
1201 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1203 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1204 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1206 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1207 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1209 DALI_TEST_CHECK( inputStyleChangedSignal );
1211 gInputStyleChangedCallbackCalled = false;
1212 gInputStyleMask = TextEditor::InputStyle::NONE;
1213 inputStyleChangedSignal = false;
1215 // Create a tap event to touch the text editor.
1216 TestGenerateTap( application, 30.0f, 25.0f );
1218 // Render and notify
1219 application.SendNotification();
1220 application.Render();
1222 // Executes the idle callbacks added by the text control on the change of input style.
1223 application.RunIdles();
1225 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1226 DALI_TEST_CHECK( !inputStyleChangedSignal );
1228 gInputStyleChangedCallbackCalled = false;
1229 gInputStyleMask = TextEditor::InputStyle::NONE;
1230 inputStyleChangedSignal = false;
1232 // Create a tap event to touch the text editor.
1233 TestGenerateTap( application, 43.0f, 25.0f );
1235 // Render and notify
1236 application.SendNotification();
1237 application.Render();
1239 // Executes the idle callbacks added by the text control on the change of input style.
1240 application.RunIdles();
1242 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1243 if( gInputStyleChangedCallbackCalled )
1245 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1247 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1248 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1250 DALI_TEST_CHECK( inputStyleChangedSignal );
1252 gInputStyleChangedCallbackCalled = false;
1253 gInputStyleMask = TextEditor::InputStyle::NONE;
1254 inputStyleChangedSignal = false;
1256 // Create a tap event to touch the text editor.
1257 TestGenerateTap( application, 88.0f, 25.0f );
1259 // Render and notify
1260 application.SendNotification();
1261 application.Render();
1263 // Executes the idle callbacks added by the text control on the change of input style.
1264 application.RunIdles();
1266 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1267 if( gInputStyleChangedCallbackCalled )
1269 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1271 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1272 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1274 Property::Map fontStyleMapSet;
1275 Property::Map fontStyleMapGet;
1277 fontStyleMapSet.Insert( "weight", "bold" );
1279 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1280 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1281 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1283 DALI_TEST_CHECK( inputStyleChangedSignal );
1285 gInputStyleChangedCallbackCalled = false;
1286 gInputStyleMask = TextEditor::InputStyle::NONE;
1287 inputStyleChangedSignal = false;
1289 // Create a tap event to touch the text editor.
1290 TestGenerateTap( application, 115.0f, 25.0f );
1292 // Render and notify
1293 application.SendNotification();
1294 application.Render();
1296 // Executes the idle callbacks added by the text control on the change of input style.
1297 application.RunIdles();
1299 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1300 DALI_TEST_CHECK( !inputStyleChangedSignal );
1302 gInputStyleChangedCallbackCalled = false;
1303 gInputStyleMask = TextEditor::InputStyle::NONE;
1304 inputStyleChangedSignal = false;
1306 // Create a tap event to touch the text editor.
1307 TestGenerateTap( application, 164.0f, 25.0f );
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 // Executes the idle callbacks added by the text control on the change of input style.
1314 application.RunIdles();
1316 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1317 if( gInputStyleChangedCallbackCalled )
1319 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1321 Property::Map fontStyleMapSet;
1322 Property::Map fontStyleMapGet;
1324 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1325 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1326 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1328 DALI_TEST_CHECK( inputStyleChangedSignal );
1330 gInputStyleChangedCallbackCalled = false;
1331 gInputStyleMask = TextEditor::InputStyle::NONE;
1332 inputStyleChangedSignal = false;
1334 // Create a tap event to touch the text editor.
1335 TestGenerateTap( application, 191.0f, 25.0f );
1337 // Render and notify
1338 application.SendNotification();
1339 application.Render();
1341 // Executes the idle callbacks added by the text control on the change of input style.
1342 application.RunIdles();
1344 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1345 DALI_TEST_CHECK( !inputStyleChangedSignal );
1350 int utcDaliTextEditorInputStyleChanged02(void)
1352 // The text-editor emits signals when the input style changes. These changes of style are
1353 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1354 // can't be emitted during the size negotiation as the callbacks may update the UI.
1355 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1356 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1357 ToolkitTestApplication application;
1358 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1362 char* pathNamePtr = get_current_dir_name();
1363 const std::string pathName( pathNamePtr );
1364 free( pathNamePtr );
1366 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1367 fontClient.SetDpi( 93u, 93u );
1369 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1370 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1372 TextEditor editor = TextEditor::New();
1373 DALI_TEST_CHECK( editor );
1376 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1377 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1378 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1380 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1381 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>" );
1383 // connect to the text changed signal.
1384 ConnectionTracker* testTracker = new ConnectionTracker();
1385 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1386 bool inputStyleChangedSignal = false;
1387 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1389 application.GetScene().Add( editor );
1391 // Render and notify
1392 application.SendNotification();
1393 application.Render();
1395 // Executes the idle callbacks added by the text control on the change of input style.
1396 application.RunIdles();
1398 gInputStyleChangedCallbackCalled = false;
1399 gInputStyleMask = TextEditor::InputStyle::NONE;
1400 inputStyleChangedSignal = false;
1402 // Create a tap event to touch the text editor.
1403 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1404 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1406 // Render and notify
1407 application.SendNotification();
1408 application.Render();
1410 // Executes the idle callbacks added by the text control on the change of input style.
1411 application.RunIdles();
1413 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1414 if( gInputStyleChangedCallbackCalled )
1416 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1417 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1418 TextEditor::InputStyle::POINT_SIZE |
1419 TextEditor::InputStyle::COLOR ),
1422 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1423 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1425 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1426 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1428 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1429 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1431 DALI_TEST_CHECK( inputStyleChangedSignal );
1433 gInputStyleChangedCallbackCalled = false;
1434 gInputStyleMask = TextEditor::InputStyle::NONE;
1435 inputStyleChangedSignal = false;
1437 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1439 // Render and notify
1440 application.SendNotification();
1441 application.Render();
1443 // Executes the idle callbacks added by the text control on the change of input style.
1444 application.RunIdles();
1446 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1447 if( gInputStyleChangedCallbackCalled )
1449 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1450 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1453 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1454 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1456 DALI_TEST_CHECK( inputStyleChangedSignal );
1458 gInputStyleChangedCallbackCalled = false;
1459 gInputStyleMask = TextEditor::InputStyle::NONE;
1460 inputStyleChangedSignal = false;
1462 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1464 // Render and notify
1465 application.SendNotification();
1466 application.Render();
1468 // Executes the idle callbacks added by the text control on the change of input style.
1469 application.RunIdles();
1471 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1472 DALI_TEST_CHECK( !inputStyleChangedSignal );
1474 gInputStyleChangedCallbackCalled = false;
1475 gInputStyleMask = TextEditor::InputStyle::NONE;
1476 inputStyleChangedSignal = false;
1478 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1480 // Render and notify
1481 application.SendNotification();
1482 application.Render();
1484 // Executes the idle callbacks added by the text control on the change of input style.
1485 application.RunIdles();
1487 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1488 if( gInputStyleChangedCallbackCalled )
1490 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1491 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1494 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1495 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1497 DALI_TEST_CHECK( inputStyleChangedSignal );
1499 gInputStyleChangedCallbackCalled = false;
1500 gInputStyleMask = TextEditor::InputStyle::NONE;
1501 inputStyleChangedSignal = false;
1503 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1505 Property::Map fontStyleMapSet;
1506 fontStyleMapSet.Insert( "weight", "thin" );
1507 fontStyleMapSet.Insert( "width", "condensed" );
1508 fontStyleMapSet.Insert( "slant", "italic" );
1510 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1511 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1512 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1514 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1515 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1516 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1517 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1519 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 // Executes the idle callbacks added by the text control on the change of input style.
1526 application.RunIdles();
1528 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1529 DALI_TEST_CHECK( !inputStyleChangedSignal );
1531 // Create a tap event to touch the text editor.
1532 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1534 // Render and notify
1535 application.SendNotification();
1536 application.Render();
1538 // Executes the idle callbacks added by the text control on the change of input style.
1539 application.RunIdles();
1541 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1542 if( gInputStyleChangedCallbackCalled )
1544 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1545 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1546 TextEditor::InputStyle::POINT_SIZE |
1547 TextEditor::InputStyle::FONT_STYLE |
1548 TextEditor::InputStyle::LINE_SPACING |
1549 TextEditor::InputStyle::UNDERLINE |
1550 TextEditor::InputStyle::SHADOW |
1551 TextEditor::InputStyle::EMBOSS |
1552 TextEditor::InputStyle::OUTLINE ),
1555 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1556 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1558 DALI_TEST_CHECK( inputStyleChangedSignal );
1560 gInputStyleChangedCallbackCalled = false;
1561 gInputStyleMask = TextEditor::InputStyle::NONE;
1562 inputStyleChangedSignal = false;
1564 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1566 fontStyleMapSet.Clear();
1567 fontStyleMapSet.Insert( "weight", "black" );
1568 fontStyleMapSet.Insert( "width", "expanded" );
1569 fontStyleMapSet.Insert( "slant", "oblique" );
1571 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1573 // Create a tap event to touch the text editor.
1574 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Executes the idle callbacks added by the text control on the change of input style.
1581 application.RunIdles();
1583 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1584 if( gInputStyleChangedCallbackCalled )
1586 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1587 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1588 TextEditor::InputStyle::POINT_SIZE |
1589 TextEditor::InputStyle::FONT_STYLE ),
1592 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1593 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1595 DALI_TEST_CHECK( inputStyleChangedSignal );
1600 int utcDaliTextEditorEvent01(void)
1602 ToolkitTestApplication application;
1603 tet_infoline(" utcDaliTextEditorEvent01");
1605 // Creates a tap event. After creating a tap event the text editor should
1606 // have the focus and add text with key events should be possible.
1608 TextEditor editor = TextEditor::New();
1609 DALI_TEST_CHECK( editor );
1611 application.GetScene().Add( editor );
1613 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1614 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1615 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1617 // Avoid a crash when core load gl resources.
1618 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1620 // Render and notify
1621 application.SendNotification();
1622 application.Render();
1624 // Add a key event but as the text editor has not the focus it should do nothing.
1625 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1627 // Render and notify
1628 application.SendNotification();
1629 application.Render();
1631 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1633 // Create a tap event to touch the text editor.
1634 TestGenerateTap( application, 150.0f, 25.0f );
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Now the text editor has the focus, so it can handle the key events.
1641 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1642 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1650 // Create a second text editor and send key events to it.
1651 TextEditor editor2 = TextEditor::New();
1653 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1654 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1655 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1656 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1658 application.GetScene().Add( editor2 );
1660 // Render and notify
1661 application.SendNotification();
1662 application.Render();
1664 // Create a tap event on the second text editor.
1665 TestGenerateTap( application, 150.0f, 125.0f );
1667 // Render and notify
1668 application.SendNotification();
1669 application.Render();
1671 // The second text editor has the focus. It should handle the key events.
1672 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1673 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1675 // Render and notify
1676 application.SendNotification();
1677 application.Render();
1679 // Check the text has been added to the second text editor.
1680 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1685 int utcDaliTextEditorEvent02(void)
1687 ToolkitTestApplication application;
1688 tet_infoline(" utcDaliTextEditorEvent02");
1690 // Checks if the right number of actors are created.
1692 TextEditor editor = TextEditor::New();
1693 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1694 DALI_TEST_CHECK( editor );
1696 application.GetScene().Add( editor );
1698 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1699 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1700 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1702 // Avoid a crash when core load gl resources.
1703 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1705 // Render and notify
1706 application.SendNotification();
1707 application.Render();
1709 // Check there are the expected number of children (the stencil).
1710 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1712 Actor stencil = editor.GetChildAt( 0u );
1714 // Create a tap event to touch the text editor.
1715 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1717 // Render and notify
1718 application.SendNotification();
1719 application.Render();
1721 Actor layer = editor.GetChildAt( 1u );
1722 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1723 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1725 // Now the text editor has the focus, so it can handle the key events.
1726 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1727 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1729 // Render and notify
1730 application.SendNotification();
1731 application.Render();
1733 // Checks the cursor and the renderer have been created.
1734 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1735 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1737 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1738 DALI_TEST_CHECK( cursor );
1740 // The stencil actor has a container with all the actors which contain the text renderers.
1741 Actor container = stencil.GetChildAt( 0u );
1742 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1744 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1745 DALI_TEST_CHECK( renderer );
1748 // Move the cursor and check the position changes.
1749 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1751 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1752 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1754 // Render and notify
1755 application.SendNotification();
1756 application.Render();
1758 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1760 DALI_TEST_CHECK( position2.x < position1.x );
1762 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1763 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1771 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1773 // Send some taps and check the cursor positions.
1775 // Try to tap at the beginning.
1776 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 // Cursor position should be the same than position1.
1783 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1785 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1787 // Tap away from the start position.
1788 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1790 // Render and notify
1791 application.SendNotification();
1792 application.Render();
1794 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1796 DALI_TEST_CHECK( position5.x > position4.x );
1798 // Remove all the text.
1799 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1800 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1801 editor.SetProperty( TextEditor::Property::TEXT, "" );
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 // Cursor position should be the same than position2.
1808 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1810 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1812 // Should not be a renderer.
1813 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1818 int utcDaliTextEditorEvent03(void)
1820 ToolkitTestApplication application;
1821 tet_infoline(" utcDaliTextEditorEvent03");
1823 // Checks if the highlight actor is created.
1825 TextEditor editor = TextEditor::New();
1826 DALI_TEST_CHECK( editor );
1828 application.GetScene().Add( editor );
1830 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1831 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1832 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1833 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1834 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1836 // Avoid a crash when core load gl resources.
1837 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 // Send some taps and check text controller with clipboard window
1844 Dali::Clipboard clipboard = Clipboard::Get();
1845 clipboard.ShowClipboard();
1846 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1847 clipboard.HideClipboard();
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1853 // Tap first to get the focus.
1854 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 // Double tap to select a word.
1861 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 // The stencil actor should have two actors: the renderer and the highlight actor.
1868 Actor stencil = editor.GetChildAt( 0u );
1870 // Highlight needs to be drawn before text, so should come first in child order
1871 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1872 DALI_TEST_CHECK( highlight );
1874 // The stencil actor has a container with all the actors which contain the text renderers.
1875 Actor container = stencil.GetChildAt( 1u );
1876 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1878 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1879 DALI_TEST_CHECK( renderer );
1882 // Double tap out of bounds
1883 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1884 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1886 // Render and notify
1887 application.SendNotification();
1888 application.Render();
1890 // The stencil actor should have one actors: the renderer actor.
1891 stencil = editor.GetChildAt( 0u );
1893 // The stencil actor has a container with all the actors which contain the text renderers.
1894 container = stencil.GetChildAt( 0u );
1895 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1897 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1898 DALI_TEST_CHECK( renderer );
1902 TestGenerateLongPress(application, 1.0f, 25.0f);
1904 // Render and notify
1905 application.SendNotification();
1906 application.Render();
1909 TestGenerateMiniPan(application);
1911 // Render and notify
1912 application.SendNotification();
1913 application.Render();
1918 int utcDaliTextEditorEvent04(void)
1920 ToolkitTestApplication application;
1921 tet_infoline(" utcDaliTextEditorEvent04");
1923 // Checks if the highlight actor is created.
1925 TextEditor editor = TextEditor::New();
1926 DALI_TEST_CHECK( editor );
1928 application.GetScene().Add( editor );
1930 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1931 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1932 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1933 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1934 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1936 // Avoid a crash when core load gl resources.
1937 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1939 // Render and notify
1940 application.SendNotification();
1941 application.Render();
1943 // Tap on the text editor
1944 TestGenerateTap( application, 3.0f, 25.0f );
1946 // Render and notify
1947 application.SendNotification();
1948 application.Render();
1950 // Move at the end of the text.
1951 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1952 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1958 for( unsigned int index = 0u; index < 10u; ++index )
1960 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1961 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1963 // Render and notify
1964 application.SendNotification();
1965 application.Render();
1969 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1977 // Add some key events
1978 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1979 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1981 // Render and notify
1982 application.SendNotification();
1983 application.Render();
1985 for( unsigned int index = 0u; index < 10u; ++index )
1987 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1988 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1996 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1998 // Render and notify
1999 application.SendNotification();
2000 application.Render();
2002 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2007 int utcDaliTextEditorEvent05(void)
2009 ToolkitTestApplication application;
2010 tet_infoline(" utcDaliTextEditorEvent05");
2012 // Checks if the highlight actor is created.
2014 TextEditor editor = TextEditor::New();
2015 DALI_TEST_CHECK( editor );
2017 application.GetScene().Add( editor );
2019 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2020 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2021 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2022 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2023 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2024 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2025 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2026 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2027 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2028 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2030 // Avoid a crash when core load gl resources.
2031 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2033 // Render and notify
2034 application.SendNotification();
2035 application.Render();
2037 // Tap on the text editor
2038 TestGenerateTap( application, 3.0f, 25.0f );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2044 // Move at the end of the text.
2045 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 for( unsigned int index = 0u; index < 10u; ++index )
2055 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2061 // Modify duration after scroll is enabled
2062 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2064 // Continuous scroll left to increase coverage
2065 for( unsigned int index = 0u; index < 10u; ++index )
2067 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2069 // Render and notify
2070 application.SendNotification();
2071 application.Render();
2073 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2074 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2075 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2076 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2077 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2079 // Press Escape to increase coverage
2080 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081 application.SendNotification();
2082 application.Render();
2084 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2089 int utcDaliTextEditorEvent06(void)
2091 ToolkitTestApplication application;
2092 tet_infoline(" utcDaliTextEditorEvent06");
2094 // Checks if the highlight actor is created.
2096 TextEditor editor = TextEditor::New();
2097 DALI_TEST_CHECK( editor );
2099 application.GetScene().Add( editor );
2101 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2102 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2103 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2104 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2105 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2107 // Avoid a crash when core load gl resources.
2108 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2110 // Render and notify
2111 application.SendNotification();
2112 application.Render();
2114 // Tap on the text editor
2115 TestGenerateTap( application, 3.0f, 25.0f );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2121 // Move to seconds line of the text.
2122 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2124 // Render and notify
2125 application.SendNotification();
2126 application.Render();
2128 float layoutHeight = editor.GetHeightForWidth( 100.f );
2131 // Add another script characters ( glyph height is defferent )
2132 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2133 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2135 // Delete characters
2136 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2139 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2141 // Render and notify
2142 application.SendNotification();
2143 application.Render();
2145 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2148 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 application.SendNotification();
2150 application.Render();
2152 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2153 application.SendNotification();
2154 application.Render();
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 application.SendNotification();
2158 application.Render();
2160 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2161 application.SendNotification();
2162 application.Render();
2164 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 application.SendNotification();
2166 application.Render();
2168 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169 application.SendNotification();
2170 application.Render();
2172 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2173 application.SendNotification();
2174 application.Render();
2179 int utcDaliTextEditorEvent07(void)
2181 ToolkitTestApplication application;
2182 tet_infoline(" utcDaliTextEditorEvent07");
2184 // Checks if the highlight actor is created.
2186 TextEditor editor = TextEditor::New();
2187 DALI_TEST_CHECK( editor );
2189 application.GetScene().Add( editor );
2191 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2192 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2193 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2194 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2195 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2197 // Avoid a crash when core load gl resources.
2198 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2200 // Render and notify
2201 application.SendNotification();
2202 application.Render();
2204 // Tap on the text editor
2205 TestGenerateTap( application, 3.0f, 25.0f );
2207 // Render and notify
2208 application.SendNotification();
2209 application.Render();
2211 // Move to second line of the text.
2212 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2214 // Render and notify
2215 application.SendNotification();
2216 application.Render();
2218 // Select some text in the right of the current cursor position
2219 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2222 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2224 // Render and notify
2225 application.SendNotification();
2226 application.Render();
2228 // Cut the selected text
2229 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2230 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 ) );
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2236 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2238 // Select some text in the left of the current cursor position
2239 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2244 // Render and notify
2245 application.SendNotification();
2246 application.Render();
2248 // Copy the selected text
2249 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2250 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 ) );
2252 // Render and notify
2253 application.SendNotification();
2254 application.Render();
2256 // Move the cursor to the third line
2257 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2258 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2264 // Paste the selected text at the current cursor position
2265 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2266 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 ) );
2268 // Render and notify
2269 application.SendNotification();
2270 application.Render();
2272 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2275 // Disable Shift Selection
2276 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2278 // Test to select some text in the right of the current cursor position
2279 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284 // Render and notify
2285 application.SendNotification();
2286 application.Render();
2288 // Cut the selected text
2289 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 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 ) );
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2296 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2297 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2299 // Test to select some text in the left of the current cursor position
2300 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 // Copy the selected text
2310 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2311 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 ) );
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2317 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2318 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2321 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 ) );
2323 // Render and notify
2324 application.SendNotification();
2325 application.Render();
2327 // replace text with "c"
2328 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2330 // Render and notify
2331 application.SendNotification();
2332 application.Render();
2335 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2338 DevelTextEditor::SelectWholeText(editor);
2340 // Render and notify
2341 application.SendNotification();
2342 application.Render();
2344 // Copy the selected text using logical keys
2345 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2348 // Render and notify
2349 application.SendNotification();
2350 application.Render();
2353 DevelTextEditor::SelectNone(editor);
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 // Paste the selected using logical keys
2360 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2366 // select all using logical keys
2367 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370 // Render and notify
2371 application.SendNotification();
2372 application.Render();
2374 // cut text using logical keys
2375 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 // Render and notify
2379 application.SendNotification();
2380 application.Render();
2383 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2388 int utcDaliTextEditorEvent08(void)
2390 ToolkitTestApplication application;
2391 tet_infoline(" utcDaliTextEditorEvent08");
2393 // Checks if the highlight actor is released correctly.
2395 TextEditor editor = TextEditor::New();
2396 DALI_TEST_CHECK( editor );
2398 application.GetScene().Add( editor );
2400 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2401 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2402 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2403 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2404 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2406 // Avoid a crash when core load gl resources.
2407 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2409 // Render and notify
2410 application.SendNotification();
2411 application.Render();
2413 // Tap on the text editor
2414 TestGenerateTap( application, 3.0f, 25.0f );
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2420 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2421 // Test to select some text in the left of the current cursor position
2422 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2423 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // Test to the left selection handle position and the right selection handle position
2432 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2434 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2435 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2437 // Render and notify
2438 application.SendNotification();
2439 application.Render();
2441 // Test to select full text in the left of the current cursor position
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2446 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 // Test to release the current full text selection
2454 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2455 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2457 // Render and notify
2458 application.SendNotification();
2459 application.Render();
2461 // Test to move the current cursor position correctly
2462 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2464 // Render and notify
2465 application.SendNotification();
2466 application.Render();
2469 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 // Render and notify
2472 application.SendNotification();
2473 application.Render();
2475 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2477 // Test to select some text in the right of the current cursor position
2478 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2479 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2482 // Render and notify
2483 application.SendNotification();
2484 application.Render();
2486 // Test the cursor position with right arrow key
2487 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2489 // Render and notify
2490 application.SendNotification();
2491 application.Render();
2494 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2496 // Render and notify
2497 application.SendNotification();
2498 application.Render();
2500 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2502 // Test to select some text in the left of the current cursor position
2503 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2504 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2505 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2506 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2507 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2509 // Render and notify
2510 application.SendNotification();
2511 application.Render();
2513 // Test the cursor position with left arrow key
2514 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2516 // Render and notify
2517 application.SendNotification();
2518 application.Render();
2521 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2529 // Test to select some text in the right of the current cursor position
2530 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2532 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2533 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2535 // Render and notify
2536 application.SendNotification();
2537 application.Render();
2539 // Test the cursor position with left arrow key
2540 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2542 // Render and notify
2543 application.SendNotification();
2544 application.Render();
2547 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2555 // Test to select some text in the left of the current cursor position
2556 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2557 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2558 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2559 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2561 // Render and notify
2562 application.SendNotification();
2563 application.Render();
2565 // Test the cursor position with right arrow key
2566 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2568 // Render and notify
2569 application.SendNotification();
2570 application.Render();
2573 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2575 // Render and notify
2576 application.SendNotification();
2577 application.Render();
2579 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2584 int utcDaliTextEditorHandles(void)
2586 ToolkitTestApplication application;
2587 tet_infoline(" utcDaliTextEditorHandles");
2589 TextEditor editor = TextEditor::New();
2590 DALI_TEST_CHECK( editor );
2592 application.GetScene().Add( editor );
2594 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2595 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2596 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2597 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2599 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2600 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2601 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2602 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2604 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2605 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2606 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2608 // Avoid a crash when core load gl resources.
2609 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2615 // Tap first to get the focus.
2616 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2618 // Render and notify
2619 application.SendNotification();
2620 application.Render();
2622 // Tap to create the grab handle.
2623 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2625 // Render and notify
2626 application.SendNotification();
2627 application.Render();
2629 // Get the active layer where the text's decoration is added.
2630 Actor activeLayer = editor.GetChildAt( 1u );
2632 // Get the handle's actor.
2633 Actor handle = activeLayer.GetChildAt( 1u );
2634 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2636 // Render and notify
2637 application.SendNotification();
2638 application.Render();
2640 // Touch the grab handle to set it as pressed.
2641 Vector2 touchPos( 10.0f, 50.0f );
2642 Dali::Integration::TouchEvent event;
2643 event = Dali::Integration::TouchEvent();
2644 event.AddPoint( GetPointDownInside( touchPos ) );
2645 application.ProcessEvent( event );
2647 // Render and notify
2648 application.SendNotification();
2649 application.Render();
2651 // Pan the grab handle
2652 uint32_t time = 100;
2653 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2654 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2655 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2656 application.SendNotification();
2657 application.Render();
2660 // Release the grab handle.
2661 event = Dali::Integration::TouchEvent();
2662 event.AddPoint( GetPointUpInside( touchPos ) );
2663 application.ProcessEvent( event );
2665 // Render and notify
2666 application.SendNotification();
2667 application.Render();
2669 // Tap first to get the focus.
2670 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2672 // Render and notify
2673 application.SendNotification();
2674 application.Render();
2676 // Double tap to select a word and create the selection handles.
2677 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2679 // Render and notify
2680 application.SendNotification();
2681 application.Render();
2683 touchPos = Vector2( 10.0f, 50.0f );
2685 // Touch the left selection handle to set it as pressed.
2686 event = Dali::Integration::TouchEvent();
2687 event.AddPoint( GetPointDownInside( touchPos ) );
2688 application.ProcessEvent( event );
2690 // Render and notify
2691 application.SendNotification();
2692 application.Render();
2694 // Release the left selection handle.
2695 event = Dali::Integration::TouchEvent();
2696 event.AddPoint( GetPointUpInside( touchPos ) );
2697 application.ProcessEvent( event );
2699 // Render and notify
2700 application.SendNotification();
2701 application.Render();
2706 int utcDaliTextEditorUnderPropertyStringP(void)
2708 ToolkitTestApplication application;
2709 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2710 TextEditor editor = TextEditor::New();
2711 DALI_TEST_CHECK( editor );
2713 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2715 application.GetScene().Add( editor );
2717 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2718 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2720 tet_infoline("Set underline settings with a map");
2721 // Check the input underline property
2722 Property::Map underlineMapSet;
2723 Property::Map underlineMapGet;
2724 underlineMapSet.Insert( "enable", true );
2725 underlineMapSet.Insert( "color", Color::BLUE );
2726 underlineMapSet.Insert( "height", 2 );
2728 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2729 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2730 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2731 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2733 tet_infoline("Set underline settings with a string");
2734 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2735 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2738 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2740 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2741 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2742 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2743 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2745 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2750 int utcDaliTextEditorShadowPropertyStringP(void)
2752 ToolkitTestApplication application;
2753 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2755 TextEditor editor = TextEditor::New();
2757 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2759 application.GetScene().Add( editor );
2761 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2763 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2767 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2772 int utcDaliTextEditorFontStylePropertyStringP(void)
2774 ToolkitTestApplication application;
2775 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2777 TextEditor editor = TextEditor::New();
2779 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2781 application.GetScene().Add( editor );
2783 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2785 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2789 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2794 int utcDaliTextEditorGetPropertyLinecountP(void)
2796 ToolkitTestApplication application;
2798 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2802 TextEditor editor = TextEditor::New();
2803 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2804 editor.SetProperty( TextEditor::Property::TEXT,
2805 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2807 application.GetScene().Add( editor );
2809 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2810 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2811 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2813 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2814 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2815 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2820 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2823 ToolkitTestApplication application;
2824 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2826 TextEditor editor = TextEditor::New();
2827 DALI_TEST_CHECK( editor );
2829 application.GetScene().Add( editor );
2831 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2832 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2833 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2834 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2835 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2836 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2838 bool startedCalled = false;
2839 bool finishedCalled = false;
2841 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2842 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2844 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2846 // Render and notify
2847 application.SendNotification();
2848 application.Render();
2850 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2851 application.SendNotification();
2852 application.Render(6000);
2854 application.SendNotification();
2855 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2856 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2861 int UtcDaliToolkitTextEditorTextWrapMode(void)
2863 ToolkitTestApplication application;
2864 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2868 TextEditor editor = TextEditor::New();
2869 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2870 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2872 application.GetScene().Add( editor );
2874 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2875 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2877 application.SendNotification();
2878 application.Render();
2880 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2881 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2883 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2884 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2886 application.SendNotification();
2887 application.Render();
2889 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2890 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2892 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2893 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2895 application.SendNotification();
2896 application.Render();
2898 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2899 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2901 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2902 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2904 application.SendNotification();
2905 application.Render();
2907 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2908 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2913 int UtcDaliTextEditorSetPaddingProperty(void)
2915 ToolkitTestApplication application;
2916 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2918 TextEditor editor = TextEditor::New();
2919 DALI_TEST_CHECK( editor );
2920 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2921 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2922 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2923 application.GetScene().Add( editor );
2925 application.SendNotification();
2926 application.Render();
2928 Vector3 originalSize = editor.GetNaturalSize();
2930 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2932 application.SendNotification();
2933 application.Render();
2935 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2937 Vector3 paddingAddedSize = editor.GetNaturalSize();
2939 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2941 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2946 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2948 ToolkitTestApplication application;
2949 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2951 TextEditor editor = TextEditor::New();
2952 DALI_TEST_CHECK( editor );
2953 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2954 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2955 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2956 application.GetScene().Add( editor );
2958 application.SendNotification();
2959 application.Render();
2961 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2962 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2964 // Check the enable shift selection property
2965 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2966 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2968 application.SendNotification();
2969 application.Render();
2974 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2976 ToolkitTestApplication application;
2977 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2979 TextEditor editor = TextEditor::New();
2980 DALI_TEST_CHECK( editor );
2981 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2982 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2983 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2984 application.GetScene().Add( editor );
2986 application.SendNotification();
2987 application.Render();
2989 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2990 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2992 // Check the enable grab handle property
2993 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2994 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2996 application.SendNotification();
2997 application.Render();
3002 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3004 ToolkitTestApplication application;
3005 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3007 TextEditor editor = TextEditor::New();
3008 DALI_TEST_CHECK( editor );
3009 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3010 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3011 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3012 application.GetScene().Add( editor );
3014 application.SendNotification();
3015 application.Render();
3017 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
3018 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3020 // Check the enable match system language direction property
3021 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3022 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3024 application.SendNotification();
3025 application.Render();
3030 int UtcDaliTextEditorGetInputMethodContext(void)
3032 ToolkitTestApplication application;
3033 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3035 TextEditor editor = TextEditor::New();
3036 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3041 int utcDaliTextEditorMaxCharactersReached(void)
3043 ToolkitTestApplication application;
3044 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3046 TextEditor editor = TextEditor::New();
3047 DALI_TEST_CHECK( editor );
3049 application.GetScene().Add( editor );
3051 const int maxNumberOfCharacters = 1;
3052 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3053 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3055 editor.SetKeyInputFocus();
3057 // connect to the text changed signal.
3058 ConnectionTracker* testTracker = new ConnectionTracker();
3059 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3060 bool maxLengthReachedSignal = false;
3061 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3063 gMaxCharactersCallBackCalled = false;
3065 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3066 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3068 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3069 DALI_TEST_CHECK( maxLengthReachedSignal );
3074 int UtcDaliTextEditorSelectWholeText(void)
3076 ToolkitTestApplication application;
3077 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3079 TextEditor textEditor = TextEditor::New();
3081 application.GetScene().Add( textEditor );
3083 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3084 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3085 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3087 // Avoid a crash when core load gl resources.
3088 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3090 application.SendNotification();
3091 application.Render();
3093 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3095 DevelTextEditor::SelectWholeText( textEditor );
3097 application.SendNotification();
3098 application.Render();
3100 // Nothing should have been selected. The number of children is still 1
3101 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3103 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3105 application.SendNotification();
3106 application.Render();
3108 DevelTextEditor::SelectWholeText( textEditor );
3110 application.SendNotification();
3111 application.Render();
3113 // Should be 2 children, the stencil and the layer
3114 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3116 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3117 Actor stencil = textEditor.GetChildAt( 0u );
3119 // The highlight actor is drawn first, so is the first actor in the list
3120 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3121 DALI_TEST_CHECK( highlight );
3126 int UtcDaliTextEditorSelectNone(void)
3128 ToolkitTestApplication application;
3129 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3131 TextEditor textEditor = TextEditor::New();
3133 application.GetScene().Add( textEditor );
3135 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3136 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3137 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3139 // Avoid a crash when core load gl resources.
3140 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3142 application.SendNotification();
3143 application.Render();
3145 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3147 application.SendNotification();
3148 application.Render();
3150 // Nothing is selected
3151 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3152 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3154 DevelTextEditor::SelectWholeText( textEditor );
3156 application.SendNotification();
3157 application.Render();
3159 // whole text is selected
3160 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3161 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3163 DevelTextEditor::SelectNone( textEditor );
3165 application.SendNotification();
3166 application.Render();
3168 // Nothing is selected
3169 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3170 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3175 int UtcDaliTextEditorSelectRange(void)
3177 ToolkitTestApplication application;
3178 tet_infoline("utcDaliTextEditorSelectRange");
3180 TextEditor textEditor = TextEditor::New();
3181 DALI_TEST_CHECK( textEditor );
3183 application.GetScene().Add( textEditor );
3185 // Avoid a crash when core load gl resources.
3186 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3188 application.SendNotification();
3189 application.Render();
3191 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3193 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3194 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3196 // Hello is selected
3197 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3198 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3200 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3201 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3206 int UtcDaliTextEditorEnableEditing(void)
3208 ToolkitTestApplication application;
3209 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3211 TextEditor textEditor = TextEditor::New();
3213 application.GetScene().Add( textEditor );
3215 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3216 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3217 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3219 // Avoid a crash when core load gl resources.
3220 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3222 application.SendNotification();
3223 application.Render();
3225 textEditor.SetKeyInputFocus();
3226 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3227 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3229 // Render and notify
3230 application.SendNotification();
3231 application.Render();
3233 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3234 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3236 textEditor.SetKeyInputFocus();
3237 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3238 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3240 // Render and notify
3241 application.SendNotification();
3242 application.Render();
3244 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3245 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3250 int UtcDaliTextEditorScrolling(void)
3252 ToolkitTestApplication application;
3253 tet_infoline(" UtcDaliTextEditorScrolling ");
3255 TextEditor textEditor = TextEditor::New();
3256 DALI_TEST_CHECK( textEditor );
3258 application.GetScene().Add( textEditor );
3260 // Avoid a crash when core load gl resources.
3261 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3263 application.SendNotification();
3264 application.Render();
3266 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3267 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3268 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3269 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3271 application.SendNotification();
3272 application.Render();
3274 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3275 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3278 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3280 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3281 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3283 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3285 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3286 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3288 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3289 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3291 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3292 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3297 int UtcDaliToolkitTextEditorFontSizeScale(void)
3299 ToolkitTestApplication application;
3300 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3302 TextEditor textEditor = TextEditor::New();
3303 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3304 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3305 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3307 TextEditor textEditorScaled = TextEditor::New();
3308 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3309 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3310 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3311 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3313 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3315 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3316 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3317 nonScaledSize = textEditor.GetNaturalSize();
3319 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3320 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3321 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3322 scaledSize = textEditorScaled.GetNaturalSize();
3324 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3329 int UtcDaliTextEditorPrimaryCursorPosition(void)
3331 ToolkitTestApplication application;
3332 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3334 TextEditor textEditor = TextEditor::New();
3336 application.GetScene().Add( textEditor );
3338 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3339 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3340 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3341 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3343 // Avoid a crash when core load gl resources.
3344 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3346 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3347 application.SendNotification();
3348 application.Render();
3350 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3352 // Render and notify
3353 application.SendNotification();
3354 application.Render();
3356 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3357 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3362 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3364 ToolkitTestApplication application;
3365 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3367 TextEditor textEditor = TextEditor::New();
3368 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3369 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3370 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3371 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3372 application.GetScene().Add( textEditor );
3374 application.SendNotification();
3375 application.Render();
3378 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3379 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3381 textEditor.GetNaturalSize();
3383 // Create a tap event to touch the text editor.
3384 TestGenerateTap( application, 18.0f, 25.0f );
3386 application.SendNotification();
3387 application.Render();
3389 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3390 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3396 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3398 ToolkitTestApplication application;
3400 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3402 int lineCountBefore =0 ;
3403 int lineCountAfter =0 ;
3405 // Create a text editor
3406 TextEditor textEditor = TextEditor::New();
3407 //Set very large font-size using point-size
3408 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3409 //Specify font-family
3410 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3412 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3413 //Set text longer than width of textEditor
3414 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3416 application.GetScene().Add( textEditor );
3418 application.SendNotification();
3419 application.Render();
3421 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3422 //GetHeightForWidth is a retrieval method which should not modify object
3423 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3424 textEditor.GetHeightForWidth(200.f);
3426 //This is to simulate focus into text editor after calling GetHeightForWidth
3427 //Create a tap event to touch the text editor.
3428 TestGenerateTap( application, 18.0f, 25.0f );
3430 application.SendNotification();
3431 application.Render();
3433 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3435 //The LineCount must not be changed when calling GetHeightForWidth.
3436 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3441 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3443 ToolkitTestApplication application;
3445 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3447 int lineCountBefore =0 ;
3448 int lineCountAfter =0 ;
3450 // Create a text editor
3451 TextEditor textEditor = TextEditor::New();
3452 //Set very large font-size using point-size
3453 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3454 //Specify font-family
3455 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3457 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3458 //Set text longer than width of textEditor
3459 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3460 //Set line wrap mode Character
3461 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3463 application.GetScene().Add( textEditor );
3465 application.SendNotification();
3466 application.Render();
3468 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3469 //GetHeightForWidth is a retrieval method which should not modify object
3470 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3471 textEditor.GetHeightForWidth(200.f);
3473 //This is to simulate focus into text editor after calling GetHeightForWidth
3474 //Create a tap event to touch the text editor.
3475 TestGenerateTap( application, 18.0f, 25.0f );
3477 application.SendNotification();
3478 application.Render();
3480 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3482 //The LineCount must not be changed when calling GetHeightForWidth.
3483 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3488 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3490 ToolkitTestApplication application;
3492 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3494 int lineCountBefore =0 ;
3495 int lineCountAfter =0 ;
3497 // Create a text editor
3498 TextEditor textEditor = TextEditor::New();
3499 //Set very large font-size using point-size
3500 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3501 //Specify font-family
3502 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3504 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3505 //Set text longer than width of textEditor
3506 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3508 application.GetScene().Add( textEditor );
3510 application.SendNotification();
3511 application.Render();
3513 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3514 //GetNaturalSize is a retrieval method which should not modify object
3515 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3516 textEditor.GetNaturalSize();
3518 //This is to simulate focus into text editor after calling GetNaturalSize
3519 //Create a tap event to touch the text editor.
3520 TestGenerateTap( application, 18.0f, 25.0f );
3522 application.SendNotification();
3523 application.Render();
3525 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3527 //The LineCount must not be changed when calling GetNaturalSize.
3528 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3533 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3535 ToolkitTestApplication application;
3537 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3539 int lineCountBefore =0 ;
3540 int lineCountAfter =0 ;
3542 // Create a text editor
3543 TextEditor textEditor = TextEditor::New();
3544 //Set very large font-size using point-size
3545 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3546 //Specify font-family
3547 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3549 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3550 //Set text longer than width of textEditor
3551 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3552 //Set line wrap mode Character
3553 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3555 application.GetScene().Add( textEditor );
3557 application.SendNotification();
3558 application.Render();
3560 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3561 //GetNaturalSize is a retrieval method which should not modify object
3562 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3563 textEditor.GetNaturalSize( );
3565 //This is to simulate focus into text editor after calling GetNaturalSize
3566 //Create a tap event to touch the text editor.
3567 TestGenerateTap( application, 18.0f, 25.0f );
3569 application.SendNotification();
3570 application.Render();
3572 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3574 //The LineCount must not be changed when calling GetNaturalSize.
3575 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3580 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3582 ToolkitTestApplication application;
3583 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3585 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3586 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3587 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3589 // Create a text editor
3590 TextEditor textEditor = TextEditor::New();
3592 //Set size to avoid automatic eliding
3593 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3594 //Set very large font-size using point-size
3595 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3596 //Specify font-family
3597 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3598 //Set text to check if appear or not
3599 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3601 application.GetScene().Add( textEditor );
3603 application.SendNotification();
3604 application.Render();
3605 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3606 Vector3 naturalSize = textEditor.GetNaturalSize();
3608 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3609 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3614 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3616 ToolkitTestApplication application;
3617 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3619 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3620 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3621 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3623 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3624 // Create a text editor
3625 TextEditor textEditor = TextEditor::New();
3626 //Set size to avoid automatic eliding
3627 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3628 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3629 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3631 const int numberOfCases = 6;
3632 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3634 for (int index=0; index < numberOfCases; index++)
3636 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3637 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3638 application.GetScene().Add( textEditor );
3639 application.SendNotification();
3640 application.Render();
3641 naturalSize = textEditor.GetNaturalSize();
3642 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3643 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3650 int UtcDaliTextEditorHyphenWrapMode(void)
3652 ToolkitTestApplication application;
3653 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3656 TextEditor textEditor = TextEditor::New();
3658 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3660 application.GetScene().Add( textEditor );
3661 application.SendNotification();
3662 application.Render();
3664 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3665 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3666 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3668 application.SendNotification();
3669 application.Render();
3671 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3677 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3679 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3680 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3681 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3683 application.SendNotification();
3684 application.Render();
3686 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3693 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );