2 * Copyright (c) 2020 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>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
102 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
103 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
104 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
105 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
109 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const unsigned int DEFAULT_FONT_SIZE = 1152u;
114 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
116 const int KEY_A_CODE = 38;
117 const int KEY_D_CODE = 40;
118 const int KEY_C_CODE = 54;
119 const int KEY_V_CODE = 55;
120 const int KEY_X_CODE = 53;
121 const int KEY_WHITE_SPACE_CODE = 65;
123 const int KEY_SHIFT_MODIFIER = 257;
124 const int KEY_CONTROL_MODIFIER = 258;
126 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
127 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
128 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
130 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
132 static bool gTextChangedCallBackCalled;
133 static bool gInputStyleChangedCallbackCalled;
134 static bool gMaxCharactersCallBackCalled;
135 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
137 struct CallbackFunctor
139 CallbackFunctor(bool* callbackFlag)
140 : mCallbackFlag( callbackFlag )
146 *mCallbackFlag = true;
151 static void TestTextChangedCallback( TextEditor control )
153 tet_infoline(" TestTextChangedCallback");
155 gTextChangedCallBackCalled = true;
158 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
160 tet_infoline(" TestInputStyleChangedCallback");
162 gInputStyleChangedCallbackCalled = true;
163 gInputStyleMask = mask;
166 static void TestMaxLengthReachedCallback( TextEditor control )
168 tet_infoline(" TestMaxLengthReachedCallback");
170 gMaxCharactersCallBackCalled = true;
173 // Generate a KeyEvent to send to Core.
174 Integration::KeyEvent GenerateKey( const std::string& keyName,
175 const std::string& logicalKey,
176 const std::string& keyString,
179 unsigned long timeStamp,
180 const Integration::KeyEvent::State& keyState,
181 const std::string& compose = "",
182 const std::string& deviceName = DEFAULT_DEVICE_NAME,
183 const Device::Class::Type& deviceClass = Device::Class::NONE,
184 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
186 return Integration::KeyEvent( keyName,
199 Dali::Integration::Point GetPointDownInside( Vector2& pos )
201 Dali::Integration::Point point;
202 point.SetState( PointState::DOWN );
203 point.SetScreenPosition( pos );
207 Dali::Integration::Point GetPointUpInside( Vector2& pos )
209 Dali::Integration::Point point;
210 point.SetState( PointState::UP );
211 point.SetScreenPosition( pos );
215 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
217 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
219 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
221 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
223 Property::Value* valueSet = NULL;
224 if ( valueGet.first.type == Property::Key::INDEX )
226 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
230 // Get Key is a string so searching Set Map for a string key
231 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
234 if( NULL != valueSet )
236 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
238 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
241 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
243 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
246 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
248 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
251 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
253 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
256 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
258 Vector2 vector2Get = valueGet.second.Get<Vector2>();
259 Vector2 vector2Set = valueSet->Get<Vector2>();
260 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
263 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
265 Vector4 vector4Get = valueGet.second.Get<Vector4>();
266 Vector4 vector4Set = valueSet->Get<Vector4>();
267 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 );
273 if ( valueGet.first.type == Property::Key::INDEX )
275 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
279 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
289 class ScrollStateChangeCallback : public Dali::ConnectionTracker
292 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
293 : mStartedCalled( startedCalled ),
294 mFinishedCalled( finishedCalled )
298 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
300 if( type == TextEditor::Scroll::STARTED )
302 mStartedCalled = true;
304 else if( type == TextEditor::Scroll::FINISHED )
306 mFinishedCalled = true;
310 bool& mStartedCalled;
311 bool& mFinishedCalled;
316 int UtcDaliToolkitTextEditorConstructorP(void)
318 ToolkitTestApplication application;
319 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
320 TextEditor textEditor;
321 DALI_TEST_CHECK( !textEditor );
325 int UtcDaliToolkitTextEditorNewP(void)
327 ToolkitTestApplication application;
328 tet_infoline(" UtcDaliToolkitTextEditorNewP");
329 TextEditor textEditor = TextEditor::New();
330 DALI_TEST_CHECK( textEditor );
334 int UtcDaliToolkitTextEditorDownCastP(void)
336 ToolkitTestApplication application;
337 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
338 TextEditor textEditor1 = TextEditor::New();
339 BaseHandle object( textEditor1 );
341 TextEditor textEditor2 = TextEditor::DownCast( object );
342 DALI_TEST_CHECK( textEditor2 );
344 TextEditor textEditor3 = DownCast< TextEditor >( object );
345 DALI_TEST_CHECK( textEditor3 );
349 int UtcDaliToolkitTextEditorDownCastN(void)
351 ToolkitTestApplication application;
352 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
353 BaseHandle uninitializedObject;
354 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
355 DALI_TEST_CHECK( !textEditor1 );
357 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
358 DALI_TEST_CHECK( !textEditor2 );
362 int UtcDaliToolkitTextEditorCopyConstructorP(void)
364 ToolkitTestApplication application;
365 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
366 TextEditor textEditor = TextEditor::New();
367 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
369 TextEditor copy( textEditor );
370 DALI_TEST_CHECK( copy );
371 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
375 int UtcDaliTextEditorMoveConstructor(void)
377 ToolkitTestApplication application;
379 TextEditor textEditor = TextEditor::New();
380 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
381 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
383 TextEditor moved = std::move( textEditor );
384 DALI_TEST_CHECK( moved );
385 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
386 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
387 DALI_TEST_CHECK( !textEditor );
392 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
394 ToolkitTestApplication application;
395 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
396 TextEditor textEditor = TextEditor::New();
397 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
399 TextEditor copy = textEditor;
400 DALI_TEST_CHECK( copy );
401 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
405 int UtcDaliTextEditorMoveAssignment(void)
407 ToolkitTestApplication application;
409 TextEditor textEditor = TextEditor::New();
410 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
411 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
414 moved = std::move( textEditor );
415 DALI_TEST_CHECK( moved );
416 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
417 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
418 DALI_TEST_CHECK( !textEditor );
423 int UtcDaliTextEditorNewP(void)
425 ToolkitTestApplication application;
426 tet_infoline(" UtcDaliToolkitTextEditorNewP");
427 TextEditor textEditor = TextEditor::New();
428 DALI_TEST_CHECK( textEditor );
432 // Positive test case for a method
433 int UtcDaliTextEditorGetPropertyP(void)
435 ToolkitTestApplication application;
436 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
437 TextEditor editor = TextEditor::New();
438 DALI_TEST_CHECK( editor );
440 // Check Property Indices are correct
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
503 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
506 Property::Map imageMap;
507 imageMap[mapKey] =mapValue;
509 editor.SetProperty( property , imageMap );
510 Property::Value propValue = editor.GetProperty( property );
511 Property::Map* resultMap = propValue.GetMap();
513 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
521 // Positive test case for a method
522 int UtcDaliTextEditorSetPropertyP(void)
524 ToolkitTestApplication application;
525 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
526 TextEditor editor = TextEditor::New();
527 DALI_TEST_CHECK( editor );
528 application.GetScene().Add( editor );
530 // Note - we can't check the defaults since the stylesheets are platform-specific
532 // Check the render backend property.
533 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
534 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
536 // Check text property.
537 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
538 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
540 // Check text's color property
541 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
542 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
544 // Check font properties.
545 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
546 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
548 Property::Map fontStyleMapSet;
549 Property::Map fontStyleMapGet;
550 Property::Value* slantValue = NULL;
552 fontStyleMapSet.Insert( "weight", "bold" );
553 fontStyleMapSet.Insert( "width", "condensed" );
554 fontStyleMapSet.Insert( "slant", "italic" );
556 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
557 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
558 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
559 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
561 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
562 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
564 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
565 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
566 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
569 fontStyleMapSet.Clear();
570 fontStyleMapSet.Insert( "weight", "normal" );
571 fontStyleMapSet.Insert( "slant", "oblique" );
572 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
574 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
575 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
577 fontStyleMapSet.Clear();
578 fontStyleMapSet.Insert( "slant", "roman" );
579 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
580 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
582 // Replace 'roman' for 'normal'.
583 slantValue = fontStyleMapGet.Find( "slant" );
584 if( NULL != slantValue )
586 if( "normal" == slantValue->Get<std::string>() )
588 fontStyleMapGet["slant"] = "roman";
591 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
594 fontStyleMapSet.Clear();
596 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
597 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
598 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
599 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
601 // Check that the Alignment properties can be correctly set
602 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
603 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
605 // Check scroll properties.
606 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
607 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
608 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
609 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
611 // Check cursor properties
612 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
613 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
614 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
615 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
617 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
618 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
619 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
620 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
621 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
622 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
624 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
626 // Check handle images
627 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
628 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
629 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
630 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
631 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
633 // Check handle images
634 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
635 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
641 // Check the highlight color
642 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
643 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
645 // Decoration bounding box
646 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
647 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
649 // Check the enable markup property.
650 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
651 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
652 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
654 // Check input color property.
655 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
656 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
658 // Check input font properties.
659 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
660 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
662 fontStyleMapSet.Clear();
663 fontStyleMapSet.Insert( "weight", "bold" );
664 fontStyleMapSet.Insert( "width", "condensed" );
665 fontStyleMapSet.Insert( "slant", "italic" );
667 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
668 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
669 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
670 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
672 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
673 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
675 // Reset input font style.
676 fontStyleMapSet.Clear();
677 fontStyleMapSet.Insert( "weight", "normal" );
678 fontStyleMapSet.Insert( "slant", "oblique" );
680 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
681 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
682 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
683 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
685 fontStyleMapSet.Clear();
686 fontStyleMapSet.Insert( "slant", "roman" );
688 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
689 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
691 // Replace 'roman' for 'normal'.
692 slantValue = fontStyleMapGet.Find( "slant" );
693 if( NULL != slantValue )
695 if( "normal" == slantValue->Get<std::string>() )
697 fontStyleMapGet["slant"] = "roman";
700 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
701 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
703 fontStyleMapSet.Clear();
705 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
706 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
707 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
708 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
710 // Check the line spacing property
711 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
712 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
713 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715 // Check the input line spacing property
716 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
718 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
720 // Check the underline property
722 Property::Map underlineMapSet;
723 Property::Map underlineMapGet;
725 underlineMapSet.Insert( "enable", true );
726 underlineMapSet.Insert( "color", Color::RED );
727 underlineMapSet.Insert( "height", 1 );
729 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
731 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
732 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
733 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
735 // Check the input underline property
736 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
737 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
739 // Check the shadow property
740 Property::Map shadowMapSet;
741 Property::Map shadowMapGet;
743 shadowMapSet.Insert( "color", Color::GREEN );
744 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
745 shadowMapSet.Insert( "blurRadius", 3.0f );
747 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
749 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
750 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
753 // Check the input shadow property
754 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
755 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
757 // Check the emboss property
758 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
759 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
761 // Check the input emboss property
762 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
763 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
765 // Check the outline property
767 // Test string type first
768 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
769 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
770 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
772 // Then test the property map type
773 Property::Map outlineMapSet;
774 Property::Map outlineMapGet;
776 outlineMapSet["color"] = Color::RED;
777 outlineMapSet["width"] = 2.0f;
779 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
781 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
782 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
783 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
785 // Check the input outline property
786 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
787 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
789 // Check the smooth scroll property
790 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
791 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
792 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
794 // Check the smooth scroll duration property
795 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
796 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
798 // Check the scroll bar property
799 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
800 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
801 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
803 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
804 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
805 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
806 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
808 // Check the pixel size of font
809 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
810 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
812 // Check placeholder text properties.
813 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
814 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
816 // Check placeholder text's color property.
817 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
818 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
820 // Check the enable selection property
821 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
822 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
824 // Check the placeholder property with pixel size
825 Property::Map placeholderPixelSizeMapSet;
826 Property::Map placeholderPixelSizeMapGet;
827 Property::Map placeholderFontstyleMap;
828 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
829 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
830 placeholderPixelSizeMapSet["color"] = Color::BLUE;
831 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
832 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
834 placeholderFontstyleMap.Insert( "weight", "bold" );
835 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
836 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
838 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
839 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
841 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
842 Property::Map placeholderConversionMap;
843 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
844 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
845 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
846 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
847 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
848 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
850 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
852 // Check the placeholder property with point size
853 Property::Map placeholderMapSet;
854 Property::Map placeholderMapGet;
855 placeholderMapSet["text"] = "Setting Placeholder Text";
856 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
857 placeholderMapSet["color"] = Color::RED;
858 placeholderMapSet["fontFamily"] = "Arial";
859 placeholderMapSet["pointSize"] = 12.0f;
860 // Check the placeholder font style property
861 placeholderFontstyleMap.Clear();
863 placeholderFontstyleMap.Insert( "weight", "bold" );
864 placeholderFontstyleMap.Insert( "width", "condensed" );
865 placeholderFontstyleMap.Insert( "slant", "italic" );
866 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
867 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
869 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
870 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
872 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
873 placeholderConversionMap.Clear();
874 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
875 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
876 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
877 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
878 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
879 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
880 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
883 placeholderFontstyleMap.Clear();
884 placeholderFontstyleMap.Insert( "weight", "normal" );
885 placeholderFontstyleMap.Insert( "slant", "oblique" );
886 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
887 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
889 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
890 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
891 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
892 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
894 placeholderFontstyleMap.Clear();
895 placeholderFontstyleMap.Insert( "slant", "roman" );
896 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
897 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
899 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
901 placeholderFontstyleMap.Clear();
902 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
904 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
905 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
906 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
907 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
908 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
910 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
911 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
913 application.SendNotification();
914 application.Render();
919 // Positive Atlas Text Renderer test
920 int utcDaliTextEditorAtlasRenderP(void)
922 ToolkitTestApplication application;
923 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
924 StyleManager styleManager = StyleManager::Get();
925 styleManager.ApplyDefaultTheme();
926 TextEditor editor = TextEditor::New();
927 DALI_TEST_CHECK( editor );
929 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
931 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
933 application.GetScene().Add( editor );
937 // Render some text with the shared atlas backend
938 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
939 application.SendNotification();
940 application.Render();
944 tet_result(TET_FAIL);
949 // Positive test for the textChanged signal.
950 int utcDaliTextEditorTextChangedP(void)
952 ToolkitTestApplication application;
953 tet_infoline(" utcDaliTextEditorTextChangedP");
954 TextEditor editor = TextEditor::New();
955 DALI_TEST_CHECK( editor );
957 application.GetScene().Add( editor );
959 // connect to the text changed signal.
960 ConnectionTracker* testTracker = new ConnectionTracker();
961 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
962 bool textChangedSignal = false;
963 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
965 gTextChangedCallBackCalled = false;
966 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
967 DALI_TEST_CHECK( gTextChangedCallBackCalled );
968 DALI_TEST_CHECK( textChangedSignal );
970 application.SendNotification();
972 editor.SetKeyInputFocus();
974 gTextChangedCallBackCalled = false;
975 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
976 DALI_TEST_CHECK( gTextChangedCallBackCalled );
981 int utcDaliTextEditorInputStyleChanged01(void)
983 // The text-editor emits signals when the input style changes. These changes of style are
984 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
985 // can't be emitted during the size negotiation as the callbacks may update the UI.
986 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
987 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
988 ToolkitTestApplication application;
989 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
993 char* pathNamePtr = get_current_dir_name();
994 const std::string pathName( pathNamePtr );
997 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
998 fontClient.SetDpi( 93u, 93u );
1000 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1001 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1003 TextEditor editor = TextEditor::New();
1004 DALI_TEST_CHECK( editor );
1007 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1008 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1009 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1011 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1012 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1014 // connect to the text changed signal.
1015 ConnectionTracker* testTracker = new ConnectionTracker();
1016 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1017 bool inputStyleChangedSignal = false;
1018 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1020 application.GetScene().Add( editor );
1022 // Render and notify
1023 application.SendNotification();
1024 application.Render();
1026 // Executes the idle callbacks added by the text control on the change of input style.
1027 application.RunIdles();
1029 gInputStyleChangedCallbackCalled = false;
1030 gInputStyleMask = TextEditor::InputStyle::NONE;
1031 inputStyleChangedSignal = false;
1033 // Create a tap event to touch the text editor.
1034 TestGenerateTap( application, 18.0f, 25.0f );
1036 // Render and notify
1037 application.SendNotification();
1038 application.Render();
1040 // Executes the idle callbacks added by the text control on the change of input style.
1041 application.RunIdles();
1043 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1044 if( gInputStyleChangedCallbackCalled )
1046 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1048 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1049 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1051 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1052 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1054 DALI_TEST_CHECK( inputStyleChangedSignal );
1056 gInputStyleChangedCallbackCalled = false;
1057 gInputStyleMask = TextEditor::InputStyle::NONE;
1058 inputStyleChangedSignal = false;
1060 // Create a tap event to touch the text editor.
1061 TestGenerateTap( application, 30.0f, 25.0f );
1063 // Render and notify
1064 application.SendNotification();
1065 application.Render();
1067 // Executes the idle callbacks added by the text control on the change of input style.
1068 application.RunIdles();
1070 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1071 DALI_TEST_CHECK( !inputStyleChangedSignal );
1073 gInputStyleChangedCallbackCalled = false;
1074 gInputStyleMask = TextEditor::InputStyle::NONE;
1075 inputStyleChangedSignal = false;
1077 // Create a tap event to touch the text editor.
1078 TestGenerateTap( application, 43.0f, 25.0f );
1080 // Render and notify
1081 application.SendNotification();
1082 application.Render();
1084 // Executes the idle callbacks added by the text control on the change of input style.
1085 application.RunIdles();
1087 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1088 if( gInputStyleChangedCallbackCalled )
1090 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1092 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1093 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1095 DALI_TEST_CHECK( inputStyleChangedSignal );
1097 gInputStyleChangedCallbackCalled = false;
1098 gInputStyleMask = TextEditor::InputStyle::NONE;
1099 inputStyleChangedSignal = false;
1101 // Create a tap event to touch the text editor.
1102 TestGenerateTap( application, 88.0f, 25.0f );
1104 // Render and notify
1105 application.SendNotification();
1106 application.Render();
1108 // Executes the idle callbacks added by the text control on the change of input style.
1109 application.RunIdles();
1111 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1112 if( gInputStyleChangedCallbackCalled )
1114 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1116 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1117 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1119 Property::Map fontStyleMapSet;
1120 Property::Map fontStyleMapGet;
1122 fontStyleMapSet.Insert( "weight", "bold" );
1124 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1125 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1126 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1128 DALI_TEST_CHECK( inputStyleChangedSignal );
1130 gInputStyleChangedCallbackCalled = false;
1131 gInputStyleMask = TextEditor::InputStyle::NONE;
1132 inputStyleChangedSignal = false;
1134 // Create a tap event to touch the text editor.
1135 TestGenerateTap( application, 115.0f, 25.0f );
1137 // Render and notify
1138 application.SendNotification();
1139 application.Render();
1141 // Executes the idle callbacks added by the text control on the change of input style.
1142 application.RunIdles();
1144 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1145 DALI_TEST_CHECK( !inputStyleChangedSignal );
1147 gInputStyleChangedCallbackCalled = false;
1148 gInputStyleMask = TextEditor::InputStyle::NONE;
1149 inputStyleChangedSignal = false;
1151 // Create a tap event to touch the text editor.
1152 TestGenerateTap( application, 164.0f, 25.0f );
1154 // Render and notify
1155 application.SendNotification();
1156 application.Render();
1158 // Executes the idle callbacks added by the text control on the change of input style.
1159 application.RunIdles();
1161 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1162 if( gInputStyleChangedCallbackCalled )
1164 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1166 Property::Map fontStyleMapSet;
1167 Property::Map fontStyleMapGet;
1169 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1170 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1171 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1173 DALI_TEST_CHECK( inputStyleChangedSignal );
1175 gInputStyleChangedCallbackCalled = false;
1176 gInputStyleMask = TextEditor::InputStyle::NONE;
1177 inputStyleChangedSignal = false;
1179 // Create a tap event to touch the text editor.
1180 TestGenerateTap( application, 191.0f, 25.0f );
1182 // Render and notify
1183 application.SendNotification();
1184 application.Render();
1186 // Executes the idle callbacks added by the text control on the change of input style.
1187 application.RunIdles();
1189 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1190 DALI_TEST_CHECK( !inputStyleChangedSignal );
1195 int utcDaliTextEditorInputStyleChanged02(void)
1197 // The text-editor emits signals when the input style changes. These changes of style are
1198 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1199 // can't be emitted during the size negotiation as the callbacks may update the UI.
1200 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1201 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1202 ToolkitTestApplication application;
1203 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1207 char* pathNamePtr = get_current_dir_name();
1208 const std::string pathName( pathNamePtr );
1209 free( pathNamePtr );
1211 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1212 fontClient.SetDpi( 93u, 93u );
1214 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1215 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1217 TextEditor editor = TextEditor::New();
1218 DALI_TEST_CHECK( editor );
1221 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1222 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1223 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1225 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1226 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>" );
1228 // connect to the text changed signal.
1229 ConnectionTracker* testTracker = new ConnectionTracker();
1230 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1231 bool inputStyleChangedSignal = false;
1232 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1234 application.GetScene().Add( editor );
1236 // Render and notify
1237 application.SendNotification();
1238 application.Render();
1240 // Executes the idle callbacks added by the text control on the change of input style.
1241 application.RunIdles();
1243 gInputStyleChangedCallbackCalled = false;
1244 gInputStyleMask = TextEditor::InputStyle::NONE;
1245 inputStyleChangedSignal = false;
1247 // Create a tap event to touch the text editor.
1248 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1249 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1251 // Render and notify
1252 application.SendNotification();
1253 application.Render();
1255 // Executes the idle callbacks added by the text control on the change of input style.
1256 application.RunIdles();
1258 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1259 if( gInputStyleChangedCallbackCalled )
1261 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1262 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1263 TextEditor::InputStyle::POINT_SIZE |
1264 TextEditor::InputStyle::COLOR ),
1267 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1268 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1270 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1271 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1273 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1274 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1276 DALI_TEST_CHECK( inputStyleChangedSignal );
1278 gInputStyleChangedCallbackCalled = false;
1279 gInputStyleMask = TextEditor::InputStyle::NONE;
1280 inputStyleChangedSignal = false;
1282 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1284 // Render and notify
1285 application.SendNotification();
1286 application.Render();
1288 // Executes the idle callbacks added by the text control on the change of input style.
1289 application.RunIdles();
1291 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1292 if( gInputStyleChangedCallbackCalled )
1294 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1295 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1298 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1299 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1301 DALI_TEST_CHECK( inputStyleChangedSignal );
1303 gInputStyleChangedCallbackCalled = false;
1304 gInputStyleMask = TextEditor::InputStyle::NONE;
1305 inputStyleChangedSignal = false;
1307 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 // Executes the idle callbacks added by the text control on the change of input style.
1314 application.RunIdles();
1316 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1317 DALI_TEST_CHECK( !inputStyleChangedSignal );
1319 gInputStyleChangedCallbackCalled = false;
1320 gInputStyleMask = TextEditor::InputStyle::NONE;
1321 inputStyleChangedSignal = false;
1323 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1325 // Render and notify
1326 application.SendNotification();
1327 application.Render();
1329 // Executes the idle callbacks added by the text control on the change of input style.
1330 application.RunIdles();
1332 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1333 if( gInputStyleChangedCallbackCalled )
1335 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1336 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1339 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1340 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1342 DALI_TEST_CHECK( inputStyleChangedSignal );
1344 gInputStyleChangedCallbackCalled = false;
1345 gInputStyleMask = TextEditor::InputStyle::NONE;
1346 inputStyleChangedSignal = false;
1348 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1350 Property::Map fontStyleMapSet;
1351 fontStyleMapSet.Insert( "weight", "thin" );
1352 fontStyleMapSet.Insert( "width", "condensed" );
1353 fontStyleMapSet.Insert( "slant", "italic" );
1355 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1356 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1357 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1359 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1360 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1361 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1362 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1364 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1366 // Render and notify
1367 application.SendNotification();
1368 application.Render();
1370 // Executes the idle callbacks added by the text control on the change of input style.
1371 application.RunIdles();
1373 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1374 DALI_TEST_CHECK( !inputStyleChangedSignal );
1376 // Create a tap event to touch the text editor.
1377 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Executes the idle callbacks added by the text control on the change of input style.
1384 application.RunIdles();
1386 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1387 if( gInputStyleChangedCallbackCalled )
1389 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1390 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1391 TextEditor::InputStyle::POINT_SIZE |
1392 TextEditor::InputStyle::FONT_STYLE |
1393 TextEditor::InputStyle::LINE_SPACING |
1394 TextEditor::InputStyle::UNDERLINE |
1395 TextEditor::InputStyle::SHADOW |
1396 TextEditor::InputStyle::EMBOSS |
1397 TextEditor::InputStyle::OUTLINE ),
1400 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1401 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1403 DALI_TEST_CHECK( inputStyleChangedSignal );
1405 gInputStyleChangedCallbackCalled = false;
1406 gInputStyleMask = TextEditor::InputStyle::NONE;
1407 inputStyleChangedSignal = false;
1409 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1411 fontStyleMapSet.Clear();
1412 fontStyleMapSet.Insert( "weight", "black" );
1413 fontStyleMapSet.Insert( "width", "expanded" );
1414 fontStyleMapSet.Insert( "slant", "oblique" );
1416 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1418 // Create a tap event to touch the text editor.
1419 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1421 // Render and notify
1422 application.SendNotification();
1423 application.Render();
1425 // Executes the idle callbacks added by the text control on the change of input style.
1426 application.RunIdles();
1428 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1429 if( gInputStyleChangedCallbackCalled )
1431 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1432 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1433 TextEditor::InputStyle::POINT_SIZE |
1434 TextEditor::InputStyle::FONT_STYLE ),
1437 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1438 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1440 DALI_TEST_CHECK( inputStyleChangedSignal );
1445 int utcDaliTextEditorEvent01(void)
1447 ToolkitTestApplication application;
1448 tet_infoline(" utcDaliTextEditorEvent01");
1450 // Creates a tap event. After creating a tap event the text editor should
1451 // have the focus and add text with key events should be possible.
1453 TextEditor editor = TextEditor::New();
1454 DALI_TEST_CHECK( editor );
1456 application.GetScene().Add( editor );
1458 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1459 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1460 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1462 // Avoid a crash when core load gl resources.
1463 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1465 // Render and notify
1466 application.SendNotification();
1467 application.Render();
1469 // Add a key event but as the text editor has not the focus it should do nothing.
1470 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1478 // Create a tap event to touch the text editor.
1479 TestGenerateTap( application, 150.0f, 25.0f );
1481 // Render and notify
1482 application.SendNotification();
1483 application.Render();
1485 // Now the text editor has the focus, so it can handle the key events.
1486 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1487 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1489 // Render and notify
1490 application.SendNotification();
1491 application.Render();
1493 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1495 // Create a second text editor and send key events to it.
1496 TextEditor editor2 = TextEditor::New();
1498 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1499 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1500 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1501 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1503 application.GetScene().Add( editor2 );
1505 // Render and notify
1506 application.SendNotification();
1507 application.Render();
1509 // Create a tap event on the second text editor.
1510 TestGenerateTap( application, 150.0f, 125.0f );
1512 // Render and notify
1513 application.SendNotification();
1514 application.Render();
1516 // The second text editor has the focus. It should handle the key events.
1517 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1518 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Check the text has been added to the second text editor.
1525 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1530 int utcDaliTextEditorEvent02(void)
1532 ToolkitTestApplication application;
1533 tet_infoline(" utcDaliTextEditorEvent02");
1535 // Checks if the right number of actors are created.
1537 TextEditor editor = TextEditor::New();
1538 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1539 DALI_TEST_CHECK( editor );
1541 application.GetScene().Add( editor );
1543 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1544 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1545 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1547 // Avoid a crash when core load gl resources.
1548 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1550 // Render and notify
1551 application.SendNotification();
1552 application.Render();
1554 // Check there are the expected number of children (the stencil).
1555 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1557 Actor stencil = editor.GetChildAt( 0u );
1559 // Create a tap event to touch the text editor.
1560 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1562 // Render and notify
1563 application.SendNotification();
1564 application.Render();
1566 Actor layer = editor.GetChildAt( 1u );
1567 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1568 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1570 // Now the text editor has the focus, so it can handle the key events.
1571 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1572 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Checks the cursor and the renderer have been created.
1579 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1580 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1582 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1583 DALI_TEST_CHECK( cursor );
1585 // The stencil actor has a container with all the actors which contain the text renderers.
1586 Actor container = stencil.GetChildAt( 0u );
1587 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1589 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1590 DALI_TEST_CHECK( renderer );
1593 // Move the cursor and check the position changes.
1594 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1596 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1597 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1599 // Render and notify
1600 application.SendNotification();
1601 application.Render();
1603 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1605 DALI_TEST_CHECK( position2.x < position1.x );
1607 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1608 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1610 // Render and notify
1611 application.SendNotification();
1612 application.Render();
1614 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1616 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1618 // Send some taps and check the cursor positions.
1620 // Try to tap at the beginning.
1621 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 // Cursor position should be the same than position1.
1628 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1630 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1632 // Tap away from the start position.
1633 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1635 // Render and notify
1636 application.SendNotification();
1637 application.Render();
1639 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1641 DALI_TEST_CHECK( position5.x > position4.x );
1643 // Remove all the text.
1644 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1645 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1646 editor.SetProperty( TextEditor::Property::TEXT, "" );
1648 // Render and notify
1649 application.SendNotification();
1650 application.Render();
1652 // Cursor position should be the same than position2.
1653 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1655 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1657 // Should not be a renderer.
1658 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1663 int utcDaliTextEditorEvent03(void)
1665 ToolkitTestApplication application;
1666 tet_infoline(" utcDaliTextEditorEvent03");
1668 // Checks if the highlight actor is created.
1670 TextEditor editor = TextEditor::New();
1671 DALI_TEST_CHECK( editor );
1673 application.GetScene().Add( editor );
1675 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1676 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1677 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1678 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1679 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1681 // Avoid a crash when core load gl resources.
1682 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1684 // Render and notify
1685 application.SendNotification();
1686 application.Render();
1688 // Send some taps and check text controller with clipboard window
1689 Dali::Clipboard clipboard = Clipboard::Get();
1690 clipboard.ShowClipboard();
1691 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1692 clipboard.HideClipboard();
1694 // Render and notify
1695 application.SendNotification();
1696 application.Render();
1698 // Tap first to get the focus.
1699 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 // Double tap to select a word.
1706 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1708 // Render and notify
1709 application.SendNotification();
1710 application.Render();
1712 // The stencil actor should have two actors: the renderer and the highlight actor.
1713 Actor stencil = editor.GetChildAt( 0u );
1715 // Highlight needs to be drawn before text, so should come first in child order
1716 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1717 DALI_TEST_CHECK( highlight );
1719 // The stencil actor has a container with all the actors which contain the text renderers.
1720 Actor container = stencil.GetChildAt( 1u );
1721 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1723 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1724 DALI_TEST_CHECK( renderer );
1727 // Double tap out of bounds
1728 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1729 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1731 // Render and notify
1732 application.SendNotification();
1733 application.Render();
1735 // The stencil actor should have one actors: the renderer actor.
1736 stencil = editor.GetChildAt( 0u );
1738 // The stencil actor has a container with all the actors which contain the text renderers.
1739 container = stencil.GetChildAt( 0u );
1740 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1742 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1743 DALI_TEST_CHECK( renderer );
1747 TestGenerateLongPress(application, 1.0f, 25.0f);
1749 // Render and notify
1750 application.SendNotification();
1751 application.Render();
1754 TestGenerateMiniPan(application);
1756 // Render and notify
1757 application.SendNotification();
1758 application.Render();
1763 int utcDaliTextEditorEvent04(void)
1765 ToolkitTestApplication application;
1766 tet_infoline(" utcDaliTextEditorEvent04");
1768 // Checks if the highlight actor is created.
1770 TextEditor editor = TextEditor::New();
1771 DALI_TEST_CHECK( editor );
1773 application.GetScene().Add( editor );
1775 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1776 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1777 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1778 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1779 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1781 // Avoid a crash when core load gl resources.
1782 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1788 // Tap on the text editor
1789 TestGenerateTap( application, 3.0f, 25.0f );
1791 // Render and notify
1792 application.SendNotification();
1793 application.Render();
1795 // Move at the end of the text.
1796 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1797 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1799 // Render and notify
1800 application.SendNotification();
1801 application.Render();
1803 for( unsigned int index = 0u; index < 10u; ++index )
1805 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1806 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1808 // Render and notify
1809 application.SendNotification();
1810 application.Render();
1814 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
1820 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1822 // Add some key events
1823 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1824 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 for( unsigned int index = 0u; index < 10u; ++index )
1832 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1833 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1835 // Render and notify
1836 application.SendNotification();
1837 application.Render();
1841 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1847 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1852 int utcDaliTextEditorEvent05(void)
1854 ToolkitTestApplication application;
1855 tet_infoline(" utcDaliTextEditorEvent05");
1857 // Checks if the highlight actor is created.
1859 TextEditor editor = TextEditor::New();
1860 DALI_TEST_CHECK( editor );
1862 application.GetScene().Add( editor );
1864 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1865 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1866 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1867 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1868 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1869 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1870 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1871 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1872 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1873 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1875 // Avoid a crash when core load gl resources.
1876 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1878 // Render and notify
1879 application.SendNotification();
1880 application.Render();
1882 // Tap on the text editor
1883 TestGenerateTap( application, 3.0f, 25.0f );
1885 // Render and notify
1886 application.SendNotification();
1887 application.Render();
1889 // Move at the end of the text.
1890 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1891 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 for( unsigned int index = 0u; index < 10u; ++index )
1900 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1906 // Modify duration after scroll is enabled
1907 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1909 // Continuous scroll left to increase coverage
1910 for( unsigned int index = 0u; index < 10u; ++index )
1912 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1914 // Render and notify
1915 application.SendNotification();
1916 application.Render();
1918 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1919 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1920 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1921 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1922 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1924 // Press Escape to increase coverage
1925 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1926 application.SendNotification();
1927 application.Render();
1929 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1934 int utcDaliTextEditorEvent06(void)
1936 ToolkitTestApplication application;
1937 tet_infoline(" utcDaliTextEditorEvent06");
1939 // Checks if the highlight actor is created.
1941 TextEditor editor = TextEditor::New();
1942 DALI_TEST_CHECK( editor );
1944 application.GetScene().Add( editor );
1946 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1947 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1948 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1949 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1950 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1952 // Avoid a crash when core load gl resources.
1953 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1959 // Tap on the text editor
1960 TestGenerateTap( application, 3.0f, 25.0f );
1962 // Render and notify
1963 application.SendNotification();
1964 application.Render();
1966 // Move to seconds line of the text.
1967 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1969 // Render and notify
1970 application.SendNotification();
1971 application.Render();
1973 float layoutHeight = editor.GetHeightForWidth( 100.f );
1976 // Add another script characters ( glyph height is defferent )
1977 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1978 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1980 // Delete characters
1981 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1982 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1984 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1993 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1994 application.SendNotification();
1995 application.Render();
1997 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1998 application.SendNotification();
1999 application.Render();
2001 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2002 application.SendNotification();
2003 application.Render();
2005 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2006 application.SendNotification();
2007 application.Render();
2009 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2010 application.SendNotification();
2011 application.Render();
2013 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2014 application.SendNotification();
2015 application.Render();
2017 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2018 application.SendNotification();
2019 application.Render();
2024 int utcDaliTextEditorEvent07(void)
2026 ToolkitTestApplication application;
2027 tet_infoline(" utcDaliTextEditorEvent07");
2029 // Checks if the highlight actor is created.
2031 TextEditor editor = TextEditor::New();
2032 DALI_TEST_CHECK( editor );
2034 application.GetScene().Add( editor );
2036 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2037 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2038 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2039 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2040 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2042 // Avoid a crash when core load gl resources.
2043 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Tap on the text editor
2050 TestGenerateTap( application, 3.0f, 25.0f );
2052 // Render and notify
2053 application.SendNotification();
2054 application.Render();
2056 // Move to second line of the text.
2057 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2059 // Render and notify
2060 application.SendNotification();
2061 application.Render();
2063 // Select some text in the right of the current cursor position
2064 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2067 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2069 // Render and notify
2070 application.SendNotification();
2071 application.Render();
2073 // Cut the selected text
2074 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2075 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 ) );
2077 // Render and notify
2078 application.SendNotification();
2079 application.Render();
2081 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2083 // Select some text in the left of the current cursor position
2084 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2085 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2086 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2087 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2089 // Render and notify
2090 application.SendNotification();
2091 application.Render();
2093 // Copy the selected text
2094 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2095 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 ) );
2097 // Render and notify
2098 application.SendNotification();
2099 application.Render();
2101 // Move the cursor to the third line
2102 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2103 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2109 // Paste the selected text at the current cursor position
2110 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2111 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 ) );
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2117 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2120 // Disable Shift Selection
2121 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2123 // Test to select some text in the right of the current cursor position
2124 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2125 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2126 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2127 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 // Render and notify
2130 application.SendNotification();
2131 application.Render();
2133 // Cut the selected text
2134 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2135 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 ) );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2142 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2144 // Test to select some text in the left of the current cursor position
2145 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2146 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2150 // Render and notify
2151 application.SendNotification();
2152 application.Render();
2154 // Copy the selected text
2155 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 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 ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2163 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2166 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 ) );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 // replace text with "c"
2173 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2180 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2183 DevelTextEditor::SelectWholeText(editor);
2185 // Render and notify
2186 application.SendNotification();
2187 application.Render();
2189 // Copy the selected text using logical keys
2190 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 // Render and notify
2194 application.SendNotification();
2195 application.Render();
2198 DevelTextEditor::SelectNone(editor);
2200 // Render and notify
2201 application.SendNotification();
2202 application.Render();
2204 // Paste the selected using logical keys
2205 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2206 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2211 // select all using logical keys
2212 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 // Render and notify
2216 application.SendNotification();
2217 application.Render();
2219 // cut text using logical keys
2220 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2228 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2233 int utcDaliTextEditorEvent08(void)
2235 ToolkitTestApplication application;
2236 tet_infoline(" utcDaliTextEditorEvent08");
2238 // Checks if the highlight actor is released correctly.
2240 TextEditor editor = TextEditor::New();
2241 DALI_TEST_CHECK( editor );
2243 application.GetScene().Add( editor );
2245 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2246 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2247 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2248 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2249 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2251 // Avoid a crash when core load gl resources.
2252 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 // Tap on the text editor
2259 TestGenerateTap( application, 3.0f, 25.0f );
2261 // Render and notify
2262 application.SendNotification();
2263 application.Render();
2265 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2266 // Test to select some text in the left of the current cursor position
2267 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 // Render and notify
2273 application.SendNotification();
2274 application.Render();
2276 // Test to the left selection handle position and the right selection handle position
2277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2279 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2286 // Test to select full text in the left of the current cursor position
2287 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2294 // Render and notify
2295 application.SendNotification();
2296 application.Render();
2298 // Test to release the current full text selection
2299 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2300 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 // Render and notify
2303 application.SendNotification();
2304 application.Render();
2306 // Test to move the current cursor position correctly
2307 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2309 // Render and notify
2310 application.SendNotification();
2311 application.Render();
2314 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 // Render and notify
2317 application.SendNotification();
2318 application.Render();
2320 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2322 // Test to select some text in the right of the current cursor position
2323 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Test the cursor position with right arrow key
2332 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2334 // Render and notify
2335 application.SendNotification();
2336 application.Render();
2339 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2341 // Render and notify
2342 application.SendNotification();
2343 application.Render();
2345 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2347 // Test to select some text in the left of the current cursor position
2348 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2349 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2351 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // Test the cursor position with left arrow key
2359 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2366 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 // Render and notify
2369 application.SendNotification();
2370 application.Render();
2372 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2374 // Test to select some text in the right of the current cursor position
2375 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 // Test the cursor position with left arrow key
2385 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2392 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2394 // Render and notify
2395 application.SendNotification();
2396 application.Render();
2398 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2400 // Test to select some text in the left of the current cursor position
2401 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2402 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2403 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 // Test the cursor position with right arrow key
2411 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2413 // Render and notify
2414 application.SendNotification();
2415 application.Render();
2418 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2420 // Render and notify
2421 application.SendNotification();
2422 application.Render();
2424 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2429 int utcDaliTextEditorHandles(void)
2431 ToolkitTestApplication application;
2432 tet_infoline(" utcDaliTextEditorHandles");
2434 TextEditor editor = TextEditor::New();
2435 DALI_TEST_CHECK( editor );
2437 application.GetScene().Add( editor );
2439 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2440 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2441 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2442 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2444 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2445 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2446 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2447 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2449 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2450 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2451 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2453 // Avoid a crash when core load gl resources.
2454 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2456 // Render and notify
2457 application.SendNotification();
2458 application.Render();
2460 // Tap first to get the focus.
2461 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2463 // Render and notify
2464 application.SendNotification();
2465 application.Render();
2467 // Tap to create the grab handle.
2468 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2474 // Get the active layer where the text's decoration is added.
2475 Actor activeLayer = editor.GetChildAt( 1u );
2477 // Get the handle's actor.
2478 Actor handle = activeLayer.GetChildAt( 1u );
2479 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2481 // Render and notify
2482 application.SendNotification();
2483 application.Render();
2485 // Touch the grab handle to set it as pressed.
2486 Vector2 touchPos( 10.0f, 50.0f );
2487 Dali::Integration::TouchEvent event;
2488 event = Dali::Integration::TouchEvent();
2489 event.AddPoint( GetPointDownInside( touchPos ) );
2490 application.ProcessEvent( event );
2492 // Render and notify
2493 application.SendNotification();
2494 application.Render();
2496 // Pan the grab handle
2497 uint32_t time = 100;
2498 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2499 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2500 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2501 application.SendNotification();
2502 application.Render();
2505 // Release the grab handle.
2506 event = Dali::Integration::TouchEvent();
2507 event.AddPoint( GetPointUpInside( touchPos ) );
2508 application.ProcessEvent( event );
2510 // Render and notify
2511 application.SendNotification();
2512 application.Render();
2514 // Tap first to get the focus.
2515 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2517 // Render and notify
2518 application.SendNotification();
2519 application.Render();
2521 // Double tap to select a word and create the selection handles.
2522 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2524 // Render and notify
2525 application.SendNotification();
2526 application.Render();
2528 touchPos = Vector2( 10.0f, 50.0f );
2530 // Touch the left selection handle to set it as pressed.
2531 event = Dali::Integration::TouchEvent();
2532 event.AddPoint( GetPointDownInside( touchPos ) );
2533 application.ProcessEvent( event );
2535 // Render and notify
2536 application.SendNotification();
2537 application.Render();
2539 // Release the left selection handle.
2540 event = Dali::Integration::TouchEvent();
2541 event.AddPoint( GetPointUpInside( touchPos ) );
2542 application.ProcessEvent( event );
2544 // Render and notify
2545 application.SendNotification();
2546 application.Render();
2551 int utcDaliTextEditorUnderPropertyStringP(void)
2553 ToolkitTestApplication application;
2554 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2555 TextEditor editor = TextEditor::New();
2556 DALI_TEST_CHECK( editor );
2558 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2560 application.GetScene().Add( editor );
2562 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2563 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2565 tet_infoline("Set underline settings with a map");
2566 // Check the input underline property
2567 Property::Map underlineMapSet;
2568 Property::Map underlineMapGet;
2569 underlineMapSet.Insert( "enable", true );
2570 underlineMapSet.Insert( "color", Color::BLUE );
2571 underlineMapSet.Insert( "height", 2 );
2573 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2574 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2575 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2576 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2578 tet_infoline("Set underline settings with a string");
2579 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2580 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2583 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2585 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2586 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2587 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2588 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2590 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2595 int utcDaliTextEditorShadowPropertyStringP(void)
2597 ToolkitTestApplication application;
2598 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2600 TextEditor editor = TextEditor::New();
2602 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2604 application.GetScene().Add( editor );
2606 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2608 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2612 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2617 int utcDaliTextEditorFontStylePropertyStringP(void)
2619 ToolkitTestApplication application;
2620 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2622 TextEditor editor = TextEditor::New();
2624 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2626 application.GetScene().Add( editor );
2628 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2630 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2634 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2639 int utcDaliTextEditorGetPropertyLinecountP(void)
2641 ToolkitTestApplication application;
2643 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2647 TextEditor editor = TextEditor::New();
2648 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2649 editor.SetProperty( TextEditor::Property::TEXT,
2650 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2652 application.GetScene().Add( editor );
2654 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2655 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2656 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2658 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2659 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2660 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2665 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2668 ToolkitTestApplication application;
2669 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2671 TextEditor editor = TextEditor::New();
2672 DALI_TEST_CHECK( editor );
2674 application.GetScene().Add( editor );
2676 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2677 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2678 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2679 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2680 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2681 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2683 bool startedCalled = false;
2684 bool finishedCalled = false;
2686 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2687 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2689 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2691 // Render and notify
2692 application.SendNotification();
2693 application.Render();
2695 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2696 application.SendNotification();
2697 application.Render(6000);
2699 application.SendNotification();
2700 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2701 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2706 int UtcDaliToolkitTextEditorTextWrapMode(void)
2708 ToolkitTestApplication application;
2709 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2713 TextEditor editor = TextEditor::New();
2714 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2715 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2717 application.GetScene().Add( editor );
2719 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2720 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2722 application.SendNotification();
2723 application.Render();
2725 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2726 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2728 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2729 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2731 application.SendNotification();
2732 application.Render();
2734 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2735 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2737 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2738 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2740 application.SendNotification();
2741 application.Render();
2743 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2744 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2746 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2747 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2749 application.SendNotification();
2750 application.Render();
2752 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2753 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2758 int UtcDaliTextEditorSetPaddingProperty(void)
2760 ToolkitTestApplication application;
2761 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2763 TextEditor editor = TextEditor::New();
2764 DALI_TEST_CHECK( editor );
2765 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2766 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2767 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2768 application.GetScene().Add( editor );
2770 application.SendNotification();
2771 application.Render();
2773 Vector3 originalSize = editor.GetNaturalSize();
2775 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2777 application.SendNotification();
2778 application.Render();
2780 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2782 Vector3 paddingAddedSize = editor.GetNaturalSize();
2784 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2786 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2791 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2793 ToolkitTestApplication application;
2794 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2796 TextEditor editor = TextEditor::New();
2797 DALI_TEST_CHECK( editor );
2798 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2799 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2800 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2801 application.GetScene().Add( editor );
2803 application.SendNotification();
2804 application.Render();
2806 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2807 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2809 // Check the enable shift selection property
2810 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2811 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2813 application.SendNotification();
2814 application.Render();
2819 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2821 ToolkitTestApplication application;
2822 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2824 TextEditor editor = TextEditor::New();
2825 DALI_TEST_CHECK( editor );
2826 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2827 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2828 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2829 application.GetScene().Add( editor );
2831 application.SendNotification();
2832 application.Render();
2834 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2835 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2837 // Check the enable grab handle property
2838 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2839 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2841 application.SendNotification();
2842 application.Render();
2847 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2849 ToolkitTestApplication application;
2850 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2852 TextEditor editor = TextEditor::New();
2853 DALI_TEST_CHECK( editor );
2854 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2855 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2856 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2857 application.GetScene().Add( editor );
2859 application.SendNotification();
2860 application.Render();
2862 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2863 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2865 // Check the enable match system language direction property
2866 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2867 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2869 application.SendNotification();
2870 application.Render();
2875 int UtcDaliTextEditorGetInputMethodContext(void)
2877 ToolkitTestApplication application;
2878 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2880 TextEditor editor = TextEditor::New();
2881 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2886 int utcDaliTextEditorMaxCharactersReached(void)
2888 ToolkitTestApplication application;
2889 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2891 TextEditor editor = TextEditor::New();
2892 DALI_TEST_CHECK( editor );
2894 application.GetScene().Add( editor );
2896 const int maxNumberOfCharacters = 1;
2897 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2898 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2900 editor.SetKeyInputFocus();
2902 // connect to the text changed signal.
2903 ConnectionTracker* testTracker = new ConnectionTracker();
2904 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2905 bool maxLengthReachedSignal = false;
2906 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2908 gMaxCharactersCallBackCalled = false;
2910 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2911 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2913 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2914 DALI_TEST_CHECK( maxLengthReachedSignal );
2919 int UtcDaliTextEditorSelectWholeText(void)
2921 ToolkitTestApplication application;
2922 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2924 TextEditor textEditor = TextEditor::New();
2926 application.GetScene().Add( textEditor );
2928 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2929 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2930 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2932 // Avoid a crash when core load gl resources.
2933 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2935 application.SendNotification();
2936 application.Render();
2938 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
2940 DevelTextEditor::SelectWholeText( textEditor );
2942 application.SendNotification();
2943 application.Render();
2945 // Nothing should have been selected. The number of children is still 1
2946 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
2948 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
2950 application.SendNotification();
2951 application.Render();
2953 DevelTextEditor::SelectWholeText( textEditor );
2955 application.SendNotification();
2956 application.Render();
2958 // Should be 2 children, the stencil and the layer
2959 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
2961 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2962 Actor stencil = textEditor.GetChildAt( 0u );
2964 // The highlight actor is drawn first, so is the first actor in the list
2965 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2966 DALI_TEST_CHECK( highlight );
2971 int UtcDaliTextEditorSelectNone(void)
2973 ToolkitTestApplication application;
2974 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2976 TextEditor textEditor = TextEditor::New();
2978 application.GetScene().Add( textEditor );
2980 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2981 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2982 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2984 // Avoid a crash when core load gl resources.
2985 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2987 application.SendNotification();
2988 application.Render();
2990 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
2992 application.SendNotification();
2993 application.Render();
2995 // Nothing is selected
2996 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
2997 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
2999 DevelTextEditor::SelectWholeText( textEditor );
3001 application.SendNotification();
3002 application.Render();
3004 // whole text is selected
3005 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3006 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3008 DevelTextEditor::SelectNone( textEditor );
3010 application.SendNotification();
3011 application.Render();
3013 // Nothing is selected
3014 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3015 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3020 int UtcDaliTextEditorSelectRange(void)
3022 ToolkitTestApplication application;
3023 tet_infoline("utcDaliTextEditorSelectRange");
3025 TextEditor textEditor = TextEditor::New();
3026 DALI_TEST_CHECK( textEditor );
3028 application.GetScene().Add( textEditor );
3030 // Avoid a crash when core load gl resources.
3031 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3033 application.SendNotification();
3034 application.Render();
3036 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3038 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3039 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3041 // Hello is selected
3042 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3043 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3045 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3046 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3051 int UtcDaliTextEditorEnableEditing(void)
3053 ToolkitTestApplication application;
3054 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3056 TextEditor textEditor = TextEditor::New();
3058 application.GetScene().Add( textEditor );
3060 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3061 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3062 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3064 // Avoid a crash when core load gl resources.
3065 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3067 application.SendNotification();
3068 application.Render();
3070 textEditor.SetKeyInputFocus();
3071 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3072 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3074 // Render and notify
3075 application.SendNotification();
3076 application.Render();
3078 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3079 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3081 textEditor.SetKeyInputFocus();
3082 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3083 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3085 // Render and notify
3086 application.SendNotification();
3087 application.Render();
3089 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3090 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3095 int UtcDaliTextEditorScrolling(void)
3097 ToolkitTestApplication application;
3098 tet_infoline(" UtcDaliTextEditorScrolling ");
3100 TextEditor textEditor = TextEditor::New();
3101 DALI_TEST_CHECK( textEditor );
3103 application.GetScene().Add( textEditor );
3105 // Avoid a crash when core load gl resources.
3106 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3108 application.SendNotification();
3109 application.Render();
3111 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3112 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3113 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3114 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3116 application.SendNotification();
3117 application.Render();
3119 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3120 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3123 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3125 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3126 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3128 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3130 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3131 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3133 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3134 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3136 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3137 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3142 int UtcDaliToolkitTextEditorFontSizeScale(void)
3144 ToolkitTestApplication application;
3145 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3147 TextEditor textEditor = TextEditor::New();
3148 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3149 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3150 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3152 TextEditor textEditorScaled = TextEditor::New();
3153 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3154 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3155 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3156 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3158 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3160 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3161 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3162 nonScaledSize = textEditor.GetNaturalSize();
3164 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3165 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3166 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3167 scaledSize = textEditorScaled.GetNaturalSize();
3169 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3174 int UtcDaliTextEditorPrimaryCursorPosition(void)
3176 ToolkitTestApplication application;
3177 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3179 TextEditor textEditor = TextEditor::New();
3181 application.GetScene().Add( textEditor );
3183 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3184 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3185 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3186 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3188 // Avoid a crash when core load gl resources.
3189 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3191 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3192 application.SendNotification();
3193 application.Render();
3195 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3197 // Render and notify
3198 application.SendNotification();
3199 application.Render();
3201 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3202 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );