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";
107 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
108 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const unsigned int DEFAULT_FONT_SIZE = 1152u;
113 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
115 const int KEY_A_CODE = 38;
116 const int KEY_D_CODE = 40;
117 const int KEY_C_CODE = 54;
118 const int KEY_V_CODE = 55;
119 const int KEY_X_CODE = 53;
120 const int KEY_WHITE_SPACE_CODE = 65;
122 const int KEY_SHIFT_MODIFIER = 257;
123 const int KEY_CONTROL_MODIFIER = 258;
125 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
126 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
127 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
131 static bool gTextChangedCallBackCalled;
132 static bool gInputStyleChangedCallbackCalled;
133 static bool gMaxCharactersCallBackCalled;
134 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
136 struct CallbackFunctor
138 CallbackFunctor(bool* callbackFlag)
139 : mCallbackFlag( callbackFlag )
145 *mCallbackFlag = true;
150 static void TestTextChangedCallback( TextEditor control )
152 tet_infoline(" TestTextChangedCallback");
154 gTextChangedCallBackCalled = true;
157 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
159 tet_infoline(" TestInputStyleChangedCallback");
161 gInputStyleChangedCallbackCalled = true;
162 gInputStyleMask = mask;
165 static void TestMaxLengthReachedCallback( TextEditor control )
167 tet_infoline(" TestMaxLengthReachedCallback");
169 gMaxCharactersCallBackCalled = true;
172 // Generate a KeyEvent to send to Core.
173 Integration::KeyEvent GenerateKey( const std::string& keyName,
174 const std::string& logicalKey,
175 const std::string& keyString,
178 unsigned long timeStamp,
179 const Integration::KeyEvent::State& keyState,
180 const std::string& compose = "",
181 const std::string& deviceName = DEFAULT_DEVICE_NAME,
182 const Device::Class::Type& deviceClass = Device::Class::NONE,
183 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
185 return Integration::KeyEvent( keyName,
198 Dali::Integration::Point GetPointDownInside( Vector2& pos )
200 Dali::Integration::Point point;
201 point.SetState( PointState::DOWN );
202 point.SetScreenPosition( pos );
206 Dali::Integration::Point GetPointUpInside( Vector2& pos )
208 Dali::Integration::Point point;
209 point.SetState( PointState::UP );
210 point.SetScreenPosition( pos );
214 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
216 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
218 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
220 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
222 Property::Value* valueSet = NULL;
223 if ( valueGet.first.type == Property::Key::INDEX )
225 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
229 // Get Key is a string so searching Set Map for a string key
230 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
233 if( NULL != valueSet )
235 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
237 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
240 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
242 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
245 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
247 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
250 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
252 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
255 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
257 Vector2 vector2Get = valueGet.second.Get<Vector2>();
258 Vector2 vector2Set = valueSet->Get<Vector2>();
259 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
262 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
264 Vector4 vector4Get = valueGet.second.Get<Vector4>();
265 Vector4 vector4Set = valueSet->Get<Vector4>();
266 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 );
272 if ( valueGet.first.type == Property::Key::INDEX )
274 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
278 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
288 class ScrollStateChangeCallback : public Dali::ConnectionTracker
291 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
292 : mStartedCalled( startedCalled ),
293 mFinishedCalled( finishedCalled )
297 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
299 if( type == TextEditor::Scroll::STARTED )
301 mStartedCalled = true;
303 else if( type == TextEditor::Scroll::FINISHED )
305 mFinishedCalled = true;
309 bool& mStartedCalled;
310 bool& mFinishedCalled;
315 int UtcDaliToolkitTextEditorConstructorP(void)
317 ToolkitTestApplication application;
318 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
319 TextEditor textEditor;
320 DALI_TEST_CHECK( !textEditor );
324 int UtcDaliToolkitTextEditorNewP(void)
326 ToolkitTestApplication application;
327 tet_infoline(" UtcDaliToolkitTextEditorNewP");
328 TextEditor textEditor = TextEditor::New();
329 DALI_TEST_CHECK( textEditor );
333 int UtcDaliToolkitTextEditorDownCastP(void)
335 ToolkitTestApplication application;
336 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
337 TextEditor textEditor1 = TextEditor::New();
338 BaseHandle object( textEditor1 );
340 TextEditor textEditor2 = TextEditor::DownCast( object );
341 DALI_TEST_CHECK( textEditor2 );
343 TextEditor textEditor3 = DownCast< TextEditor >( object );
344 DALI_TEST_CHECK( textEditor3 );
348 int UtcDaliToolkitTextEditorDownCastN(void)
350 ToolkitTestApplication application;
351 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
352 BaseHandle uninitializedObject;
353 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
354 DALI_TEST_CHECK( !textEditor1 );
356 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
357 DALI_TEST_CHECK( !textEditor2 );
361 int UtcDaliToolkitTextEditorCopyConstructorP(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
365 TextEditor textEditor = TextEditor::New();
366 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
368 TextEditor copy( textEditor );
369 DALI_TEST_CHECK( copy );
370 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
374 int UtcDaliTextEditorMoveConstructor(void)
376 ToolkitTestApplication application;
378 TextEditor textEditor = TextEditor::New();
379 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
380 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
382 TextEditor moved = std::move( textEditor );
383 DALI_TEST_CHECK( moved );
384 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
385 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
386 DALI_TEST_CHECK( !textEditor );
391 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
395 TextEditor textEditor = TextEditor::New();
396 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
398 TextEditor copy = textEditor;
399 DALI_TEST_CHECK( copy );
400 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
404 int UtcDaliTextEditorMoveAssignment(void)
406 ToolkitTestApplication application;
408 TextEditor textEditor = TextEditor::New();
409 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
410 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
413 moved = std::move( textEditor );
414 DALI_TEST_CHECK( moved );
415 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
416 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
417 DALI_TEST_CHECK( !textEditor );
422 int UtcDaliTextEditorNewP(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliToolkitTextEditorNewP");
426 TextEditor textEditor = TextEditor::New();
427 DALI_TEST_CHECK( textEditor );
431 // Positive test case for a method
432 int UtcDaliTextEditorGetPropertyP(void)
434 ToolkitTestApplication application;
435 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
436 TextEditor editor = TextEditor::New();
437 DALI_TEST_CHECK( editor );
439 // Check Property Indices are correct
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
500 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
503 Property::Map imageMap;
504 imageMap[mapKey] =mapValue;
506 editor.SetProperty( property , imageMap );
507 Property::Value propValue = editor.GetProperty( property );
508 Property::Map* resultMap = propValue.GetMap();
510 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
518 // Positive test case for a method
519 int UtcDaliTextEditorSetPropertyP(void)
521 ToolkitTestApplication application;
522 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
523 TextEditor editor = TextEditor::New();
524 DALI_TEST_CHECK( editor );
525 application.GetScene().Add( editor );
527 // Note - we can't check the defaults since the stylesheets are platform-specific
529 // Check the render backend property.
530 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
531 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
533 // Check text property.
534 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
535 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
537 // Check text's color property
538 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
539 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
541 // Check font properties.
542 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
543 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
545 Property::Map fontStyleMapSet;
546 Property::Map fontStyleMapGet;
547 Property::Value* slantValue = NULL;
549 fontStyleMapSet.Insert( "weight", "bold" );
550 fontStyleMapSet.Insert( "width", "condensed" );
551 fontStyleMapSet.Insert( "slant", "italic" );
553 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
554 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
555 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
556 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
558 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
559 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
562 fontStyleMapSet.Clear();
563 fontStyleMapSet.Insert( "weight", "normal" );
564 fontStyleMapSet.Insert( "slant", "oblique" );
565 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
566 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
567 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
568 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
570 fontStyleMapSet.Clear();
571 fontStyleMapSet.Insert( "slant", "roman" );
572 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
575 // Replace 'roman' for 'normal'.
576 slantValue = fontStyleMapGet.Find( "slant" );
577 if( NULL != slantValue )
579 if( "normal" == slantValue->Get<std::string>() )
581 fontStyleMapGet["slant"] = "roman";
584 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
585 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
587 fontStyleMapSet.Clear();
589 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
590 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
591 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
594 // Check that the Alignment properties can be correctly set
595 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
596 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
598 // Check scroll properties.
599 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
600 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
601 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
602 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
604 // Check cursor properties
605 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
606 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
607 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
608 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
610 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
611 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
612 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
613 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
614 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
615 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
616 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
617 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
619 // Check handle images
620 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
621 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
622 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
623 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
624 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
626 // Check handle images
627 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
628 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
629 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
630 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
631 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
632 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
634 // Check the highlight color
635 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
636 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
638 // Decoration bounding box
639 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
640 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
642 // Check the enable markup property.
643 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
644 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
645 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
647 // Check input color property.
648 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
649 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
651 // Check input font properties.
652 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
653 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
655 fontStyleMapSet.Clear();
656 fontStyleMapSet.Insert( "weight", "bold" );
657 fontStyleMapSet.Insert( "width", "condensed" );
658 fontStyleMapSet.Insert( "slant", "italic" );
660 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
661 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
662 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
663 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
665 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
666 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 // Reset input font style.
669 fontStyleMapSet.Clear();
670 fontStyleMapSet.Insert( "weight", "normal" );
671 fontStyleMapSet.Insert( "slant", "oblique" );
673 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
674 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
675 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
676 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
678 fontStyleMapSet.Clear();
679 fontStyleMapSet.Insert( "slant", "roman" );
681 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
682 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
684 // Replace 'roman' for 'normal'.
685 slantValue = fontStyleMapGet.Find( "slant" );
686 if( NULL != slantValue )
688 if( "normal" == slantValue->Get<std::string>() )
690 fontStyleMapGet["slant"] = "roman";
693 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
694 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
696 fontStyleMapSet.Clear();
698 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
699 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
700 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
701 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
703 // Check the line spacing property
704 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
705 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
706 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
708 // Check the input line spacing property
709 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
710 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
711 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713 // Check the underline property
715 Property::Map underlineMapSet;
716 Property::Map underlineMapGet;
718 underlineMapSet.Insert( "enable", true );
719 underlineMapSet.Insert( "color", Color::RED );
720 underlineMapSet.Insert( "height", 1 );
722 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
724 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
725 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
726 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
728 // Check the input underline property
729 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
730 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
732 // Check the shadow property
733 Property::Map shadowMapSet;
734 Property::Map shadowMapGet;
736 shadowMapSet.Insert( "color", Color::GREEN );
737 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
738 shadowMapSet.Insert( "blurRadius", 3.0f );
740 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
742 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
743 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
746 // Check the input shadow property
747 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
748 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
750 // Check the emboss property
751 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
752 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
754 // Check the input emboss property
755 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
756 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
758 // Check the outline property
760 // Test string type first
761 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
762 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
763 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
765 // Then test the property map type
766 Property::Map outlineMapSet;
767 Property::Map outlineMapGet;
769 outlineMapSet["color"] = Color::RED;
770 outlineMapSet["width"] = 2.0f;
772 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
774 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
775 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
776 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
778 // Check the input outline property
779 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
780 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
782 // Check the smooth scroll property
783 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
784 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
785 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
787 // Check the smooth scroll duration property
788 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
789 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
791 // Check the scroll bar property
792 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
793 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
794 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
796 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
797 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
798 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
799 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
801 // Check the pixel size of font
802 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
803 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
805 // Check placeholder text properties.
806 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
807 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
809 // Check placeholder text's color property.
810 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
811 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
813 // Check the enable selection property
814 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
815 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
817 // Check the placeholder property with pixel size
818 Property::Map placeholderPixelSizeMapSet;
819 Property::Map placeholderPixelSizeMapGet;
820 Property::Map placeholderFontstyleMap;
821 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
822 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
823 placeholderPixelSizeMapSet["color"] = Color::BLUE;
824 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
825 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
827 placeholderFontstyleMap.Insert( "weight", "bold" );
828 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
829 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
831 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
832 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
834 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
835 Property::Map placeholderConversionMap;
836 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
837 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
838 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
839 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
840 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
841 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
843 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
845 // Check the placeholder property with point size
846 Property::Map placeholderMapSet;
847 Property::Map placeholderMapGet;
848 placeholderMapSet["text"] = "Setting Placeholder Text";
849 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
850 placeholderMapSet["color"] = Color::RED;
851 placeholderMapSet["fontFamily"] = "Arial";
852 placeholderMapSet["pointSize"] = 12.0f;
853 // Check the placeholder font style property
854 placeholderFontstyleMap.Clear();
856 placeholderFontstyleMap.Insert( "weight", "bold" );
857 placeholderFontstyleMap.Insert( "width", "condensed" );
858 placeholderFontstyleMap.Insert( "slant", "italic" );
859 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
860 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
862 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
863 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
865 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
866 placeholderConversionMap.Clear();
867 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
868 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
869 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
870 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
871 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
872 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
873 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
876 placeholderFontstyleMap.Clear();
877 placeholderFontstyleMap.Insert( "weight", "normal" );
878 placeholderFontstyleMap.Insert( "slant", "oblique" );
879 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
880 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
882 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
883 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
884 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
885 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
887 placeholderFontstyleMap.Clear();
888 placeholderFontstyleMap.Insert( "slant", "roman" );
889 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
890 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
892 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
894 placeholderFontstyleMap.Clear();
895 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
897 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
898 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
899 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
900 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
901 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
903 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
904 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
906 application.SendNotification();
907 application.Render();
912 // Positive Atlas Text Renderer test
913 int utcDaliTextEditorAtlasRenderP(void)
915 ToolkitTestApplication application;
916 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
917 StyleManager styleManager = StyleManager::Get();
918 styleManager.ApplyDefaultTheme();
919 TextEditor editor = TextEditor::New();
920 DALI_TEST_CHECK( editor );
922 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
924 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
926 application.GetScene().Add( editor );
930 // Render some text with the shared atlas backend
931 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
932 application.SendNotification();
933 application.Render();
937 tet_result(TET_FAIL);
942 // Positive test for the textChanged signal.
943 int utcDaliTextEditorTextChangedP(void)
945 ToolkitTestApplication application;
946 tet_infoline(" utcDaliTextEditorTextChangedP");
947 TextEditor editor = TextEditor::New();
948 DALI_TEST_CHECK( editor );
950 application.GetScene().Add( editor );
952 // connect to the text changed signal.
953 ConnectionTracker* testTracker = new ConnectionTracker();
954 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
955 bool textChangedSignal = false;
956 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
958 gTextChangedCallBackCalled = false;
959 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
960 DALI_TEST_CHECK( gTextChangedCallBackCalled );
961 DALI_TEST_CHECK( textChangedSignal );
963 application.SendNotification();
965 editor.SetKeyInputFocus();
967 gTextChangedCallBackCalled = false;
968 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
969 DALI_TEST_CHECK( gTextChangedCallBackCalled );
974 int utcDaliTextEditorInputStyleChanged01(void)
976 // The text-editor emits signals when the input style changes. These changes of style are
977 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
978 // can't be emitted during the size negotiation as the callbacks may update the UI.
979 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
980 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
981 ToolkitTestApplication application;
982 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
986 char* pathNamePtr = get_current_dir_name();
987 const std::string pathName( pathNamePtr );
990 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
991 fontClient.SetDpi( 93u, 93u );
993 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
994 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
996 TextEditor editor = TextEditor::New();
997 DALI_TEST_CHECK( editor );
1000 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1001 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1002 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1004 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1005 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1007 // connect to the text changed signal.
1008 ConnectionTracker* testTracker = new ConnectionTracker();
1009 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1010 bool inputStyleChangedSignal = false;
1011 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1013 application.GetScene().Add( editor );
1015 // Render and notify
1016 application.SendNotification();
1017 application.Render();
1019 // Executes the idle callbacks added by the text control on the change of input style.
1020 application.RunIdles();
1022 gInputStyleChangedCallbackCalled = false;
1023 gInputStyleMask = TextEditor::InputStyle::NONE;
1024 inputStyleChangedSignal = false;
1026 // Create a tap event to touch the text editor.
1027 TestGenerateTap( application, 18.0f, 25.0f );
1029 // Render and notify
1030 application.SendNotification();
1031 application.Render();
1033 // Executes the idle callbacks added by the text control on the change of input style.
1034 application.RunIdles();
1036 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1037 if( gInputStyleChangedCallbackCalled )
1039 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1041 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1042 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1044 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1045 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1047 DALI_TEST_CHECK( inputStyleChangedSignal );
1049 gInputStyleChangedCallbackCalled = false;
1050 gInputStyleMask = TextEditor::InputStyle::NONE;
1051 inputStyleChangedSignal = false;
1053 // Create a tap event to touch the text editor.
1054 TestGenerateTap( application, 30.0f, 25.0f );
1056 // Render and notify
1057 application.SendNotification();
1058 application.Render();
1060 // Executes the idle callbacks added by the text control on the change of input style.
1061 application.RunIdles();
1063 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1064 DALI_TEST_CHECK( !inputStyleChangedSignal );
1066 gInputStyleChangedCallbackCalled = false;
1067 gInputStyleMask = TextEditor::InputStyle::NONE;
1068 inputStyleChangedSignal = false;
1070 // Create a tap event to touch the text editor.
1071 TestGenerateTap( application, 43.0f, 25.0f );
1073 // Render and notify
1074 application.SendNotification();
1075 application.Render();
1077 // Executes the idle callbacks added by the text control on the change of input style.
1078 application.RunIdles();
1080 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1081 if( gInputStyleChangedCallbackCalled )
1083 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1085 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1086 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1088 DALI_TEST_CHECK( inputStyleChangedSignal );
1090 gInputStyleChangedCallbackCalled = false;
1091 gInputStyleMask = TextEditor::InputStyle::NONE;
1092 inputStyleChangedSignal = false;
1094 // Create a tap event to touch the text editor.
1095 TestGenerateTap( application, 88.0f, 25.0f );
1097 // Render and notify
1098 application.SendNotification();
1099 application.Render();
1101 // Executes the idle callbacks added by the text control on the change of input style.
1102 application.RunIdles();
1104 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1105 if( gInputStyleChangedCallbackCalled )
1107 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1109 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1110 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1112 Property::Map fontStyleMapSet;
1113 Property::Map fontStyleMapGet;
1115 fontStyleMapSet.Insert( "weight", "bold" );
1117 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1118 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1119 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1121 DALI_TEST_CHECK( inputStyleChangedSignal );
1123 gInputStyleChangedCallbackCalled = false;
1124 gInputStyleMask = TextEditor::InputStyle::NONE;
1125 inputStyleChangedSignal = false;
1127 // Create a tap event to touch the text editor.
1128 TestGenerateTap( application, 115.0f, 25.0f );
1130 // Render and notify
1131 application.SendNotification();
1132 application.Render();
1134 // Executes the idle callbacks added by the text control on the change of input style.
1135 application.RunIdles();
1137 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1138 DALI_TEST_CHECK( !inputStyleChangedSignal );
1140 gInputStyleChangedCallbackCalled = false;
1141 gInputStyleMask = TextEditor::InputStyle::NONE;
1142 inputStyleChangedSignal = false;
1144 // Create a tap event to touch the text editor.
1145 TestGenerateTap( application, 164.0f, 25.0f );
1147 // Render and notify
1148 application.SendNotification();
1149 application.Render();
1151 // Executes the idle callbacks added by the text control on the change of input style.
1152 application.RunIdles();
1154 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1155 if( gInputStyleChangedCallbackCalled )
1157 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1159 Property::Map fontStyleMapSet;
1160 Property::Map fontStyleMapGet;
1162 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1163 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1164 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1166 DALI_TEST_CHECK( inputStyleChangedSignal );
1168 gInputStyleChangedCallbackCalled = false;
1169 gInputStyleMask = TextEditor::InputStyle::NONE;
1170 inputStyleChangedSignal = false;
1172 // Create a tap event to touch the text editor.
1173 TestGenerateTap( application, 191.0f, 25.0f );
1175 // Render and notify
1176 application.SendNotification();
1177 application.Render();
1179 // Executes the idle callbacks added by the text control on the change of input style.
1180 application.RunIdles();
1182 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1183 DALI_TEST_CHECK( !inputStyleChangedSignal );
1188 int utcDaliTextEditorInputStyleChanged02(void)
1190 // The text-editor emits signals when the input style changes. These changes of style are
1191 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1192 // can't be emitted during the size negotiation as the callbacks may update the UI.
1193 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1194 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1195 ToolkitTestApplication application;
1196 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1200 char* pathNamePtr = get_current_dir_name();
1201 const std::string pathName( pathNamePtr );
1202 free( pathNamePtr );
1204 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1205 fontClient.SetDpi( 93u, 93u );
1207 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1208 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1210 TextEditor editor = TextEditor::New();
1211 DALI_TEST_CHECK( editor );
1214 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1215 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1216 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1218 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1219 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>" );
1221 // connect to the text changed signal.
1222 ConnectionTracker* testTracker = new ConnectionTracker();
1223 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1224 bool inputStyleChangedSignal = false;
1225 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1227 application.GetScene().Add( editor );
1229 // Render and notify
1230 application.SendNotification();
1231 application.Render();
1233 // Executes the idle callbacks added by the text control on the change of input style.
1234 application.RunIdles();
1236 gInputStyleChangedCallbackCalled = false;
1237 gInputStyleMask = TextEditor::InputStyle::NONE;
1238 inputStyleChangedSignal = false;
1240 // Create a tap event to touch the text editor.
1241 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1242 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1244 // Render and notify
1245 application.SendNotification();
1246 application.Render();
1248 // Executes the idle callbacks added by the text control on the change of input style.
1249 application.RunIdles();
1251 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1252 if( gInputStyleChangedCallbackCalled )
1254 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1255 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1256 TextEditor::InputStyle::POINT_SIZE |
1257 TextEditor::InputStyle::COLOR ),
1260 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1261 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1263 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1264 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1266 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1267 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1269 DALI_TEST_CHECK( inputStyleChangedSignal );
1271 gInputStyleChangedCallbackCalled = false;
1272 gInputStyleMask = TextEditor::InputStyle::NONE;
1273 inputStyleChangedSignal = false;
1275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1277 // Render and notify
1278 application.SendNotification();
1279 application.Render();
1281 // Executes the idle callbacks added by the text control on the change of input style.
1282 application.RunIdles();
1284 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1285 if( gInputStyleChangedCallbackCalled )
1287 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1288 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1291 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1292 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1294 DALI_TEST_CHECK( inputStyleChangedSignal );
1296 gInputStyleChangedCallbackCalled = false;
1297 gInputStyleMask = TextEditor::InputStyle::NONE;
1298 inputStyleChangedSignal = false;
1300 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1302 // Render and notify
1303 application.SendNotification();
1304 application.Render();
1306 // Executes the idle callbacks added by the text control on the change of input style.
1307 application.RunIdles();
1309 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1310 DALI_TEST_CHECK( !inputStyleChangedSignal );
1312 gInputStyleChangedCallbackCalled = false;
1313 gInputStyleMask = TextEditor::InputStyle::NONE;
1314 inputStyleChangedSignal = false;
1316 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1318 // Render and notify
1319 application.SendNotification();
1320 application.Render();
1322 // Executes the idle callbacks added by the text control on the change of input style.
1323 application.RunIdles();
1325 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1326 if( gInputStyleChangedCallbackCalled )
1328 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1329 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1332 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1333 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1335 DALI_TEST_CHECK( inputStyleChangedSignal );
1337 gInputStyleChangedCallbackCalled = false;
1338 gInputStyleMask = TextEditor::InputStyle::NONE;
1339 inputStyleChangedSignal = false;
1341 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1343 Property::Map fontStyleMapSet;
1344 fontStyleMapSet.Insert( "weight", "thin" );
1345 fontStyleMapSet.Insert( "width", "condensed" );
1346 fontStyleMapSet.Insert( "slant", "italic" );
1348 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1349 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1350 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1352 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1353 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1354 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1355 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1357 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1359 // Render and notify
1360 application.SendNotification();
1361 application.Render();
1363 // Executes the idle callbacks added by the text control on the change of input style.
1364 application.RunIdles();
1366 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1367 DALI_TEST_CHECK( !inputStyleChangedSignal );
1369 // Create a tap event to touch the text editor.
1370 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1372 // Render and notify
1373 application.SendNotification();
1374 application.Render();
1376 // Executes the idle callbacks added by the text control on the change of input style.
1377 application.RunIdles();
1379 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1380 if( gInputStyleChangedCallbackCalled )
1382 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1383 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1384 TextEditor::InputStyle::POINT_SIZE |
1385 TextEditor::InputStyle::FONT_STYLE |
1386 TextEditor::InputStyle::LINE_SPACING |
1387 TextEditor::InputStyle::UNDERLINE |
1388 TextEditor::InputStyle::SHADOW |
1389 TextEditor::InputStyle::EMBOSS |
1390 TextEditor::InputStyle::OUTLINE ),
1393 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1394 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1396 DALI_TEST_CHECK( inputStyleChangedSignal );
1398 gInputStyleChangedCallbackCalled = false;
1399 gInputStyleMask = TextEditor::InputStyle::NONE;
1400 inputStyleChangedSignal = false;
1402 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1404 fontStyleMapSet.Clear();
1405 fontStyleMapSet.Insert( "weight", "black" );
1406 fontStyleMapSet.Insert( "width", "expanded" );
1407 fontStyleMapSet.Insert( "slant", "oblique" );
1409 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1411 // Create a tap event to touch the text editor.
1412 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1414 // Render and notify
1415 application.SendNotification();
1416 application.Render();
1418 // Executes the idle callbacks added by the text control on the change of input style.
1419 application.RunIdles();
1421 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1422 if( gInputStyleChangedCallbackCalled )
1424 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1425 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1426 TextEditor::InputStyle::POINT_SIZE |
1427 TextEditor::InputStyle::FONT_STYLE ),
1430 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1431 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1433 DALI_TEST_CHECK( inputStyleChangedSignal );
1438 int utcDaliTextEditorEvent01(void)
1440 ToolkitTestApplication application;
1441 tet_infoline(" utcDaliTextEditorEvent01");
1443 // Creates a tap event. After creating a tap event the text editor should
1444 // have the focus and add text with key events should be possible.
1446 TextEditor editor = TextEditor::New();
1447 DALI_TEST_CHECK( editor );
1449 application.GetScene().Add( editor );
1451 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1452 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1453 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1455 // Avoid a crash when core load gl resources.
1456 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 // Add a key event but as the text editor has not the focus it should do nothing.
1463 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1465 // Render and notify
1466 application.SendNotification();
1467 application.Render();
1469 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1471 // Create a tap event to touch the text editor.
1472 TestGenerateTap( application, 150.0f, 25.0f );
1474 // Render and notify
1475 application.SendNotification();
1476 application.Render();
1478 // Now the text editor has the focus, so it can handle the key events.
1479 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1480 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1488 // Create a second text editor and send key events to it.
1489 TextEditor editor2 = TextEditor::New();
1491 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1492 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1493 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1494 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1496 application.GetScene().Add( editor2 );
1498 // Render and notify
1499 application.SendNotification();
1500 application.Render();
1502 // Create a tap event on the second text editor.
1503 TestGenerateTap( application, 150.0f, 125.0f );
1505 // Render and notify
1506 application.SendNotification();
1507 application.Render();
1509 // The second text editor has the focus. It should handle the key events.
1510 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1511 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1513 // Render and notify
1514 application.SendNotification();
1515 application.Render();
1517 // Check the text has been added to the second text editor.
1518 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1523 int utcDaliTextEditorEvent02(void)
1525 ToolkitTestApplication application;
1526 tet_infoline(" utcDaliTextEditorEvent02");
1528 // Checks if the right number of actors are created.
1530 TextEditor editor = TextEditor::New();
1531 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1532 DALI_TEST_CHECK( editor );
1534 application.GetScene().Add( editor );
1536 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1537 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1538 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1540 // Avoid a crash when core load gl resources.
1541 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1543 // Render and notify
1544 application.SendNotification();
1545 application.Render();
1547 // Check there are the expected number of children (the stencil).
1548 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1550 Actor stencil = editor.GetChildAt( 0u );
1552 // Create a tap event to touch the text editor.
1553 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 Actor layer = editor.GetChildAt( 1u );
1560 DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
1562 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1563 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1565 // Now the text editor has the focus, so it can handle the key events.
1566 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // Checks the cursor and the renderer have been created.
1574 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1575 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1577 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1578 DALI_TEST_CHECK( cursor );
1580 // The stencil actor has a container with all the actors which contain the text renderers.
1581 Actor container = stencil.GetChildAt( 0u );
1582 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1584 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1585 DALI_TEST_CHECK( renderer );
1588 // Move the cursor and check the position changes.
1589 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1591 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1592 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1594 // Render and notify
1595 application.SendNotification();
1596 application.Render();
1598 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1600 DALI_TEST_CHECK( position2.x < position1.x );
1602 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1611 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1613 // Send some taps and check the cursor positions.
1615 // Try to tap at the beginning.
1616 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1618 // Render and notify
1619 application.SendNotification();
1620 application.Render();
1622 // Cursor position should be the same than position1.
1623 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1625 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1627 // Tap away from the start position.
1628 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1636 DALI_TEST_CHECK( position5.x > position4.x );
1638 // Remove all the text.
1639 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1640 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1641 editor.SetProperty( TextEditor::Property::TEXT, "" );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Cursor position should be the same than position2.
1648 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1650 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1652 // Should not be a renderer.
1653 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1658 int utcDaliTextEditorEvent03(void)
1660 ToolkitTestApplication application;
1661 tet_infoline(" utcDaliTextEditorEvent03");
1663 // Checks if the highlight actor is created.
1665 TextEditor editor = TextEditor::New();
1666 DALI_TEST_CHECK( editor );
1668 application.GetScene().Add( editor );
1670 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1671 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1672 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1673 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1674 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1676 // Avoid a crash when core load gl resources.
1677 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Send some taps and check text controller with clipboard window
1684 Dali::Clipboard clipboard = Clipboard::Get();
1685 clipboard.ShowClipboard();
1686 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1687 clipboard.HideClipboard();
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1693 // Tap first to get the focus.
1694 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 // Double tap to select a word.
1701 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 // The stencil actor should have two actors: the renderer and the highlight actor.
1708 Actor stencil = editor.GetChildAt( 0u );
1710 // Highlight needs to be drawn before text, so should come first in child order
1711 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1712 DALI_TEST_CHECK( highlight );
1714 // The stencil actor has a container with all the actors which contain the text renderers.
1715 Actor container = stencil.GetChildAt( 1u );
1716 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1718 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1719 DALI_TEST_CHECK( renderer );
1722 // Double tap out of bounds
1723 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1724 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 // The stencil actor should have one actors: the renderer actor.
1731 stencil = editor.GetChildAt( 0u );
1733 // The stencil actor has a container with all the actors which contain the text renderers.
1734 container = stencil.GetChildAt( 0u );
1735 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1737 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1738 DALI_TEST_CHECK( renderer );
1742 TestGenerateLongPress(application, 1.0f, 25.0f);
1744 // Render and notify
1745 application.SendNotification();
1746 application.Render();
1751 int utcDaliTextEditorEvent04(void)
1753 ToolkitTestApplication application;
1754 tet_infoline(" utcDaliTextEditorEvent04");
1756 // Checks if the highlight actor is created.
1758 TextEditor editor = TextEditor::New();
1759 DALI_TEST_CHECK( editor );
1761 application.GetScene().Add( editor );
1763 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1764 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1765 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1766 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1767 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1769 // Avoid a crash when core load gl resources.
1770 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1772 // Render and notify
1773 application.SendNotification();
1774 application.Render();
1776 // Tap on the text editor
1777 TestGenerateTap( application, 3.0f, 25.0f );
1779 // Render and notify
1780 application.SendNotification();
1781 application.Render();
1783 // Move at the end of the text.
1784 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1785 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 for( unsigned int index = 0u; index < 10u; ++index )
1793 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1794 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1802 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1804 // Render and notify
1805 application.SendNotification();
1806 application.Render();
1808 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1810 // Add some key events
1811 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1812 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1818 for( unsigned int index = 0u; index < 10u; ++index )
1820 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1823 // Render and notify
1824 application.SendNotification();
1825 application.Render();
1829 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1831 // Render and notify
1832 application.SendNotification();
1833 application.Render();
1835 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1840 int utcDaliTextEditorEvent05(void)
1842 ToolkitTestApplication application;
1843 tet_infoline(" utcDaliTextEditorEvent05");
1845 // Checks if the highlight actor is created.
1847 TextEditor editor = TextEditor::New();
1848 DALI_TEST_CHECK( editor );
1850 application.GetScene().Add( editor );
1852 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1853 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1854 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1855 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1856 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1857 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1858 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1859 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1860 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1861 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1863 // Avoid a crash when core load gl resources.
1864 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1870 // Tap on the text editor
1871 TestGenerateTap( application, 3.0f, 25.0f );
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1877 // Move at the end of the text.
1878 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1879 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 for( unsigned int index = 0u; index < 10u; ++index )
1888 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1890 // Render and notify
1891 application.SendNotification();
1892 application.Render();
1894 // Modify duration after scroll is enabled
1895 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1897 // Continuous scroll left to increase coverage
1898 for( unsigned int index = 0u; index < 10u; ++index )
1900 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1906 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1907 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1908 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1909 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1910 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1912 // Press Escape to increase coverage
1913 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1914 application.SendNotification();
1915 application.Render();
1917 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1922 int utcDaliTextEditorEvent06(void)
1924 ToolkitTestApplication application;
1925 tet_infoline(" utcDaliTextEditorEvent06");
1927 // Checks if the highlight actor is created.
1929 TextEditor editor = TextEditor::New();
1930 DALI_TEST_CHECK( editor );
1932 application.GetScene().Add( editor );
1934 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1935 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1936 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1937 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1938 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1940 // Avoid a crash when core load gl resources.
1941 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1947 // Tap on the text editor
1948 TestGenerateTap( application, 3.0f, 25.0f );
1950 // Render and notify
1951 application.SendNotification();
1952 application.Render();
1954 // Move to seconds line of the text.
1955 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1957 // Render and notify
1958 application.SendNotification();
1959 application.Render();
1961 float layoutHeight = editor.GetHeightForWidth( 100.f );
1964 // Add another script characters ( glyph height is defferent )
1965 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1966 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1968 // Delete characters
1969 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1970 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1972 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1978 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1981 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1982 application.SendNotification();
1983 application.Render();
1985 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1986 application.SendNotification();
1987 application.Render();
1989 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1990 application.SendNotification();
1991 application.Render();
1993 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 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::DevelKey::DALI_KEY_DELETE, 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::DevelKey::DALI_KEY_CONTROL_LEFT, 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::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2006 application.SendNotification();
2007 application.Render();
2012 int utcDaliTextEditorEvent07(void)
2014 ToolkitTestApplication application;
2015 tet_infoline(" utcDaliTextEditorEvent07");
2017 // Checks if the highlight actor is created.
2019 TextEditor editor = TextEditor::New();
2020 DALI_TEST_CHECK( editor );
2022 application.GetScene().Add( editor );
2024 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2025 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2026 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2027 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2028 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2030 // Avoid a crash when core load gl resources.
2031 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2033 // Render and notify
2034 application.SendNotification();
2035 application.Render();
2037 // Tap on the text editor
2038 TestGenerateTap( application, 3.0f, 25.0f );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2044 // Move to second line of the text.
2045 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2047 // Render and notify
2048 application.SendNotification();
2049 application.Render();
2051 // Select some text in the right of the current cursor position
2052 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2053 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2057 // Render and notify
2058 application.SendNotification();
2059 application.Render();
2061 // Cut the selected text
2062 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2063 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 ) );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2069 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2071 // Select some text in the left of the current cursor position
2072 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2073 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2074 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2075 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2077 // Render and notify
2078 application.SendNotification();
2079 application.Render();
2081 // Copy the selected text
2082 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2083 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 ) );
2085 // Render and notify
2086 application.SendNotification();
2087 application.Render();
2089 // Move the cursor to the third line
2090 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2097 // Paste the selected text at the current cursor position
2098 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 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 ) );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2108 // Disable Shift Selection
2109 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2111 // Test to select some text in the right of the current cursor position
2112 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2113 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2114 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2115 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2121 // Cut the selected text
2122 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2123 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 ) );
2125 // Render and notify
2126 application.SendNotification();
2127 application.Render();
2129 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2130 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2132 // Test to select some text in the left of the current cursor position
2133 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2135 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2136 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 // Copy the selected text
2143 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2144 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 ) );
2146 // Render and notify
2147 application.SendNotification();
2148 application.Render();
2150 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2151 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2156 int utcDaliTextEditorEvent08(void)
2158 ToolkitTestApplication application;
2159 tet_infoline(" utcDaliTextEditorEvent08");
2161 // Checks if the highlight actor is released correctly.
2163 TextEditor editor = TextEditor::New();
2164 DALI_TEST_CHECK( editor );
2166 application.GetScene().Add( editor );
2168 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2169 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2170 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2171 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2172 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2174 // Avoid a crash when core load gl resources.
2175 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 // Tap on the text editor
2182 TestGenerateTap( application, 3.0f, 25.0f );
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2188 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2189 // Test to select some text in the left of the current cursor position
2190 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2195 // Render and notify
2196 application.SendNotification();
2197 application.Render();
2199 // Test to the left selection handle position and the right selection handle position
2200 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2201 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // Test to select full text in the left of the current cursor position
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2214 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 // Render and notify
2218 application.SendNotification();
2219 application.Render();
2221 // Test to release the current full text selection
2222 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2223 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2225 // Render and notify
2226 application.SendNotification();
2227 application.Render();
2229 // Test to move the current cursor position correctly
2230 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2237 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 // Render and notify
2240 application.SendNotification();
2241 application.Render();
2243 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2245 // Test to select some text in the right of the current cursor position
2246 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2247 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2248 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2250 // Render and notify
2251 application.SendNotification();
2252 application.Render();
2254 // Test the cursor position with right arrow key
2255 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2257 // Render and notify
2258 application.SendNotification();
2259 application.Render();
2262 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 // Render and notify
2265 application.SendNotification();
2266 application.Render();
2268 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2270 // Test to select some text in the left of the current cursor position
2271 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2274 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 // Render and notify
2278 application.SendNotification();
2279 application.Render();
2281 // Test the cursor position with left arrow key
2282 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284 // Render and notify
2285 application.SendNotification();
2286 application.Render();
2289 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 // Render and notify
2292 application.SendNotification();
2293 application.Render();
2295 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2297 // Test to select some text in the right of the current cursor position
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2300 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 // Render and notify
2304 application.SendNotification();
2305 application.Render();
2307 // Test the cursor position with left arrow key
2308 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2310 // Render and notify
2311 application.SendNotification();
2312 application.Render();
2315 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2323 // Test to select some text in the left of the current cursor position
2324 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2326 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 // Test the cursor position with right arrow key
2334 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2341 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343 // Render and notify
2344 application.SendNotification();
2345 application.Render();
2347 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2352 int utcDaliTextEditorHandles(void)
2354 ToolkitTestApplication application;
2355 tet_infoline(" utcDaliTextEditorHandles");
2357 TextEditor editor = TextEditor::New();
2358 DALI_TEST_CHECK( editor );
2360 application.GetScene().Add( editor );
2362 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2363 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2364 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2365 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2367 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2368 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2369 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2370 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2372 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2373 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2374 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2376 // Avoid a crash when core load gl resources.
2377 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2379 // Render and notify
2380 application.SendNotification();
2381 application.Render();
2383 // Tap first to get the focus.
2384 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // Tap to create the grab handle.
2391 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Get the active layer where the text's decoration is added.
2398 Actor activeLayer = editor.GetChildAt( 1u );
2400 // Get the handle's actor.
2401 Actor handle = activeLayer.GetChildAt( 1u );
2402 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // Touch the grab handle to set it as pressed.
2409 Vector2 touchPos( 10.0f, 50.0f );
2410 Dali::Integration::TouchEvent event;
2411 event = Dali::Integration::TouchEvent();
2412 event.AddPoint( GetPointDownInside( touchPos ) );
2413 application.ProcessEvent( event );
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2419 // Release the grab handle.
2420 event = Dali::Integration::TouchEvent();
2421 event.AddPoint( GetPointUpInside( touchPos ) );
2422 application.ProcessEvent( event );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2428 // Tap first to get the focus.
2429 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2431 // Render and notify
2432 application.SendNotification();
2433 application.Render();
2435 // Double tap to select a word and create the selection handles.
2436 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2438 // Render and notify
2439 application.SendNotification();
2440 application.Render();
2442 touchPos = Vector2( 10.0f, 50.0f );
2444 // Touch the left selection handle to set it as pressed.
2445 event = Dali::Integration::TouchEvent();
2446 event.AddPoint( GetPointDownInside( touchPos ) );
2447 application.ProcessEvent( event );
2449 // Render and notify
2450 application.SendNotification();
2451 application.Render();
2453 // Release the left selection handle.
2454 event = Dali::Integration::TouchEvent();
2455 event.AddPoint( GetPointUpInside( touchPos ) );
2456 application.ProcessEvent( event );
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2465 int utcDaliTextEditorUnderPropertyStringP(void)
2467 ToolkitTestApplication application;
2468 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2469 TextEditor editor = TextEditor::New();
2470 DALI_TEST_CHECK( editor );
2472 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2474 application.GetScene().Add( editor );
2476 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2477 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2479 tet_infoline("Set underline settings with a map");
2480 // Check the input underline property
2481 Property::Map underlineMapSet;
2482 Property::Map underlineMapGet;
2483 underlineMapSet.Insert( "enable", true );
2484 underlineMapSet.Insert( "color", Color::BLUE );
2485 underlineMapSet.Insert( "height", 2 );
2487 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2488 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2489 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2490 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2492 tet_infoline("Set underline settings with a string");
2493 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2494 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2497 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2499 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2500 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2501 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2502 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2504 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2509 int utcDaliTextEditorShadowPropertyStringP(void)
2511 ToolkitTestApplication application;
2512 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2514 TextEditor editor = TextEditor::New();
2516 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2518 application.GetScene().Add( editor );
2520 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2522 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2526 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2531 int utcDaliTextEditorFontStylePropertyStringP(void)
2533 ToolkitTestApplication application;
2534 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2536 TextEditor editor = TextEditor::New();
2538 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2540 application.GetScene().Add( editor );
2542 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2544 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2548 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2553 int utcDaliTextEditorGetPropertyLinecountP(void)
2555 ToolkitTestApplication application;
2557 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2561 TextEditor editor = TextEditor::New();
2562 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2563 editor.SetProperty( TextEditor::Property::TEXT,
2564 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2566 application.GetScene().Add( editor );
2568 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2569 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2570 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2572 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2573 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2574 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2579 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2582 ToolkitTestApplication application;
2583 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2585 TextEditor editor = TextEditor::New();
2586 DALI_TEST_CHECK( editor );
2588 application.GetScene().Add( editor );
2590 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2591 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2592 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2593 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2594 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2595 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2597 bool startedCalled = false;
2598 bool finishedCalled = false;
2600 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2601 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2603 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2605 // Render and notify
2606 application.SendNotification();
2607 application.Render();
2609 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2610 application.SendNotification();
2611 application.Render(6000);
2613 application.SendNotification();
2614 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2615 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2620 int UtcDaliToolkitTextEditorTextWrapMode(void)
2622 ToolkitTestApplication application;
2623 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2627 TextEditor editor = TextEditor::New();
2628 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2629 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2631 application.GetScene().Add( editor );
2633 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2634 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2636 application.SendNotification();
2637 application.Render();
2639 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2640 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2642 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2643 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2645 application.SendNotification();
2646 application.Render();
2648 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2649 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2651 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2652 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2654 application.SendNotification();
2655 application.Render();
2657 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2658 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2660 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2661 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2663 application.SendNotification();
2664 application.Render();
2666 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2667 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2672 int UtcDaliTextEditorSetPaddingProperty(void)
2674 ToolkitTestApplication application;
2675 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2677 TextEditor editor = TextEditor::New();
2678 DALI_TEST_CHECK( editor );
2679 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2680 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2681 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2682 application.GetScene().Add( editor );
2684 application.SendNotification();
2685 application.Render();
2687 Vector3 originalSize = editor.GetNaturalSize();
2689 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2691 application.SendNotification();
2692 application.Render();
2694 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2696 Vector3 paddingAddedSize = editor.GetNaturalSize();
2698 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2700 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2705 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2707 ToolkitTestApplication application;
2708 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2710 TextEditor editor = TextEditor::New();
2711 DALI_TEST_CHECK( editor );
2712 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2713 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2714 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2715 application.GetScene().Add( editor );
2717 application.SendNotification();
2718 application.Render();
2720 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2721 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2723 // Check the enable shift selection property
2724 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2725 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2727 application.SendNotification();
2728 application.Render();
2733 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2735 ToolkitTestApplication application;
2736 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2738 TextEditor editor = TextEditor::New();
2739 DALI_TEST_CHECK( editor );
2740 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2741 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2742 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2743 application.GetScene().Add( editor );
2745 application.SendNotification();
2746 application.Render();
2748 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2749 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2751 // Check the enable grab handle property
2752 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2753 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2755 application.SendNotification();
2756 application.Render();
2761 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2763 ToolkitTestApplication application;
2764 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2766 TextEditor editor = TextEditor::New();
2767 DALI_TEST_CHECK( editor );
2768 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2769 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2770 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2771 application.GetScene().Add( editor );
2773 application.SendNotification();
2774 application.Render();
2776 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2777 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2779 // Check the enable match system language direction property
2780 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2781 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2783 application.SendNotification();
2784 application.Render();
2789 int UtcDaliTextEditorGetInputMethodContext(void)
2791 ToolkitTestApplication application;
2792 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2794 TextEditor editor = TextEditor::New();
2795 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2800 int utcDaliTextEditorMaxCharactersReached(void)
2802 ToolkitTestApplication application;
2803 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2805 TextEditor editor = TextEditor::New();
2806 DALI_TEST_CHECK( editor );
2808 application.GetScene().Add( editor );
2810 const int maxNumberOfCharacters = 1;
2811 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2812 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2814 editor.SetKeyInputFocus();
2816 // connect to the text changed signal.
2817 ConnectionTracker* testTracker = new ConnectionTracker();
2818 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2819 bool maxLengthReachedSignal = false;
2820 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2822 gMaxCharactersCallBackCalled = false;
2824 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2825 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2827 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2828 DALI_TEST_CHECK( maxLengthReachedSignal );