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";
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 );
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 application.SendNotification();
935 application.Render();
940 // Positive Atlas Text Renderer test
941 int utcDaliTextEditorAtlasRenderP(void)
943 ToolkitTestApplication application;
944 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
945 StyleManager styleManager = StyleManager::Get();
946 styleManager.ApplyDefaultTheme();
947 TextEditor editor = TextEditor::New();
948 DALI_TEST_CHECK( editor );
950 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
952 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
954 application.GetScene().Add( editor );
958 // Render some text with the shared atlas backend
959 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
960 application.SendNotification();
961 application.Render();
965 tet_result(TET_FAIL);
970 // Positive test for the anchorClicked signal.
971 int utcDaliTextEditorAnchorClickedP(void)
973 ToolkitTestApplication application;
974 tet_infoline(" utcDaliTextEditorAnchorClickedP");
975 TextEditor editor = TextEditor::New();
976 DALI_TEST_CHECK(editor);
978 application.GetScene().Add(editor);
980 // connect to the anchor clicked signal.
981 ConnectionTracker* testTracker = new ConnectionTracker();
982 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
983 bool anchorClickedSignal = false;
984 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
986 gAnchorClickedCallBackCalled = false;
987 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
988 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
989 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
990 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
991 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
993 application.SendNotification();
994 application.Render();
995 editor.SetKeyInputFocus();
997 // Create a tap event to touch the text editor.
998 TestGenerateTap(application, 5.0f, 5.0f);
999 application.SendNotification();
1000 application.Render();
1002 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1003 DALI_TEST_CHECK(anchorClickedSignal);
1005 gAnchorClickedCallBackNotCalled = true;
1006 // Tap the outside of anchor, callback should not be called.
1007 TestGenerateTap(application, 150.f, 100.f);
1008 application.SendNotification();
1009 application.Render();
1011 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1016 // Positive test for the textChanged signal.
1017 int utcDaliTextEditorTextChangedP(void)
1019 ToolkitTestApplication application;
1020 tet_infoline(" utcDaliTextEditorTextChangedP");
1021 TextEditor editor = TextEditor::New();
1022 DALI_TEST_CHECK( editor );
1024 application.GetScene().Add( editor );
1026 // connect to the text changed signal.
1027 ConnectionTracker* testTracker = new ConnectionTracker();
1028 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1029 bool textChangedSignal = false;
1030 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1032 gTextChangedCallBackCalled = false;
1033 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1034 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1035 DALI_TEST_CHECK( textChangedSignal );
1037 application.SendNotification();
1038 editor.SetKeyInputFocus();
1040 gTextChangedCallBackCalled = false;
1041 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1042 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1045 editor.SetProperty( TextField::Property::TEXT, "" );
1047 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1048 gTextChangedCallBackCalled = false;
1049 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1050 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1052 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1053 gTextChangedCallBackCalled = false;
1054 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1055 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1060 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1062 ToolkitTestApplication application;
1063 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1064 TextEditor editor = TextEditor::New();
1065 DALI_TEST_CHECK( editor );
1068 application.GetScene().Add( editor );
1070 // connect to the text changed signal.
1071 ConnectionTracker* testTracker = new ConnectionTracker();
1072 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1073 bool textChangedSignal = false;
1074 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1077 // get InputMethodContext
1079 InputMethodContext::EventData imfEvent;
1080 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1082 editor.SetKeyInputFocus();
1083 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1086 gTextChangedCallBackCalled = false;
1087 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1088 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1089 application.SendNotification();
1090 application.Render();
1091 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1092 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1094 gTextChangedCallBackCalled = false;
1095 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1096 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1097 application.SendNotification();
1098 application.Render();
1099 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1100 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1102 gTextChangedCallBackCalled = false;
1103 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1104 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1105 application.SendNotification();
1106 application.Render();
1107 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1108 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1110 gTextChangedCallBackCalled = false;
1111 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1112 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1113 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1115 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1116 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1117 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1119 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1120 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1121 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1123 application.SendNotification();
1124 application.Render();
1125 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1126 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1132 int utcDaliTextEditorInputStyleChanged01(void)
1134 // The text-editor emits signals when the input style changes. These changes of style are
1135 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1136 // can't be emitted during the size negotiation as the callbacks may update the UI.
1137 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1138 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1139 ToolkitTestApplication application;
1140 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1144 char* pathNamePtr = get_current_dir_name();
1145 const std::string pathName( pathNamePtr );
1146 free( pathNamePtr );
1148 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1149 fontClient.SetDpi( 93u, 93u );
1151 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1152 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1154 TextEditor editor = TextEditor::New();
1155 DALI_TEST_CHECK( editor );
1158 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1159 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1160 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1162 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1163 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1165 // connect to the text changed signal.
1166 ConnectionTracker* testTracker = new ConnectionTracker();
1167 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1168 bool inputStyleChangedSignal = false;
1169 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1171 application.GetScene().Add( editor );
1173 // Render and notify
1174 application.SendNotification();
1175 application.Render();
1177 // Executes the idle callbacks added by the text control on the change of input style.
1178 application.RunIdles();
1180 gInputStyleChangedCallbackCalled = false;
1181 gInputStyleMask = TextEditor::InputStyle::NONE;
1182 inputStyleChangedSignal = false;
1184 // Create a tap event to touch the text editor.
1185 TestGenerateTap( application, 18.0f, 25.0f );
1187 // Render and notify
1188 application.SendNotification();
1189 application.Render();
1191 // Executes the idle callbacks added by the text control on the change of input style.
1192 application.RunIdles();
1194 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1195 if( gInputStyleChangedCallbackCalled )
1197 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1199 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1200 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1202 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1203 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1205 DALI_TEST_CHECK( inputStyleChangedSignal );
1207 gInputStyleChangedCallbackCalled = false;
1208 gInputStyleMask = TextEditor::InputStyle::NONE;
1209 inputStyleChangedSignal = false;
1211 // Create a tap event to touch the text editor.
1212 TestGenerateTap( application, 30.0f, 25.0f );
1214 // Render and notify
1215 application.SendNotification();
1216 application.Render();
1218 // Executes the idle callbacks added by the text control on the change of input style.
1219 application.RunIdles();
1221 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1222 DALI_TEST_CHECK( !inputStyleChangedSignal );
1224 gInputStyleChangedCallbackCalled = false;
1225 gInputStyleMask = TextEditor::InputStyle::NONE;
1226 inputStyleChangedSignal = false;
1228 // Create a tap event to touch the text editor.
1229 TestGenerateTap( application, 43.0f, 25.0f );
1231 // Render and notify
1232 application.SendNotification();
1233 application.Render();
1235 // Executes the idle callbacks added by the text control on the change of input style.
1236 application.RunIdles();
1238 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1239 if( gInputStyleChangedCallbackCalled )
1241 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1243 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1244 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1246 DALI_TEST_CHECK( inputStyleChangedSignal );
1248 gInputStyleChangedCallbackCalled = false;
1249 gInputStyleMask = TextEditor::InputStyle::NONE;
1250 inputStyleChangedSignal = false;
1252 // Create a tap event to touch the text editor.
1253 TestGenerateTap( application, 88.0f, 25.0f );
1255 // Render and notify
1256 application.SendNotification();
1257 application.Render();
1259 // Executes the idle callbacks added by the text control on the change of input style.
1260 application.RunIdles();
1262 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1263 if( gInputStyleChangedCallbackCalled )
1265 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1267 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1268 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1270 Property::Map fontStyleMapSet;
1271 Property::Map fontStyleMapGet;
1273 fontStyleMapSet.Insert( "weight", "bold" );
1275 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1276 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1277 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1279 DALI_TEST_CHECK( inputStyleChangedSignal );
1281 gInputStyleChangedCallbackCalled = false;
1282 gInputStyleMask = TextEditor::InputStyle::NONE;
1283 inputStyleChangedSignal = false;
1285 // Create a tap event to touch the text editor.
1286 TestGenerateTap( application, 115.0f, 25.0f );
1288 // Render and notify
1289 application.SendNotification();
1290 application.Render();
1292 // Executes the idle callbacks added by the text control on the change of input style.
1293 application.RunIdles();
1295 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1296 DALI_TEST_CHECK( !inputStyleChangedSignal );
1298 gInputStyleChangedCallbackCalled = false;
1299 gInputStyleMask = TextEditor::InputStyle::NONE;
1300 inputStyleChangedSignal = false;
1302 // Create a tap event to touch the text editor.
1303 TestGenerateTap( application, 164.0f, 25.0f );
1305 // Render and notify
1306 application.SendNotification();
1307 application.Render();
1309 // Executes the idle callbacks added by the text control on the change of input style.
1310 application.RunIdles();
1312 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1313 if( gInputStyleChangedCallbackCalled )
1315 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1317 Property::Map fontStyleMapSet;
1318 Property::Map fontStyleMapGet;
1320 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1321 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1322 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1324 DALI_TEST_CHECK( inputStyleChangedSignal );
1326 gInputStyleChangedCallbackCalled = false;
1327 gInputStyleMask = TextEditor::InputStyle::NONE;
1328 inputStyleChangedSignal = false;
1330 // Create a tap event to touch the text editor.
1331 TestGenerateTap( application, 191.0f, 25.0f );
1333 // Render and notify
1334 application.SendNotification();
1335 application.Render();
1337 // Executes the idle callbacks added by the text control on the change of input style.
1338 application.RunIdles();
1340 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1341 DALI_TEST_CHECK( !inputStyleChangedSignal );
1346 int utcDaliTextEditorInputStyleChanged02(void)
1348 // The text-editor emits signals when the input style changes. These changes of style are
1349 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1350 // can't be emitted during the size negotiation as the callbacks may update the UI.
1351 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1352 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1353 ToolkitTestApplication application;
1354 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1358 char* pathNamePtr = get_current_dir_name();
1359 const std::string pathName( pathNamePtr );
1360 free( pathNamePtr );
1362 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1363 fontClient.SetDpi( 93u, 93u );
1365 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1366 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1368 TextEditor editor = TextEditor::New();
1369 DALI_TEST_CHECK( editor );
1372 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1373 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1374 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1376 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1377 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>" );
1379 // connect to the text changed signal.
1380 ConnectionTracker* testTracker = new ConnectionTracker();
1381 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1382 bool inputStyleChangedSignal = false;
1383 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1385 application.GetScene().Add( editor );
1387 // Render and notify
1388 application.SendNotification();
1389 application.Render();
1391 // Executes the idle callbacks added by the text control on the change of input style.
1392 application.RunIdles();
1394 gInputStyleChangedCallbackCalled = false;
1395 gInputStyleMask = TextEditor::InputStyle::NONE;
1396 inputStyleChangedSignal = false;
1398 // Create a tap event to touch the text editor.
1399 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1400 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1402 // Render and notify
1403 application.SendNotification();
1404 application.Render();
1406 // Executes the idle callbacks added by the text control on the change of input style.
1407 application.RunIdles();
1409 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1410 if( gInputStyleChangedCallbackCalled )
1412 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1413 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1414 TextEditor::InputStyle::POINT_SIZE |
1415 TextEditor::InputStyle::COLOR ),
1418 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1419 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1421 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1422 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1424 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1425 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1427 DALI_TEST_CHECK( inputStyleChangedSignal );
1429 gInputStyleChangedCallbackCalled = false;
1430 gInputStyleMask = TextEditor::InputStyle::NONE;
1431 inputStyleChangedSignal = false;
1433 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 // Executes the idle callbacks added by the text control on the change of input style.
1440 application.RunIdles();
1442 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1443 if( gInputStyleChangedCallbackCalled )
1445 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1446 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1449 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1450 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1452 DALI_TEST_CHECK( inputStyleChangedSignal );
1454 gInputStyleChangedCallbackCalled = false;
1455 gInputStyleMask = TextEditor::InputStyle::NONE;
1456 inputStyleChangedSignal = false;
1458 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1460 // Render and notify
1461 application.SendNotification();
1462 application.Render();
1464 // Executes the idle callbacks added by the text control on the change of input style.
1465 application.RunIdles();
1467 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1468 DALI_TEST_CHECK( !inputStyleChangedSignal );
1470 gInputStyleChangedCallbackCalled = false;
1471 gInputStyleMask = TextEditor::InputStyle::NONE;
1472 inputStyleChangedSignal = false;
1474 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Executes the idle callbacks added by the text control on the change of input style.
1481 application.RunIdles();
1483 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1484 if( gInputStyleChangedCallbackCalled )
1486 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1487 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1490 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1491 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1493 DALI_TEST_CHECK( inputStyleChangedSignal );
1495 gInputStyleChangedCallbackCalled = false;
1496 gInputStyleMask = TextEditor::InputStyle::NONE;
1497 inputStyleChangedSignal = false;
1499 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1501 Property::Map fontStyleMapSet;
1502 fontStyleMapSet.Insert( "weight", "thin" );
1503 fontStyleMapSet.Insert( "width", "condensed" );
1504 fontStyleMapSet.Insert( "slant", "italic" );
1506 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1507 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1508 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1510 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1511 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1512 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1513 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1515 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1517 // Render and notify
1518 application.SendNotification();
1519 application.Render();
1521 // Executes the idle callbacks added by the text control on the change of input style.
1522 application.RunIdles();
1524 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1525 DALI_TEST_CHECK( !inputStyleChangedSignal );
1527 // Create a tap event to touch the text editor.
1528 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1530 // Render and notify
1531 application.SendNotification();
1532 application.Render();
1534 // Executes the idle callbacks added by the text control on the change of input style.
1535 application.RunIdles();
1537 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1538 if( gInputStyleChangedCallbackCalled )
1540 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1541 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1542 TextEditor::InputStyle::POINT_SIZE |
1543 TextEditor::InputStyle::FONT_STYLE |
1544 TextEditor::InputStyle::LINE_SPACING |
1545 TextEditor::InputStyle::UNDERLINE |
1546 TextEditor::InputStyle::SHADOW |
1547 TextEditor::InputStyle::EMBOSS |
1548 TextEditor::InputStyle::OUTLINE ),
1551 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1552 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1554 DALI_TEST_CHECK( inputStyleChangedSignal );
1556 gInputStyleChangedCallbackCalled = false;
1557 gInputStyleMask = TextEditor::InputStyle::NONE;
1558 inputStyleChangedSignal = false;
1560 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1562 fontStyleMapSet.Clear();
1563 fontStyleMapSet.Insert( "weight", "black" );
1564 fontStyleMapSet.Insert( "width", "expanded" );
1565 fontStyleMapSet.Insert( "slant", "oblique" );
1567 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1569 // Create a tap event to touch the text editor.
1570 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1572 // Render and notify
1573 application.SendNotification();
1574 application.Render();
1576 // Executes the idle callbacks added by the text control on the change of input style.
1577 application.RunIdles();
1579 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1580 if( gInputStyleChangedCallbackCalled )
1582 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1583 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1584 TextEditor::InputStyle::POINT_SIZE |
1585 TextEditor::InputStyle::FONT_STYLE ),
1588 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1589 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1591 DALI_TEST_CHECK( inputStyleChangedSignal );
1596 int utcDaliTextEditorEvent01(void)
1598 ToolkitTestApplication application;
1599 tet_infoline(" utcDaliTextEditorEvent01");
1601 // Creates a tap event. After creating a tap event the text editor should
1602 // have the focus and add text with key events should be possible.
1604 TextEditor editor = TextEditor::New();
1605 DALI_TEST_CHECK( editor );
1607 application.GetScene().Add( editor );
1609 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1610 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1611 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1613 // Avoid a crash when core load gl resources.
1614 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 // Add a key event but as the text editor has not the focus it should do nothing.
1621 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1629 // Create a tap event to touch the text editor.
1630 TestGenerateTap( application, 150.0f, 25.0f );
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 // Now the text editor has the focus, so it can handle the key events.
1637 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1638 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1646 // Create a second text editor and send key events to it.
1647 TextEditor editor2 = TextEditor::New();
1649 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1650 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1651 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1652 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1654 application.GetScene().Add( editor2 );
1656 // Render and notify
1657 application.SendNotification();
1658 application.Render();
1660 // Create a tap event on the second text editor.
1661 TestGenerateTap( application, 150.0f, 125.0f );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // The second text editor has the focus. It should handle the key events.
1668 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1669 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 // Check the text has been added to the second text editor.
1676 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1681 int utcDaliTextEditorEvent02(void)
1683 ToolkitTestApplication application;
1684 tet_infoline(" utcDaliTextEditorEvent02");
1686 // Checks if the right number of actors are created.
1688 TextEditor editor = TextEditor::New();
1689 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1690 DALI_TEST_CHECK( editor );
1692 application.GetScene().Add( editor );
1694 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1695 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1696 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1698 // Avoid a crash when core load gl resources.
1699 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 // Check there are the expected number of children (the stencil).
1706 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1708 Actor stencil = editor.GetChildAt( 0u );
1710 // Create a tap event to touch the text editor.
1711 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1713 // Render and notify
1714 application.SendNotification();
1715 application.Render();
1717 Actor layer = editor.GetChildAt( 1u );
1718 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1719 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1721 // Now the text editor has the focus, so it can handle the key events.
1722 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1723 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1725 // Render and notify
1726 application.SendNotification();
1727 application.Render();
1729 // Checks the cursor and the renderer have been created.
1730 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1731 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1733 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1734 DALI_TEST_CHECK( cursor );
1736 // The stencil actor has a container with all the actors which contain the text renderers.
1737 Actor container = stencil.GetChildAt( 0u );
1738 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1740 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1741 DALI_TEST_CHECK( renderer );
1744 // Move the cursor and check the position changes.
1745 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1747 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1748 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1754 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1756 DALI_TEST_CHECK( position2.x < position1.x );
1758 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1759 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1767 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1769 // Send some taps and check the cursor positions.
1771 // Try to tap at the beginning.
1772 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1774 // Render and notify
1775 application.SendNotification();
1776 application.Render();
1778 // Cursor position should be the same than position1.
1779 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1781 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1783 // Tap away from the start position.
1784 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1790 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1792 DALI_TEST_CHECK( position5.x > position4.x );
1794 // Remove all the text.
1795 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1796 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1797 editor.SetProperty( TextEditor::Property::TEXT, "" );
1799 // Render and notify
1800 application.SendNotification();
1801 application.Render();
1803 // Cursor position should be the same than position2.
1804 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1806 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1808 // Should not be a renderer.
1809 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1814 int utcDaliTextEditorEvent03(void)
1816 ToolkitTestApplication application;
1817 tet_infoline(" utcDaliTextEditorEvent03");
1819 // Checks if the highlight actor is created.
1821 TextEditor editor = TextEditor::New();
1822 DALI_TEST_CHECK( editor );
1824 application.GetScene().Add( editor );
1826 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1827 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1828 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1829 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1830 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1832 // Avoid a crash when core load gl resources.
1833 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1835 // Render and notify
1836 application.SendNotification();
1837 application.Render();
1839 // Send some taps and check text controller with clipboard window
1840 Dali::Clipboard clipboard = Clipboard::Get();
1841 clipboard.ShowClipboard();
1842 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1843 clipboard.HideClipboard();
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Tap first to get the focus.
1850 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1852 // Render and notify
1853 application.SendNotification();
1854 application.Render();
1856 // Double tap to select a word.
1857 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1859 // Render and notify
1860 application.SendNotification();
1861 application.Render();
1863 // The stencil actor should have two actors: the renderer and the highlight actor.
1864 Actor stencil = editor.GetChildAt( 0u );
1866 // Highlight needs to be drawn before text, so should come first in child order
1867 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1868 DALI_TEST_CHECK( highlight );
1870 // The stencil actor has a container with all the actors which contain the text renderers.
1871 Actor container = stencil.GetChildAt( 1u );
1872 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1874 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1875 DALI_TEST_CHECK( renderer );
1878 // Double tap out of bounds
1879 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1880 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1882 // Render and notify
1883 application.SendNotification();
1884 application.Render();
1886 // The stencil actor should have one actors: the renderer actor.
1887 stencil = editor.GetChildAt( 0u );
1889 // The stencil actor has a container with all the actors which contain the text renderers.
1890 container = stencil.GetChildAt( 0u );
1891 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1893 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1894 DALI_TEST_CHECK( renderer );
1898 TestGenerateLongPress(application, 1.0f, 25.0f);
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1905 TestGenerateMiniPan(application);
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1914 int utcDaliTextEditorEvent04(void)
1916 ToolkitTestApplication application;
1917 tet_infoline(" utcDaliTextEditorEvent04");
1919 // Checks if the highlight actor is created.
1921 TextEditor editor = TextEditor::New();
1922 DALI_TEST_CHECK( editor );
1924 application.GetScene().Add( editor );
1926 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1927 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1928 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1929 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1930 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1932 // Avoid a crash when core load gl resources.
1933 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1935 // Render and notify
1936 application.SendNotification();
1937 application.Render();
1939 // Tap on the text editor
1940 TestGenerateTap( application, 3.0f, 25.0f );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 // Move at the end of the text.
1947 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1948 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1950 // Render and notify
1951 application.SendNotification();
1952 application.Render();
1954 for( unsigned int index = 0u; index < 10u; ++index )
1956 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1957 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1965 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1967 // Render and notify
1968 application.SendNotification();
1969 application.Render();
1971 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1973 // Add some key events
1974 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1975 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 for( unsigned int index = 0u; index < 10u; ++index )
1983 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1984 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1992 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1994 // Render and notify
1995 application.SendNotification();
1996 application.Render();
1998 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2003 int utcDaliTextEditorEvent05(void)
2005 ToolkitTestApplication application;
2006 tet_infoline(" utcDaliTextEditorEvent05");
2008 // Checks if the highlight actor is created.
2010 TextEditor editor = TextEditor::New();
2011 DALI_TEST_CHECK( editor );
2013 application.GetScene().Add( editor );
2015 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2016 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2017 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2018 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2019 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2020 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2021 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2022 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2023 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2024 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2026 // Avoid a crash when core load gl resources.
2027 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2029 // Render and notify
2030 application.SendNotification();
2031 application.Render();
2033 // Tap on the text editor
2034 TestGenerateTap( application, 3.0f, 25.0f );
2036 // Render and notify
2037 application.SendNotification();
2038 application.Render();
2040 // Move at the end of the text.
2041 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 for( unsigned int index = 0u; index < 10u; ++index )
2051 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 // Modify duration after scroll is enabled
2058 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2060 // Continuous scroll left to increase coverage
2061 for( unsigned int index = 0u; index < 10u; ++index )
2063 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2069 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2070 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2071 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2072 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2073 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2075 // Press Escape to increase coverage
2076 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2077 application.SendNotification();
2078 application.Render();
2080 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2085 int utcDaliTextEditorEvent06(void)
2087 ToolkitTestApplication application;
2088 tet_infoline(" utcDaliTextEditorEvent06");
2090 // Checks if the highlight actor is created.
2092 TextEditor editor = TextEditor::New();
2093 DALI_TEST_CHECK( editor );
2095 application.GetScene().Add( editor );
2097 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2098 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2099 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2100 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2101 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2103 // Avoid a crash when core load gl resources.
2104 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2106 // Render and notify
2107 application.SendNotification();
2108 application.Render();
2110 // Tap on the text editor
2111 TestGenerateTap( application, 3.0f, 25.0f );
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2117 // Move to seconds line of the text.
2118 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2120 // Render and notify
2121 application.SendNotification();
2122 application.Render();
2124 float layoutHeight = editor.GetHeightForWidth( 100.f );
2127 // Add another script characters ( glyph height is defferent )
2128 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2131 // Delete characters
2132 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2133 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2135 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2144 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2145 application.SendNotification();
2146 application.Render();
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 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_VOLUME_UP, 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_DOWN, 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::DevelKey::DALI_KEY_DELETE, 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_CONTROL_LEFT, 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_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169 application.SendNotification();
2170 application.Render();
2175 int utcDaliTextEditorEvent07(void)
2177 ToolkitTestApplication application;
2178 tet_infoline(" utcDaliTextEditorEvent07");
2180 // Checks if the highlight actor is created.
2182 TextEditor editor = TextEditor::New();
2183 DALI_TEST_CHECK( editor );
2185 application.GetScene().Add( editor );
2187 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2188 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2189 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2190 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2191 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2193 // Avoid a crash when core load gl resources.
2194 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2200 // Tap on the text editor
2201 TestGenerateTap( application, 3.0f, 25.0f );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // Move to second line of the text.
2208 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2214 // Select some text in the right of the current cursor position
2215 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2216 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // Cut the selected text
2225 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226 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 ) );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2234 // Select some text in the left of the current cursor position
2235 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2238 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 // Render and notify
2241 application.SendNotification();
2242 application.Render();
2244 // Copy the selected text
2245 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 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 ) );
2248 // Render and notify
2249 application.SendNotification();
2250 application.Render();
2252 // Move the cursor to the third line
2253 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 // Render and notify
2257 application.SendNotification();
2258 application.Render();
2260 // Paste the selected text at the current cursor position
2261 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 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 ) );
2264 // Render and notify
2265 application.SendNotification();
2266 application.Render();
2268 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2271 // Disable Shift Selection
2272 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2274 // Test to select some text in the right of the current cursor position
2275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 // Render and notify
2281 application.SendNotification();
2282 application.Render();
2284 // Cut the selected text
2285 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2286 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 ) );
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2292 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2293 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2295 // Test to select some text in the left of the current cursor position
2296 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 // Copy the selected text
2306 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2307 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 ) );
2309 // Render and notify
2310 application.SendNotification();
2311 application.Render();
2313 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2314 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2317 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 ) );
2319 // Render and notify
2320 application.SendNotification();
2321 application.Render();
2323 // replace text with "c"
2324 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2331 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2334 DevelTextEditor::SelectWholeText(editor);
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 // Copy the selected text using logical keys
2341 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2349 DevelTextEditor::SelectNone(editor);
2351 // Render and notify
2352 application.SendNotification();
2353 application.Render();
2355 // Paste the selected using logical keys
2356 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2357 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2362 // select all using logical keys
2363 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2366 // Render and notify
2367 application.SendNotification();
2368 application.Render();
2370 // cut text using logical keys
2371 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2379 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2384 int utcDaliTextEditorEvent08(void)
2386 ToolkitTestApplication application;
2387 tet_infoline(" utcDaliTextEditorEvent08");
2389 // Checks if the highlight actor is released correctly.
2391 TextEditor editor = TextEditor::New();
2392 DALI_TEST_CHECK( editor );
2394 application.GetScene().Add( editor );
2396 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2397 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2398 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2399 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2400 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2402 // Avoid a crash when core load gl resources.
2403 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // Tap on the text editor
2410 TestGenerateTap( application, 3.0f, 25.0f );
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2416 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2417 // Test to select some text in the left of the current cursor position
2418 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2420 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2421 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2423 // Render and notify
2424 application.SendNotification();
2425 application.Render();
2427 // Test to the left selection handle position and the right selection handle position
2428 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2429 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2430 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2431 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2437 // Test to select full text in the left of the current cursor position
2438 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2439 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2445 // Render and notify
2446 application.SendNotification();
2447 application.Render();
2449 // Test to release the current full text selection
2450 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // Test to move the current cursor position correctly
2458 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2460 // Render and notify
2461 application.SendNotification();
2462 application.Render();
2465 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 // Render and notify
2468 application.SendNotification();
2469 application.Render();
2471 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2473 // Test to select some text in the right of the current cursor position
2474 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2475 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2476 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2478 // Render and notify
2479 application.SendNotification();
2480 application.Render();
2482 // Test the cursor position with right arrow key
2483 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2485 // Render and notify
2486 application.SendNotification();
2487 application.Render();
2490 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2492 // Render and notify
2493 application.SendNotification();
2494 application.Render();
2496 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2498 // Test to select some text in the left of the current cursor position
2499 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2500 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2501 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2502 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2503 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 // Test the cursor position with left arrow key
2510 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2512 // Render and notify
2513 application.SendNotification();
2514 application.Render();
2517 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2525 // Test to select some text in the right of the current cursor position
2526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2529 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Test the cursor position with left arrow key
2536 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2543 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2551 // Test to select some text in the left of the current cursor position
2552 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2554 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2555 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2561 // Test the cursor position with right arrow key
2562 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2564 // Render and notify
2565 application.SendNotification();
2566 application.Render();
2569 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2571 // Render and notify
2572 application.SendNotification();
2573 application.Render();
2575 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2580 int utcDaliTextEditorHandles(void)
2582 ToolkitTestApplication application;
2583 tet_infoline(" utcDaliTextEditorHandles");
2585 TextEditor editor = TextEditor::New();
2586 DALI_TEST_CHECK( editor );
2588 application.GetScene().Add( editor );
2590 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2591 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2592 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2593 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2595 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2596 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2597 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2598 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2600 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2601 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2602 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2604 // Avoid a crash when core load gl resources.
2605 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2607 // Render and notify
2608 application.SendNotification();
2609 application.Render();
2611 // Tap first to get the focus.
2612 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2614 // Render and notify
2615 application.SendNotification();
2616 application.Render();
2618 // Tap to create the grab handle.
2619 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2621 // Render and notify
2622 application.SendNotification();
2623 application.Render();
2625 // Get the active layer where the text's decoration is added.
2626 Actor activeLayer = editor.GetChildAt( 1u );
2628 // Get the handle's actor.
2629 Actor handle = activeLayer.GetChildAt( 1u );
2630 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2632 // Render and notify
2633 application.SendNotification();
2634 application.Render();
2636 // Touch the grab handle to set it as pressed.
2637 Vector2 touchPos( 10.0f, 50.0f );
2638 Dali::Integration::TouchEvent event;
2639 event = Dali::Integration::TouchEvent();
2640 event.AddPoint( GetPointDownInside( touchPos ) );
2641 application.ProcessEvent( event );
2643 // Render and notify
2644 application.SendNotification();
2645 application.Render();
2647 // Pan the grab handle
2648 uint32_t time = 100;
2649 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2650 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2651 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2652 application.SendNotification();
2653 application.Render();
2656 // Release the grab handle.
2657 event = Dali::Integration::TouchEvent();
2658 event.AddPoint( GetPointUpInside( touchPos ) );
2659 application.ProcessEvent( event );
2661 // Render and notify
2662 application.SendNotification();
2663 application.Render();
2665 // Tap first to get the focus.
2666 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2668 // Render and notify
2669 application.SendNotification();
2670 application.Render();
2672 // Double tap to select a word and create the selection handles.
2673 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2675 // Render and notify
2676 application.SendNotification();
2677 application.Render();
2679 touchPos = Vector2( 10.0f, 50.0f );
2681 // Touch the left selection handle to set it as pressed.
2682 event = Dali::Integration::TouchEvent();
2683 event.AddPoint( GetPointDownInside( touchPos ) );
2684 application.ProcessEvent( event );
2686 // Render and notify
2687 application.SendNotification();
2688 application.Render();
2690 // Release the left selection handle.
2691 event = Dali::Integration::TouchEvent();
2692 event.AddPoint( GetPointUpInside( touchPos ) );
2693 application.ProcessEvent( event );
2695 // Render and notify
2696 application.SendNotification();
2697 application.Render();
2702 int utcDaliTextEditorUnderPropertyStringP(void)
2704 ToolkitTestApplication application;
2705 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2706 TextEditor editor = TextEditor::New();
2707 DALI_TEST_CHECK( editor );
2709 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2711 application.GetScene().Add( editor );
2713 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2714 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2716 tet_infoline("Set underline settings with a map");
2717 // Check the input underline property
2718 Property::Map underlineMapSet;
2719 Property::Map underlineMapGet;
2720 underlineMapSet.Insert( "enable", true );
2721 underlineMapSet.Insert( "color", Color::BLUE );
2722 underlineMapSet.Insert( "height", 2 );
2724 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2725 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2726 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2727 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2729 tet_infoline("Set underline settings with a string");
2730 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2731 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2734 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2736 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2737 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2738 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2739 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2741 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2746 int utcDaliTextEditorShadowPropertyStringP(void)
2748 ToolkitTestApplication application;
2749 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2751 TextEditor editor = TextEditor::New();
2753 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2755 application.GetScene().Add( editor );
2757 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2759 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2763 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2768 int utcDaliTextEditorFontStylePropertyStringP(void)
2770 ToolkitTestApplication application;
2771 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2773 TextEditor editor = TextEditor::New();
2775 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2777 application.GetScene().Add( editor );
2779 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2781 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2785 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2790 int utcDaliTextEditorGetPropertyLinecountP(void)
2792 ToolkitTestApplication application;
2794 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2798 TextEditor editor = TextEditor::New();
2799 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2800 editor.SetProperty( TextEditor::Property::TEXT,
2801 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2803 application.GetScene().Add( editor );
2805 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2806 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2807 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2809 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2810 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2811 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2816 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2819 ToolkitTestApplication application;
2820 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2822 TextEditor editor = TextEditor::New();
2823 DALI_TEST_CHECK( editor );
2825 application.GetScene().Add( editor );
2827 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2828 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2829 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2830 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2831 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2832 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2834 bool startedCalled = false;
2835 bool finishedCalled = false;
2837 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2838 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2840 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2842 // Render and notify
2843 application.SendNotification();
2844 application.Render();
2846 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2847 application.SendNotification();
2848 application.Render(6000);
2850 application.SendNotification();
2851 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2852 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2857 int UtcDaliToolkitTextEditorTextWrapMode(void)
2859 ToolkitTestApplication application;
2860 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2864 TextEditor editor = TextEditor::New();
2865 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2866 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2868 application.GetScene().Add( editor );
2870 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2871 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2873 application.SendNotification();
2874 application.Render();
2876 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2877 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2879 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2880 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2882 application.SendNotification();
2883 application.Render();
2885 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2886 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2888 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2889 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2891 application.SendNotification();
2892 application.Render();
2894 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2895 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2897 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2898 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2900 application.SendNotification();
2901 application.Render();
2903 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2904 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2909 int UtcDaliTextEditorSetPaddingProperty(void)
2911 ToolkitTestApplication application;
2912 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2914 TextEditor editor = TextEditor::New();
2915 DALI_TEST_CHECK( editor );
2916 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2917 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2918 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2919 application.GetScene().Add( editor );
2921 application.SendNotification();
2922 application.Render();
2924 Vector3 originalSize = editor.GetNaturalSize();
2926 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2928 application.SendNotification();
2929 application.Render();
2931 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2933 Vector3 paddingAddedSize = editor.GetNaturalSize();
2935 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2937 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2942 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2944 ToolkitTestApplication application;
2945 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2947 TextEditor editor = TextEditor::New();
2948 DALI_TEST_CHECK( editor );
2949 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2950 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2951 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2952 application.GetScene().Add( editor );
2954 application.SendNotification();
2955 application.Render();
2957 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2958 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2960 // Check the enable shift selection property
2961 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2962 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2964 application.SendNotification();
2965 application.Render();
2970 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2972 ToolkitTestApplication application;
2973 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2975 TextEditor editor = TextEditor::New();
2976 DALI_TEST_CHECK( editor );
2977 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2978 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2979 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2980 application.GetScene().Add( editor );
2982 application.SendNotification();
2983 application.Render();
2985 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2986 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2988 // Check the enable grab handle property
2989 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2990 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2992 application.SendNotification();
2993 application.Render();
2998 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
3000 ToolkitTestApplication application;
3001 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3003 TextEditor editor = TextEditor::New();
3004 DALI_TEST_CHECK( editor );
3005 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3006 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3007 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3008 application.GetScene().Add( editor );
3010 application.SendNotification();
3011 application.Render();
3013 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
3014 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3016 // Check the enable match system language direction property
3017 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3018 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3020 application.SendNotification();
3021 application.Render();
3026 int UtcDaliTextEditorGetInputMethodContext(void)
3028 ToolkitTestApplication application;
3029 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3031 TextEditor editor = TextEditor::New();
3032 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3037 int utcDaliTextEditorMaxCharactersReached(void)
3039 ToolkitTestApplication application;
3040 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3042 TextEditor editor = TextEditor::New();
3043 DALI_TEST_CHECK( editor );
3045 application.GetScene().Add( editor );
3047 const int maxNumberOfCharacters = 1;
3048 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3049 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3051 editor.SetKeyInputFocus();
3053 // connect to the text changed signal.
3054 ConnectionTracker* testTracker = new ConnectionTracker();
3055 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3056 bool maxLengthReachedSignal = false;
3057 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3059 gMaxCharactersCallBackCalled = false;
3061 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3062 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3064 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3065 DALI_TEST_CHECK( maxLengthReachedSignal );
3070 int UtcDaliTextEditorSelectWholeText(void)
3072 ToolkitTestApplication application;
3073 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3075 TextEditor textEditor = TextEditor::New();
3077 application.GetScene().Add( textEditor );
3079 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3080 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3081 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3083 // Avoid a crash when core load gl resources.
3084 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3086 application.SendNotification();
3087 application.Render();
3089 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3091 DevelTextEditor::SelectWholeText( textEditor );
3093 application.SendNotification();
3094 application.Render();
3096 // Nothing should have been selected. The number of children is still 1
3097 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3099 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3101 application.SendNotification();
3102 application.Render();
3104 DevelTextEditor::SelectWholeText( textEditor );
3106 application.SendNotification();
3107 application.Render();
3109 // Should be 2 children, the stencil and the layer
3110 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3112 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3113 Actor stencil = textEditor.GetChildAt( 0u );
3115 // The highlight actor is drawn first, so is the first actor in the list
3116 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3117 DALI_TEST_CHECK( highlight );
3122 int UtcDaliTextEditorSelectNone(void)
3124 ToolkitTestApplication application;
3125 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3127 TextEditor textEditor = TextEditor::New();
3129 application.GetScene().Add( textEditor );
3131 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3132 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3133 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3135 // Avoid a crash when core load gl resources.
3136 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3138 application.SendNotification();
3139 application.Render();
3141 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3143 application.SendNotification();
3144 application.Render();
3146 // Nothing is selected
3147 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3148 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3150 DevelTextEditor::SelectWholeText( textEditor );
3152 application.SendNotification();
3153 application.Render();
3155 // whole text is selected
3156 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3157 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3159 DevelTextEditor::SelectNone( textEditor );
3161 application.SendNotification();
3162 application.Render();
3164 // Nothing is selected
3165 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3166 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3171 int UtcDaliTextEditorSelectRange(void)
3173 ToolkitTestApplication application;
3174 tet_infoline("utcDaliTextEditorSelectRange");
3176 TextEditor textEditor = TextEditor::New();
3177 DALI_TEST_CHECK( textEditor );
3179 application.GetScene().Add( textEditor );
3181 // Avoid a crash when core load gl resources.
3182 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3184 application.SendNotification();
3185 application.Render();
3187 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3189 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3190 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3192 // Hello is selected
3193 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3194 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3196 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3197 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3202 int UtcDaliTextEditorEnableEditing(void)
3204 ToolkitTestApplication application;
3205 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3207 TextEditor textEditor = TextEditor::New();
3209 application.GetScene().Add( textEditor );
3211 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3212 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3213 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3215 // Avoid a crash when core load gl resources.
3216 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3218 application.SendNotification();
3219 application.Render();
3221 textEditor.SetKeyInputFocus();
3222 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3223 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3225 // Render and notify
3226 application.SendNotification();
3227 application.Render();
3229 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3230 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3232 textEditor.SetKeyInputFocus();
3233 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3234 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3236 // Render and notify
3237 application.SendNotification();
3238 application.Render();
3240 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3241 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3246 int UtcDaliTextEditorScrolling(void)
3248 ToolkitTestApplication application;
3249 tet_infoline(" UtcDaliTextEditorScrolling ");
3251 TextEditor textEditor = TextEditor::New();
3252 DALI_TEST_CHECK( textEditor );
3254 application.GetScene().Add( textEditor );
3256 // Avoid a crash when core load gl resources.
3257 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3259 application.SendNotification();
3260 application.Render();
3262 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3263 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3264 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3265 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3267 application.SendNotification();
3268 application.Render();
3270 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3271 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3274 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3276 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3277 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3279 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3281 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3282 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3284 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3285 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3287 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3288 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3293 int UtcDaliToolkitTextEditorFontSizeScale(void)
3295 ToolkitTestApplication application;
3296 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3298 TextEditor textEditor = TextEditor::New();
3299 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3300 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3301 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3303 TextEditor textEditorScaled = TextEditor::New();
3304 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3305 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3306 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3307 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3309 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3311 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3312 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3313 nonScaledSize = textEditor.GetNaturalSize();
3315 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3316 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3317 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3318 scaledSize = textEditorScaled.GetNaturalSize();
3320 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3325 int UtcDaliTextEditorPrimaryCursorPosition(void)
3327 ToolkitTestApplication application;
3328 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3330 TextEditor textEditor = TextEditor::New();
3332 application.GetScene().Add( textEditor );
3334 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3335 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3336 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3337 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3339 // Avoid a crash when core load gl resources.
3340 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3342 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3343 application.SendNotification();
3344 application.Render();
3346 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3348 // Render and notify
3349 application.SendNotification();
3350 application.Render();
3352 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3353 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3358 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3360 ToolkitTestApplication application;
3361 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3363 TextEditor textEditor = TextEditor::New();
3364 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3365 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3366 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3367 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3368 application.GetScene().Add( textEditor );
3370 application.SendNotification();
3371 application.Render();
3374 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3375 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3377 textEditor.GetNaturalSize();
3379 // Create a tap event to touch the text editor.
3380 TestGenerateTap( application, 18.0f, 25.0f );
3382 application.SendNotification();
3383 application.Render();
3385 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3386 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3392 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase(void)
3394 ToolkitTestApplication application;
3396 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountScrollingCase ");
3398 int lineCountBefore =0 ;
3399 int lineCountAfter =0 ;
3401 // Create a text editor
3402 TextEditor textEditor = TextEditor::New();
3403 //Set very large font-size using point-size
3404 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3405 //Specify font-family
3406 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3408 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3409 //Set text longer than width of textEditor
3410 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3412 application.GetScene().Add( textEditor );
3414 application.SendNotification();
3415 application.Render();
3417 //Failed case is the GetHeightForWidth change LineCount then the scrollor will not arrive to latest line
3418 //GetHeightForWidth is a retrieval method which should not modify object
3419 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3420 textEditor.GetHeightForWidth(200.f);
3422 //This is to simulate focus into text editor after calling GetHeightForWidth
3423 //Create a tap event to touch the text editor.
3424 TestGenerateTap( application, 18.0f, 25.0f );
3426 application.SendNotification();
3427 application.Render();
3429 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3431 //The LineCount must not be changed when calling GetHeightForWidth.
3432 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3437 int utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase(void)
3439 ToolkitTestApplication application;
3441 tet_infoline(" utcDaliTextEditorGetHeightForWidthDoesNotChangeLineCountLineWrapCharCase ");
3443 int lineCountBefore =0 ;
3444 int lineCountAfter =0 ;
3446 // Create a text editor
3447 TextEditor textEditor = TextEditor::New();
3448 //Set very large font-size using point-size
3449 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3450 //Specify font-family
3451 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3453 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3454 //Set text longer than width of textEditor
3455 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3456 //Set line wrap mode Character
3457 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3459 application.GetScene().Add( textEditor );
3461 application.SendNotification();
3462 application.Render();
3464 //Failed case is the GetHeightForWidth change LineCount which make position of cursor invalid in TextEditor
3465 //GetHeightForWidth is a retrieval method which should not modify object
3466 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3467 textEditor.GetHeightForWidth(200.f);
3469 //This is to simulate focus into text editor after calling GetHeightForWidth
3470 //Create a tap event to touch the text editor.
3471 TestGenerateTap( application, 18.0f, 25.0f );
3473 application.SendNotification();
3474 application.Render();
3476 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3478 //The LineCount must not be changed when calling GetHeightForWidth.
3479 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3484 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase(void)
3486 ToolkitTestApplication application;
3488 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountScrollingCase ");
3490 int lineCountBefore =0 ;
3491 int lineCountAfter =0 ;
3493 // Create a text editor
3494 TextEditor textEditor = TextEditor::New();
3495 //Set very large font-size using point-size
3496 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3497 //Specify font-family
3498 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3500 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
3501 //Set text longer than width of textEditor
3502 textEditor.SetProperty( TextEditor::Property::TEXT, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
3504 application.GetScene().Add( textEditor );
3506 application.SendNotification();
3507 application.Render();
3509 //Failed case is the GetNaturalSize change LineCount then the scrollor will not arrive to latest line
3510 //GetNaturalSize is a retrieval method which should not modify object
3511 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3512 textEditor.GetNaturalSize();
3514 //This is to simulate focus into text editor after calling GetNaturalSize
3515 //Create a tap event to touch the text editor.
3516 TestGenerateTap( application, 18.0f, 25.0f );
3518 application.SendNotification();
3519 application.Render();
3521 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3523 //The LineCount must not be changed when calling GetNaturalSize.
3524 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3529 int utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase(void)
3531 ToolkitTestApplication application;
3533 tet_infoline(" utcDaliTextEditorGetNaturalSizeDoesNotChangeLineCountLineWrapCharCase ");
3535 int lineCountBefore =0 ;
3536 int lineCountAfter =0 ;
3538 // Create a text editor
3539 TextEditor textEditor = TextEditor::New();
3540 //Set very large font-size using point-size
3541 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
3542 //Specify font-family
3543 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3545 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
3546 //Set text longer than width of textEditor
3547 textEditor.SetProperty( TextEditor::Property::TEXT, "qwertyuiopasdfghjklzxcvbnm\n");
3548 //Set line wrap mode Character
3549 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, "CHARACTER");
3551 application.GetScene().Add( textEditor );
3553 application.SendNotification();
3554 application.Render();
3556 //Failed case is the GetNaturalSize change LineCount which make position of cursor invalid in TextEditor
3557 //GetNaturalSize is a retrieval method which should not modify object
3558 lineCountBefore = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3559 textEditor.GetNaturalSize( );
3561 //This is to simulate focus into text editor after calling GetNaturalSize
3562 //Create a tap event to touch the text editor.
3563 TestGenerateTap( application, 18.0f, 25.0f );
3565 application.SendNotification();
3566 application.Render();
3568 lineCountAfter = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3570 //The LineCount must not be changed when calling GetNaturalSize.
3571 DALI_TEST_EQUALS( lineCountAfter , lineCountBefore, TEST_LOCATION );
3576 int UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize(void)
3578 ToolkitTestApplication application;
3579 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledForLargeFontPointSize ");
3581 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3582 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3583 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3585 // Create a text editor
3586 TextEditor textEditor = TextEditor::New();
3588 //Set size to avoid automatic eliding
3589 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3590 //Set very large font-size using point-size
3591 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 1000) ;
3592 //Specify font-family
3593 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3594 //Set text to check if appear or not
3595 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3597 application.GetScene().Add( textEditor );
3599 application.SendNotification();
3600 application.Render();
3601 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3602 Vector3 naturalSize = textEditor.GetNaturalSize();
3604 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3605 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3610 int UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases(void)
3612 ToolkitTestApplication application;
3613 tet_infoline(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases ");
3615 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3616 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3617 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3619 Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3620 // Create a text editor
3621 TextEditor textEditor = TextEditor::New();
3622 //Set size to avoid automatic eliding
3623 textEditor.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3624 textEditor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVu Sans");
3625 textEditor.SetProperty( TextEditor::Property::TEXT, "A");
3627 const int numberOfCases = 6;
3628 int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3630 for (int index=0; index < numberOfCases; index++)
3632 tet_printf(" UtcDaliTextEditorAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3633 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, arrayCases[index]) ;
3634 application.GetScene().Add( textEditor );
3635 application.SendNotification();
3636 application.Render();
3637 naturalSize = textEditor.GetNaturalSize();
3638 DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3639 DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3646 int UtcDaliTextEditorHyphenWrapMode(void)
3648 ToolkitTestApplication application;
3649 tet_infoline(" UtcDaliTextEditorHyphenWrapMode ");
3652 TextEditor textEditor = TextEditor::New();
3654 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
3656 application.GetScene().Add( textEditor );
3657 application.SendNotification();
3658 application.Render();
3660 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3661 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
3662 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
3664 application.SendNotification();
3665 application.Render();
3667 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3673 DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
3675 textEditor.SetProperty( TextEditor::Property::TEXT, "Hi Experimen" );
3676 textEditor.SetProperty(TextEditor::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
3677 DALI_TEST_EQUALS( textEditor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
3679 application.SendNotification();
3680 application.Render();
3682 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3689 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );