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";
127 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
129 static bool gTextChangedCallBackCalled;
130 static bool gInputStyleChangedCallbackCalled;
131 static bool gMaxCharactersCallBackCalled;
132 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
134 struct CallbackFunctor
136 CallbackFunctor(bool* callbackFlag)
137 : mCallbackFlag( callbackFlag )
143 *mCallbackFlag = true;
148 static void TestTextChangedCallback( TextEditor control )
150 tet_infoline(" TestTextChangedCallback");
152 gTextChangedCallBackCalled = true;
155 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
157 tet_infoline(" TestInputStyleChangedCallback");
159 gInputStyleChangedCallbackCalled = true;
160 gInputStyleMask = mask;
163 static void TestMaxLengthReachedCallback( TextEditor control )
165 tet_infoline(" TestMaxLengthReachedCallback");
167 gMaxCharactersCallBackCalled = true;
170 // Generate a KeyEvent to send to Core.
171 Integration::KeyEvent GenerateKey( const std::string& keyName,
172 const std::string& logicalKey,
173 const std::string& keyString,
176 unsigned long timeStamp,
177 const Integration::KeyEvent::State& keyState,
178 const std::string& compose = "",
179 const std::string& deviceName = DEFAULT_DEVICE_NAME,
180 const Device::Class::Type& deviceClass = Device::Class::NONE,
181 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
183 return Integration::KeyEvent( keyName,
196 Dali::Integration::Point GetPointDownInside( Vector2& pos )
198 Dali::Integration::Point point;
199 point.SetState( PointState::DOWN );
200 point.SetScreenPosition( pos );
204 Dali::Integration::Point GetPointUpInside( Vector2& pos )
206 Dali::Integration::Point point;
207 point.SetState( PointState::UP );
208 point.SetScreenPosition( pos );
212 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
214 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
216 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
218 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
220 Property::Value* valueSet = NULL;
221 if ( valueGet.first.type == Property::Key::INDEX )
223 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
227 // Get Key is a string so searching Set Map for a string key
228 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
231 if( NULL != valueSet )
233 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
235 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
238 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
240 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
243 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
245 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
248 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
250 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
253 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
255 Vector2 vector2Get = valueGet.second.Get<Vector2>();
256 Vector2 vector2Set = valueSet->Get<Vector2>();
257 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
260 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
262 Vector4 vector4Get = valueGet.second.Get<Vector4>();
263 Vector4 vector4Set = valueSet->Get<Vector4>();
264 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 );
270 if ( valueGet.first.type == Property::Key::INDEX )
272 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
276 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
286 class ScrollStateChangeCallback : public Dali::ConnectionTracker
289 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
290 : mStartedCalled( startedCalled ),
291 mFinishedCalled( finishedCalled )
295 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
297 if( type == TextEditor::Scroll::STARTED )
299 mStartedCalled = true;
301 else if( type == TextEditor::Scroll::FINISHED )
303 mFinishedCalled = true;
307 bool& mStartedCalled;
308 bool& mFinishedCalled;
313 int UtcDaliToolkitTextEditorConstructorP(void)
315 ToolkitTestApplication application;
316 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
317 TextEditor textEditor;
318 DALI_TEST_CHECK( !textEditor );
322 int UtcDaliToolkitTextEditorNewP(void)
324 ToolkitTestApplication application;
325 tet_infoline(" UtcDaliToolkitTextEditorNewP");
326 TextEditor textEditor = TextEditor::New();
327 DALI_TEST_CHECK( textEditor );
331 int UtcDaliToolkitTextEditorDownCastP(void)
333 ToolkitTestApplication application;
334 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
335 TextEditor textEditor1 = TextEditor::New();
336 BaseHandle object( textEditor1 );
338 TextEditor textEditor2 = TextEditor::DownCast( object );
339 DALI_TEST_CHECK( textEditor2 );
341 TextEditor textEditor3 = DownCast< TextEditor >( object );
342 DALI_TEST_CHECK( textEditor3 );
346 int UtcDaliToolkitTextEditorDownCastN(void)
348 ToolkitTestApplication application;
349 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
350 BaseHandle uninitializedObject;
351 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
352 DALI_TEST_CHECK( !textEditor1 );
354 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
355 DALI_TEST_CHECK( !textEditor2 );
359 int UtcDaliToolkitTextEditorCopyConstructorP(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
363 TextEditor textEditor = TextEditor::New();
364 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
366 TextEditor copy( textEditor );
367 DALI_TEST_CHECK( copy );
368 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
372 int UtcDaliTextEditorMoveConstructor(void)
374 ToolkitTestApplication application;
376 TextEditor textEditor = TextEditor::New();
377 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
378 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
380 TextEditor moved = std::move( textEditor );
381 DALI_TEST_CHECK( moved );
382 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
383 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
384 DALI_TEST_CHECK( !textEditor );
389 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
393 TextEditor textEditor = TextEditor::New();
394 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
396 TextEditor copy = textEditor;
397 DALI_TEST_CHECK( copy );
398 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
402 int UtcDaliTextEditorMoveAssignment(void)
404 ToolkitTestApplication application;
406 TextEditor textEditor = TextEditor::New();
407 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
408 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
411 moved = std::move( textEditor );
412 DALI_TEST_CHECK( moved );
413 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
414 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
415 DALI_TEST_CHECK( !textEditor );
420 int UtcDaliTextEditorNewP(void)
422 ToolkitTestApplication application;
423 tet_infoline(" UtcDaliToolkitTextEditorNewP");
424 TextEditor textEditor = TextEditor::New();
425 DALI_TEST_CHECK( textEditor );
429 // Positive test case for a method
430 int UtcDaliTextEditorGetPropertyP(void)
432 ToolkitTestApplication application;
433 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
434 TextEditor editor = TextEditor::New();
435 DALI_TEST_CHECK( editor );
437 // Check Property Indices are correct
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
498 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
501 Property::Map imageMap;
502 imageMap[mapKey] =mapValue;
504 editor.SetProperty( property , imageMap );
505 Property::Value propValue = editor.GetProperty( property );
506 Property::Map* resultMap = propValue.GetMap();
508 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
516 // Positive test case for a method
517 int UtcDaliTextEditorSetPropertyP(void)
519 ToolkitTestApplication application;
520 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
521 TextEditor editor = TextEditor::New();
522 DALI_TEST_CHECK( editor );
523 application.GetScene().Add( editor );
525 // Note - we can't check the defaults since the stylesheets are platform-specific
527 // Check the render backend property.
528 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
529 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
531 // Check text property.
532 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
533 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
535 // Check text's color property
536 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
537 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
539 // Check font properties.
540 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
541 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
543 Property::Map fontStyleMapSet;
544 Property::Map fontStyleMapGet;
545 Property::Value* slantValue = NULL;
547 fontStyleMapSet.Insert( "weight", "bold" );
548 fontStyleMapSet.Insert( "width", "condensed" );
549 fontStyleMapSet.Insert( "slant", "italic" );
551 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
552 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
553 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
554 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
556 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
557 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
560 fontStyleMapSet.Clear();
561 fontStyleMapSet.Insert( "weight", "normal" );
562 fontStyleMapSet.Insert( "slant", "oblique" );
563 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
564 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
565 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
566 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
568 fontStyleMapSet.Clear();
569 fontStyleMapSet.Insert( "slant", "roman" );
570 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
571 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
573 // Replace 'roman' for 'normal'.
574 slantValue = fontStyleMapGet.Find( "slant" );
575 if( NULL != slantValue )
577 if( "normal" == slantValue->Get<std::string>() )
579 fontStyleMapGet["slant"] = "roman";
582 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
583 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
585 fontStyleMapSet.Clear();
587 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
588 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
589 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
590 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
592 // Check that the Alignment properties can be correctly set
593 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
594 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
596 // Check scroll properties.
597 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
598 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
599 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
600 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
602 // Check cursor properties
603 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
604 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
605 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
606 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
608 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
609 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
610 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
611 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
612 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
613 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
614 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
615 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
617 // Check handle images
618 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
619 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
620 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
621 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
622 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
624 // Check handle images
625 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
626 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
627 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
628 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
629 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
630 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
632 // Check the highlight color
633 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
634 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
636 // Decoration bounding box
637 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
638 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
640 // Check the enable markup property.
641 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
642 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
643 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
645 // Check input color property.
646 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
647 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
649 // Check input font properties.
650 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
651 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
653 fontStyleMapSet.Clear();
654 fontStyleMapSet.Insert( "weight", "bold" );
655 fontStyleMapSet.Insert( "width", "condensed" );
656 fontStyleMapSet.Insert( "slant", "italic" );
658 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
659 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
660 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
661 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
663 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
664 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
666 // Reset input font style.
667 fontStyleMapSet.Clear();
668 fontStyleMapSet.Insert( "weight", "normal" );
669 fontStyleMapSet.Insert( "slant", "oblique" );
671 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
672 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
673 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
674 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
676 fontStyleMapSet.Clear();
677 fontStyleMapSet.Insert( "slant", "roman" );
679 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
680 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
682 // Replace 'roman' for 'normal'.
683 slantValue = fontStyleMapGet.Find( "slant" );
684 if( NULL != slantValue )
686 if( "normal" == slantValue->Get<std::string>() )
688 fontStyleMapGet["slant"] = "roman";
691 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
692 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
694 fontStyleMapSet.Clear();
696 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
697 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
698 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
699 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
701 // Check the line spacing property
702 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
703 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
704 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
706 // Check the input line spacing property
707 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
708 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
709 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
711 // Check the underline property
713 Property::Map underlineMapSet;
714 Property::Map underlineMapGet;
716 underlineMapSet.Insert( "enable", true );
717 underlineMapSet.Insert( "color", Color::RED );
718 underlineMapSet.Insert( "height", 1 );
720 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
722 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
723 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
724 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
726 // Check the input underline property
727 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
728 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
730 // Check the shadow property
731 Property::Map shadowMapSet;
732 Property::Map shadowMapGet;
734 shadowMapSet.Insert( "color", Color::GREEN );
735 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
736 shadowMapSet.Insert( "blurRadius", 3.0f );
738 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
740 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
741 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
742 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
744 // Check the input shadow property
745 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
746 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
748 // Check the emboss property
749 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
750 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
752 // Check the input emboss property
753 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
754 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
756 // Check the outline property
758 // Test string type first
759 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
760 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
761 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
763 // Then test the property map type
764 Property::Map outlineMapSet;
765 Property::Map outlineMapGet;
767 outlineMapSet["color"] = Color::RED;
768 outlineMapSet["width"] = 2.0f;
770 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
772 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
773 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
774 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
776 // Check the input outline property
777 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
778 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
780 // Check the smooth scroll property
781 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
782 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
783 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
785 // Check the smooth scroll duration property
786 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
787 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
789 // Check the scroll bar property
790 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
791 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
792 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
794 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
795 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
796 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
797 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
799 // Check the pixel size of font
800 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
801 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
803 // Check placeholder text properties.
804 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
805 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
807 // Check placeholder text's color property.
808 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
809 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
811 // Check the enable selection property
812 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
813 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
815 // Check the placeholder property with pixel size
816 Property::Map placeholderPixelSizeMapSet;
817 Property::Map placeholderPixelSizeMapGet;
818 Property::Map placeholderFontstyleMap;
819 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
820 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
821 placeholderPixelSizeMapSet["color"] = Color::BLUE;
822 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
823 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
825 placeholderFontstyleMap.Insert( "weight", "bold" );
826 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
827 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
829 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
830 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
832 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
833 Property::Map placeholderConversionMap;
834 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
835 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
836 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
837 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
838 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
839 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
841 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
843 // Check the placeholder property with point size
844 Property::Map placeholderMapSet;
845 Property::Map placeholderMapGet;
846 placeholderMapSet["text"] = "Setting Placeholder Text";
847 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
848 placeholderMapSet["color"] = Color::RED;
849 placeholderMapSet["fontFamily"] = "Arial";
850 placeholderMapSet["pointSize"] = 12.0f;
851 // Check the placeholder font style property
852 placeholderFontstyleMap.Clear();
854 placeholderFontstyleMap.Insert( "weight", "bold" );
855 placeholderFontstyleMap.Insert( "width", "condensed" );
856 placeholderFontstyleMap.Insert( "slant", "italic" );
857 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
858 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
860 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
861 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
863 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
864 placeholderConversionMap.Clear();
865 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
866 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
867 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
868 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
869 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
870 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
871 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
874 placeholderFontstyleMap.Clear();
875 placeholderFontstyleMap.Insert( "weight", "normal" );
876 placeholderFontstyleMap.Insert( "slant", "oblique" );
877 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
878 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
880 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
881 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
882 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
883 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
885 placeholderFontstyleMap.Clear();
886 placeholderFontstyleMap.Insert( "slant", "roman" );
887 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
888 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
890 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
892 placeholderFontstyleMap.Clear();
893 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
895 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
896 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
897 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
898 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
899 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
901 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
902 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
904 application.SendNotification();
905 application.Render();
910 // Positive Atlas Text Renderer test
911 int utcDaliTextEditorAtlasRenderP(void)
913 ToolkitTestApplication application;
914 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
915 StyleManager styleManager = StyleManager::Get();
916 styleManager.ApplyDefaultTheme();
917 TextEditor editor = TextEditor::New();
918 DALI_TEST_CHECK( editor );
920 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
922 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
924 application.GetScene().Add( editor );
928 // Render some text with the shared atlas backend
929 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
930 application.SendNotification();
931 application.Render();
935 tet_result(TET_FAIL);
940 // Positive test for the textChanged signal.
941 int utcDaliTextEditorTextChangedP(void)
943 ToolkitTestApplication application;
944 tet_infoline(" utcDaliTextEditorTextChangedP");
945 TextEditor editor = TextEditor::New();
946 DALI_TEST_CHECK( editor );
948 application.GetScene().Add( editor );
950 // connect to the text changed signal.
951 ConnectionTracker* testTracker = new ConnectionTracker();
952 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
953 bool textChangedSignal = false;
954 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
956 gTextChangedCallBackCalled = false;
957 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
958 DALI_TEST_CHECK( gTextChangedCallBackCalled );
959 DALI_TEST_CHECK( textChangedSignal );
961 application.SendNotification();
963 editor.SetKeyInputFocus();
965 gTextChangedCallBackCalled = false;
966 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
967 DALI_TEST_CHECK( gTextChangedCallBackCalled );
972 int utcDaliTextEditorInputStyleChanged01(void)
974 // The text-editor emits signals when the input style changes. These changes of style are
975 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
976 // can't be emitted during the size negotiation as the callbacks may update the UI.
977 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
978 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
979 ToolkitTestApplication application;
980 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
984 char* pathNamePtr = get_current_dir_name();
985 const std::string pathName( pathNamePtr );
988 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
989 fontClient.SetDpi( 93u, 93u );
991 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
992 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
994 TextEditor editor = TextEditor::New();
995 DALI_TEST_CHECK( editor );
998 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
999 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1000 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1002 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1003 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1005 // connect to the text changed signal.
1006 ConnectionTracker* testTracker = new ConnectionTracker();
1007 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1008 bool inputStyleChangedSignal = false;
1009 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1011 application.GetScene().Add( editor );
1013 // Render and notify
1014 application.SendNotification();
1015 application.Render();
1017 // Executes the idle callbacks added by the text control on the change of input style.
1018 application.RunIdles();
1020 gInputStyleChangedCallbackCalled = false;
1021 gInputStyleMask = TextEditor::InputStyle::NONE;
1022 inputStyleChangedSignal = false;
1024 // Create a tap event to touch the text editor.
1025 TestGenerateTap( application, 18.0f, 25.0f );
1027 // Render and notify
1028 application.SendNotification();
1029 application.Render();
1031 // Executes the idle callbacks added by the text control on the change of input style.
1032 application.RunIdles();
1034 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1035 if( gInputStyleChangedCallbackCalled )
1037 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1039 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1040 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1042 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1043 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1045 DALI_TEST_CHECK( inputStyleChangedSignal );
1047 gInputStyleChangedCallbackCalled = false;
1048 gInputStyleMask = TextEditor::InputStyle::NONE;
1049 inputStyleChangedSignal = false;
1051 // Create a tap event to touch the text editor.
1052 TestGenerateTap( application, 30.0f, 25.0f );
1054 // Render and notify
1055 application.SendNotification();
1056 application.Render();
1058 // Executes the idle callbacks added by the text control on the change of input style.
1059 application.RunIdles();
1061 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1062 DALI_TEST_CHECK( !inputStyleChangedSignal );
1064 gInputStyleChangedCallbackCalled = false;
1065 gInputStyleMask = TextEditor::InputStyle::NONE;
1066 inputStyleChangedSignal = false;
1068 // Create a tap event to touch the text editor.
1069 TestGenerateTap( application, 43.0f, 25.0f );
1071 // Render and notify
1072 application.SendNotification();
1073 application.Render();
1075 // Executes the idle callbacks added by the text control on the change of input style.
1076 application.RunIdles();
1078 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1079 if( gInputStyleChangedCallbackCalled )
1081 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1083 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1084 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1086 DALI_TEST_CHECK( inputStyleChangedSignal );
1088 gInputStyleChangedCallbackCalled = false;
1089 gInputStyleMask = TextEditor::InputStyle::NONE;
1090 inputStyleChangedSignal = false;
1092 // Create a tap event to touch the text editor.
1093 TestGenerateTap( application, 88.0f, 25.0f );
1095 // Render and notify
1096 application.SendNotification();
1097 application.Render();
1099 // Executes the idle callbacks added by the text control on the change of input style.
1100 application.RunIdles();
1102 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1103 if( gInputStyleChangedCallbackCalled )
1105 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1107 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1108 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1110 Property::Map fontStyleMapSet;
1111 Property::Map fontStyleMapGet;
1113 fontStyleMapSet.Insert( "weight", "bold" );
1115 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1116 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1117 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1119 DALI_TEST_CHECK( inputStyleChangedSignal );
1121 gInputStyleChangedCallbackCalled = false;
1122 gInputStyleMask = TextEditor::InputStyle::NONE;
1123 inputStyleChangedSignal = false;
1125 // Create a tap event to touch the text editor.
1126 TestGenerateTap( application, 115.0f, 25.0f );
1128 // Render and notify
1129 application.SendNotification();
1130 application.Render();
1132 // Executes the idle callbacks added by the text control on the change of input style.
1133 application.RunIdles();
1135 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1136 DALI_TEST_CHECK( !inputStyleChangedSignal );
1138 gInputStyleChangedCallbackCalled = false;
1139 gInputStyleMask = TextEditor::InputStyle::NONE;
1140 inputStyleChangedSignal = false;
1142 // Create a tap event to touch the text editor.
1143 TestGenerateTap( application, 164.0f, 25.0f );
1145 // Render and notify
1146 application.SendNotification();
1147 application.Render();
1149 // Executes the idle callbacks added by the text control on the change of input style.
1150 application.RunIdles();
1152 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1153 if( gInputStyleChangedCallbackCalled )
1155 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1157 Property::Map fontStyleMapSet;
1158 Property::Map fontStyleMapGet;
1160 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1161 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1162 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1164 DALI_TEST_CHECK( inputStyleChangedSignal );
1166 gInputStyleChangedCallbackCalled = false;
1167 gInputStyleMask = TextEditor::InputStyle::NONE;
1168 inputStyleChangedSignal = false;
1170 // Create a tap event to touch the text editor.
1171 TestGenerateTap( application, 191.0f, 25.0f );
1173 // Render and notify
1174 application.SendNotification();
1175 application.Render();
1177 // Executes the idle callbacks added by the text control on the change of input style.
1178 application.RunIdles();
1180 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1181 DALI_TEST_CHECK( !inputStyleChangedSignal );
1186 int utcDaliTextEditorInputStyleChanged02(void)
1188 // The text-editor emits signals when the input style changes. These changes of style are
1189 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1190 // can't be emitted during the size negotiation as the callbacks may update the UI.
1191 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1192 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1193 ToolkitTestApplication application;
1194 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1198 char* pathNamePtr = get_current_dir_name();
1199 const std::string pathName( pathNamePtr );
1200 free( pathNamePtr );
1202 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1203 fontClient.SetDpi( 93u, 93u );
1205 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1206 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1208 TextEditor editor = TextEditor::New();
1209 DALI_TEST_CHECK( editor );
1212 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1213 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1214 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1216 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1217 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>" );
1219 // connect to the text changed signal.
1220 ConnectionTracker* testTracker = new ConnectionTracker();
1221 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1222 bool inputStyleChangedSignal = false;
1223 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1225 application.GetScene().Add( editor );
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Executes the idle callbacks added by the text control on the change of input style.
1232 application.RunIdles();
1234 gInputStyleChangedCallbackCalled = false;
1235 gInputStyleMask = TextEditor::InputStyle::NONE;
1236 inputStyleChangedSignal = false;
1238 // Create a tap event to touch the text editor.
1239 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1240 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1242 // Render and notify
1243 application.SendNotification();
1244 application.Render();
1246 // Executes the idle callbacks added by the text control on the change of input style.
1247 application.RunIdles();
1249 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1250 if( gInputStyleChangedCallbackCalled )
1252 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1253 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1254 TextEditor::InputStyle::POINT_SIZE |
1255 TextEditor::InputStyle::COLOR ),
1258 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1259 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1261 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1262 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1264 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1265 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1267 DALI_TEST_CHECK( inputStyleChangedSignal );
1269 gInputStyleChangedCallbackCalled = false;
1270 gInputStyleMask = TextEditor::InputStyle::NONE;
1271 inputStyleChangedSignal = false;
1273 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1275 // Render and notify
1276 application.SendNotification();
1277 application.Render();
1279 // Executes the idle callbacks added by the text control on the change of input style.
1280 application.RunIdles();
1282 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1283 if( gInputStyleChangedCallbackCalled )
1285 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1286 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1289 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1290 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1292 DALI_TEST_CHECK( inputStyleChangedSignal );
1294 gInputStyleChangedCallbackCalled = false;
1295 gInputStyleMask = TextEditor::InputStyle::NONE;
1296 inputStyleChangedSignal = false;
1298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1300 // Render and notify
1301 application.SendNotification();
1302 application.Render();
1304 // Executes the idle callbacks added by the text control on the change of input style.
1305 application.RunIdles();
1307 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1308 DALI_TEST_CHECK( !inputStyleChangedSignal );
1310 gInputStyleChangedCallbackCalled = false;
1311 gInputStyleMask = TextEditor::InputStyle::NONE;
1312 inputStyleChangedSignal = false;
1314 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1316 // Render and notify
1317 application.SendNotification();
1318 application.Render();
1320 // Executes the idle callbacks added by the text control on the change of input style.
1321 application.RunIdles();
1323 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1324 if( gInputStyleChangedCallbackCalled )
1326 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1327 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1330 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1331 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1333 DALI_TEST_CHECK( inputStyleChangedSignal );
1335 gInputStyleChangedCallbackCalled = false;
1336 gInputStyleMask = TextEditor::InputStyle::NONE;
1337 inputStyleChangedSignal = false;
1339 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1341 Property::Map fontStyleMapSet;
1342 fontStyleMapSet.Insert( "weight", "thin" );
1343 fontStyleMapSet.Insert( "width", "condensed" );
1344 fontStyleMapSet.Insert( "slant", "italic" );
1346 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1347 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1348 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1350 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1351 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1352 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1353 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1355 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1357 // Render and notify
1358 application.SendNotification();
1359 application.Render();
1361 // Executes the idle callbacks added by the text control on the change of input style.
1362 application.RunIdles();
1364 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1365 DALI_TEST_CHECK( !inputStyleChangedSignal );
1367 // Create a tap event to touch the text editor.
1368 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1370 // Render and notify
1371 application.SendNotification();
1372 application.Render();
1374 // Executes the idle callbacks added by the text control on the change of input style.
1375 application.RunIdles();
1377 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1378 if( gInputStyleChangedCallbackCalled )
1380 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1381 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1382 TextEditor::InputStyle::POINT_SIZE |
1383 TextEditor::InputStyle::FONT_STYLE |
1384 TextEditor::InputStyle::LINE_SPACING |
1385 TextEditor::InputStyle::UNDERLINE |
1386 TextEditor::InputStyle::SHADOW |
1387 TextEditor::InputStyle::EMBOSS |
1388 TextEditor::InputStyle::OUTLINE ),
1391 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1392 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1394 DALI_TEST_CHECK( inputStyleChangedSignal );
1396 gInputStyleChangedCallbackCalled = false;
1397 gInputStyleMask = TextEditor::InputStyle::NONE;
1398 inputStyleChangedSignal = false;
1400 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1402 fontStyleMapSet.Clear();
1403 fontStyleMapSet.Insert( "weight", "black" );
1404 fontStyleMapSet.Insert( "width", "expanded" );
1405 fontStyleMapSet.Insert( "slant", "oblique" );
1407 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1409 // Create a tap event to touch the text editor.
1410 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1412 // Render and notify
1413 application.SendNotification();
1414 application.Render();
1416 // Executes the idle callbacks added by the text control on the change of input style.
1417 application.RunIdles();
1419 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1420 if( gInputStyleChangedCallbackCalled )
1422 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1423 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1424 TextEditor::InputStyle::POINT_SIZE |
1425 TextEditor::InputStyle::FONT_STYLE ),
1428 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1429 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1431 DALI_TEST_CHECK( inputStyleChangedSignal );
1436 int utcDaliTextEditorEvent01(void)
1438 ToolkitTestApplication application;
1439 tet_infoline(" utcDaliTextEditorEvent01");
1441 // Creates a tap event. After creating a tap event the text editor should
1442 // have the focus and add text with key events should be possible.
1444 TextEditor editor = TextEditor::New();
1445 DALI_TEST_CHECK( editor );
1447 application.GetScene().Add( editor );
1449 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1450 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1451 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1453 // Avoid a crash when core load gl resources.
1454 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1456 // Render and notify
1457 application.SendNotification();
1458 application.Render();
1460 // Add a key event but as the text editor has not the focus it should do nothing.
1461 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1463 // Render and notify
1464 application.SendNotification();
1465 application.Render();
1467 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1469 // Create a tap event to touch the text editor.
1470 TestGenerateTap( application, 150.0f, 25.0f );
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 // Now the text editor has the focus, so it can handle the key events.
1477 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1478 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1480 // Render and notify
1481 application.SendNotification();
1482 application.Render();
1484 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1486 // Create a second text editor and send key events to it.
1487 TextEditor editor2 = TextEditor::New();
1489 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1490 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1491 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1492 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1494 application.GetScene().Add( editor2 );
1496 // Render and notify
1497 application.SendNotification();
1498 application.Render();
1500 // Create a tap event on the second text editor.
1501 TestGenerateTap( application, 150.0f, 125.0f );
1503 // Render and notify
1504 application.SendNotification();
1505 application.Render();
1507 // The second text editor has the focus. It should handle the key events.
1508 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1509 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1511 // Render and notify
1512 application.SendNotification();
1513 application.Render();
1515 // Check the text has been added to the second text editor.
1516 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1521 int utcDaliTextEditorEvent02(void)
1523 ToolkitTestApplication application;
1524 tet_infoline(" utcDaliTextEditorEvent02");
1526 // Checks if the right number of actors are created.
1528 TextEditor editor = TextEditor::New();
1529 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1530 DALI_TEST_CHECK( editor );
1532 application.GetScene().Add( editor );
1534 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1535 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1536 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1538 // Avoid a crash when core load gl resources.
1539 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 // Check there are the expected number of children (the stencil).
1546 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1548 Actor stencil = editor.GetChildAt( 0u );
1550 // Create a tap event to touch the text editor.
1551 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1553 // Render and notify
1554 application.SendNotification();
1555 application.Render();
1557 Actor layer = editor.GetChildAt( 1u );
1558 DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
1560 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1561 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1563 // Now the text editor has the focus, so it can handle the key events.
1564 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1565 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // Checks the cursor and the renderer have been created.
1572 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1573 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1575 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1576 DALI_TEST_CHECK( cursor );
1578 // The stencil actor has a container with all the actors which contain the text renderers.
1579 Actor container = stencil.GetChildAt( 0u );
1580 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1582 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1583 DALI_TEST_CHECK( renderer );
1586 // Move the cursor and check the position changes.
1587 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1589 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1590 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1592 // Render and notify
1593 application.SendNotification();
1594 application.Render();
1596 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1598 DALI_TEST_CHECK( position2.x < position1.x );
1600 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1601 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1609 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1611 // Send some taps and check the cursor positions.
1613 // Try to tap at the beginning.
1614 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 // Cursor position should be the same than position1.
1621 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1623 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1625 // Tap away from the start position.
1626 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1634 DALI_TEST_CHECK( position5.x > position4.x );
1636 // Remove all the text.
1637 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1638 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 editor.SetProperty( TextEditor::Property::TEXT, "" );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Cursor position should be the same than position2.
1646 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1648 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1650 // Should not be a renderer.
1651 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1656 int utcDaliTextEditorEvent03(void)
1658 ToolkitTestApplication application;
1659 tet_infoline(" utcDaliTextEditorEvent03");
1661 // Checks if the highlight actor is created.
1663 TextEditor editor = TextEditor::New();
1664 DALI_TEST_CHECK( editor );
1666 application.GetScene().Add( editor );
1668 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1669 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1670 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1671 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1672 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1674 // Avoid a crash when core load gl resources.
1675 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 // Send some taps and check text controller with clipboard window
1682 Dali::Clipboard clipboard = Clipboard::Get();
1683 clipboard.ShowClipboard();
1684 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1685 clipboard.HideClipboard();
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1691 // Tap first to get the focus.
1692 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1694 // Render and notify
1695 application.SendNotification();
1696 application.Render();
1698 // Double tap to select a word.
1699 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 // The stencil actor should have two actors: the renderer and the highlight actor.
1706 Actor stencil = editor.GetChildAt( 0u );
1708 // Highlight needs to be drawn before text, so should come first in child order
1709 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1710 DALI_TEST_CHECK( highlight );
1712 // The stencil actor has a container with all the actors which contain the text renderers.
1713 Actor container = stencil.GetChildAt( 1u );
1714 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1716 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1717 DALI_TEST_CHECK( renderer );
1720 // Double tap out of bounds
1721 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1722 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1724 // Render and notify
1725 application.SendNotification();
1726 application.Render();
1728 // The stencil actor should have one actors: the renderer actor.
1729 stencil = editor.GetChildAt( 0u );
1731 // The stencil actor has a container with all the actors which contain the text renderers.
1732 container = stencil.GetChildAt( 0u );
1733 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1735 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1736 DALI_TEST_CHECK( renderer );
1740 TestGenerateLongPress(application, 1.0f, 25.0f);
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1749 int utcDaliTextEditorEvent04(void)
1751 ToolkitTestApplication application;
1752 tet_infoline(" utcDaliTextEditorEvent04");
1754 // Checks if the highlight actor is created.
1756 TextEditor editor = TextEditor::New();
1757 DALI_TEST_CHECK( editor );
1759 application.GetScene().Add( editor );
1761 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1762 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1763 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1764 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1765 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1767 // Avoid a crash when core load gl resources.
1768 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // Tap on the text editor
1775 TestGenerateTap( application, 3.0f, 25.0f );
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1781 // Move at the end of the text.
1782 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1783 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1789 for( unsigned int index = 0u; index < 10u; ++index )
1791 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1792 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1800 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1802 // Render and notify
1803 application.SendNotification();
1804 application.Render();
1806 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1808 // Add some key events
1809 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1810 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1816 for( unsigned int index = 0u; index < 10u; ++index )
1818 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1827 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1829 // Render and notify
1830 application.SendNotification();
1831 application.Render();
1833 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1838 int utcDaliTextEditorEvent05(void)
1840 ToolkitTestApplication application;
1841 tet_infoline(" utcDaliTextEditorEvent05");
1843 // Checks if the highlight actor is created.
1845 TextEditor editor = TextEditor::New();
1846 DALI_TEST_CHECK( editor );
1848 application.GetScene().Add( editor );
1850 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1851 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1852 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1853 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1854 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1855 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1856 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1857 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1858 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1859 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1861 // Avoid a crash when core load gl resources.
1862 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1864 // Render and notify
1865 application.SendNotification();
1866 application.Render();
1868 // Tap on the text editor
1869 TestGenerateTap( application, 3.0f, 25.0f );
1871 // Render and notify
1872 application.SendNotification();
1873 application.Render();
1875 // Move at the end of the text.
1876 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1877 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1879 // Render and notify
1880 application.SendNotification();
1881 application.Render();
1883 for( unsigned int index = 0u; index < 10u; ++index )
1886 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1888 // Render and notify
1889 application.SendNotification();
1890 application.Render();
1892 // Modify duration after scroll is enabled
1893 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1895 // Continuous scroll left to increase coverage
1896 for( unsigned int index = 0u; index < 10u; ++index )
1898 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1904 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1905 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1906 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1907 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1908 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1910 // Press Escape to increase coverage
1911 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1912 application.SendNotification();
1913 application.Render();
1915 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1920 int utcDaliTextEditorEvent06(void)
1922 ToolkitTestApplication application;
1923 tet_infoline(" utcDaliTextEditorEvent06");
1925 // Checks if the highlight actor is created.
1927 TextEditor editor = TextEditor::New();
1928 DALI_TEST_CHECK( editor );
1930 application.GetScene().Add( editor );
1932 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1933 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1934 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1935 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1936 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1938 // Avoid a crash when core load gl resources.
1939 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Tap on the text editor
1946 TestGenerateTap( application, 3.0f, 25.0f );
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Move to seconds line of the text.
1953 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1955 // Render and notify
1956 application.SendNotification();
1957 application.Render();
1959 float layoutHeight = editor.GetHeightForWidth( 100.f );
1962 // Add another script characters ( glyph height is defferent )
1963 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1964 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1966 // Delete characters
1967 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1968 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1970 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1972 // Render and notify
1973 application.SendNotification();
1974 application.Render();
1976 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1979 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1980 application.SendNotification();
1981 application.Render();
1983 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1984 application.SendNotification();
1985 application.Render();
1987 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1988 application.SendNotification();
1989 application.Render();
1991 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1992 application.SendNotification();
1993 application.Render();
1995 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1996 application.SendNotification();
1997 application.Render();
1999 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2000 application.SendNotification();
2001 application.Render();
2003 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2004 application.SendNotification();
2005 application.Render();
2010 int utcDaliTextEditorEvent07(void)
2012 ToolkitTestApplication application;
2013 tet_infoline(" utcDaliTextEditorEvent07");
2015 // Checks if the highlight actor is created.
2017 TextEditor editor = TextEditor::New();
2018 DALI_TEST_CHECK( editor );
2020 application.GetScene().Add( editor );
2022 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2023 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2024 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2025 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2026 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2028 // Avoid a crash when core load gl resources.
2029 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 // Tap on the text editor
2036 TestGenerateTap( application, 3.0f, 25.0f );
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2042 // Move to second line of the text.
2043 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Select some text in the right of the current cursor position
2050 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2052 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 // Cut the selected text
2060 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2061 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 ) );
2063 // Render and notify
2064 application.SendNotification();
2065 application.Render();
2067 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2069 // Select some text in the left of the current cursor position
2070 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2071 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2075 // Render and notify
2076 application.SendNotification();
2077 application.Render();
2079 // Copy the selected text
2080 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081 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 ) );
2083 // Render and notify
2084 application.SendNotification();
2085 application.Render();
2087 // Move the cursor to the third line
2088 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2089 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 // Render and notify
2092 application.SendNotification();
2093 application.Render();
2095 // Paste the selected text at the current cursor position
2096 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2097 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 ) );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2103 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2106 // Disable Shift Selection
2107 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2109 // Test to select some text in the right of the current cursor position
2110 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2111 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2112 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2115 // Render and notify
2116 application.SendNotification();
2117 application.Render();
2119 // Cut the selected text
2120 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2121 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 ) );
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2127 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2128 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2130 // Test to select some text in the left of the current cursor position
2131 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2132 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2133 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // Copy the selected text
2141 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2142 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 ) );
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2149 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2154 int utcDaliTextEditorEvent08(void)
2156 ToolkitTestApplication application;
2157 tet_infoline(" utcDaliTextEditorEvent08");
2159 // Checks if the highlight actor is released correctly.
2161 TextEditor editor = TextEditor::New();
2162 DALI_TEST_CHECK( editor );
2164 application.GetScene().Add( editor );
2166 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2167 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2168 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2169 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2170 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2172 // Avoid a crash when core load gl resources.
2173 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 // Tap on the text editor
2180 TestGenerateTap( application, 3.0f, 25.0f );
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2186 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2187 // Test to select some text in the left of the current cursor position
2188 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2193 // Render and notify
2194 application.SendNotification();
2195 application.Render();
2197 // Test to the left selection handle position and the right selection handle position
2198 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2199 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2200 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // Test to select full text in the left of the current cursor position
2208 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2215 // Render and notify
2216 application.SendNotification();
2217 application.Render();
2219 // Test to release the current full text selection
2220 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2227 // Test to move the current cursor position correctly
2228 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2230 // Render and notify
2231 application.SendNotification();
2232 application.Render();
2235 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 // Render and notify
2238 application.SendNotification();
2239 application.Render();
2241 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2243 // Test to select some text in the right of the current cursor position
2244 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2245 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2248 // Render and notify
2249 application.SendNotification();
2250 application.Render();
2252 // Test the cursor position with right arrow key
2253 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 // Render and notify
2256 application.SendNotification();
2257 application.Render();
2260 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 // Render and notify
2263 application.SendNotification();
2264 application.Render();
2266 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2268 // Test to select some text in the left of the current cursor position
2269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2275 // Render and notify
2276 application.SendNotification();
2277 application.Render();
2279 // Test the cursor position with left arrow key
2280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2287 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 // Render and notify
2290 application.SendNotification();
2291 application.Render();
2293 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2295 // Test to select some text in the right of the current cursor position
2296 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 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 ) );
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 // Test the cursor position with left arrow key
2306 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 // Render and notify
2309 application.SendNotification();
2310 application.Render();
2313 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2319 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2321 // Test to select some text in the left of the current cursor position
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2327 // Render and notify
2328 application.SendNotification();
2329 application.Render();
2331 // Test the cursor position with right arrow key
2332 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2334 // Render and notify
2335 application.SendNotification();
2336 application.Render();
2339 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2341 // Render and notify
2342 application.SendNotification();
2343 application.Render();
2345 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2350 int utcDaliTextEditorHandles(void)
2352 ToolkitTestApplication application;
2353 tet_infoline(" utcDaliTextEditorHandles");
2355 TextEditor editor = TextEditor::New();
2356 DALI_TEST_CHECK( editor );
2358 application.GetScene().Add( editor );
2360 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2361 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2362 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2363 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2365 Property::Map imagePropertyMap;
2366 imagePropertyMap["type"] = "BufferImage";
2367 imagePropertyMap["width"] = 40;
2368 imagePropertyMap["height"] = 40;
2370 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2371 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2372 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2373 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2375 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2376 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2377 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2379 // Avoid a crash when core load gl resources.
2380 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2382 // Render and notify
2383 application.SendNotification();
2384 application.Render();
2386 // Tap first to get the focus.
2387 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2389 // Render and notify
2390 application.SendNotification();
2391 application.Render();
2393 // Tap to create the grab handle.
2394 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2396 // Render and notify
2397 application.SendNotification();
2398 application.Render();
2400 // Get the active layer where the text's decoration is added.
2401 Actor activeLayer = editor.GetChildAt( 1u );
2403 // Get the handle's actor.
2404 Actor handle = activeLayer.GetChildAt( 1u );
2405 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // Touch the grab handle to set it as pressed.
2412 Vector2 touchPos( 10.0f, 50.0f );
2413 Dali::Integration::TouchEvent event;
2414 event = Dali::Integration::TouchEvent();
2415 event.AddPoint( GetPointDownInside( touchPos ) );
2416 application.ProcessEvent( event );
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 // Release the grab handle.
2423 event = Dali::Integration::TouchEvent();
2424 event.AddPoint( GetPointUpInside( touchPos ) );
2425 application.ProcessEvent( event );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2431 // Tap first to get the focus.
2432 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 // Double tap to select a word and create the selection handles.
2439 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2441 // Render and notify
2442 application.SendNotification();
2443 application.Render();
2445 touchPos = Vector2( 10.0f, 50.0f );
2447 // Touch the left selection handle to set it as pressed.
2448 event = Dali::Integration::TouchEvent();
2449 event.AddPoint( GetPointDownInside( touchPos ) );
2450 application.ProcessEvent( event );
2452 // Render and notify
2453 application.SendNotification();
2454 application.Render();
2456 // Release the left selection handle.
2457 event = Dali::Integration::TouchEvent();
2458 event.AddPoint( GetPointUpInside( touchPos ) );
2459 application.ProcessEvent( event );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2468 int utcDaliTextEditorUnderPropertyStringP(void)
2470 ToolkitTestApplication application;
2471 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2472 TextEditor editor = TextEditor::New();
2473 DALI_TEST_CHECK( editor );
2475 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2477 application.GetScene().Add( editor );
2479 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2480 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2482 tet_infoline("Set underline settings with a map");
2483 // Check the input underline property
2484 Property::Map underlineMapSet;
2485 Property::Map underlineMapGet;
2486 underlineMapSet.Insert( "enable", true );
2487 underlineMapSet.Insert( "color", Color::BLUE );
2488 underlineMapSet.Insert( "height", 2 );
2490 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2491 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2492 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2493 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2495 tet_infoline("Set underline settings with a string");
2496 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2497 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2500 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2502 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2503 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2504 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2505 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2507 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2512 int utcDaliTextEditorShadowPropertyStringP(void)
2514 ToolkitTestApplication application;
2515 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2517 TextEditor editor = TextEditor::New();
2519 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2521 application.GetScene().Add( editor );
2523 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2525 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2529 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2534 int utcDaliTextEditorFontStylePropertyStringP(void)
2536 ToolkitTestApplication application;
2537 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2539 TextEditor editor = TextEditor::New();
2541 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2543 application.GetScene().Add( editor );
2545 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2547 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2551 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2556 int utcDaliTextEditorGetPropertyLinecountP(void)
2558 ToolkitTestApplication application;
2560 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2564 TextEditor editor = TextEditor::New();
2565 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2566 editor.SetProperty( TextEditor::Property::TEXT,
2567 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2569 application.GetScene().Add( editor );
2571 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2572 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2573 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2575 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2576 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2577 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2582 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2585 ToolkitTestApplication application;
2586 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2588 TextEditor editor = TextEditor::New();
2589 DALI_TEST_CHECK( editor );
2591 application.GetScene().Add( editor );
2593 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2594 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2595 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2596 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2597 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2598 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2600 bool startedCalled = false;
2601 bool finishedCalled = false;
2603 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2604 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2606 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2608 // Render and notify
2609 application.SendNotification();
2610 application.Render();
2612 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2613 application.SendNotification();
2614 application.Render(6000);
2616 application.SendNotification();
2617 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2618 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2623 int UtcDaliToolkitTextEditorTextWrapMode(void)
2625 ToolkitTestApplication application;
2626 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2630 TextEditor editor = TextEditor::New();
2631 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2632 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2634 application.GetScene().Add( editor );
2636 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2637 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2639 application.SendNotification();
2640 application.Render();
2642 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2643 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2645 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2646 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2648 application.SendNotification();
2649 application.Render();
2651 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2652 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2654 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2655 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2657 application.SendNotification();
2658 application.Render();
2660 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2661 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2663 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2664 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2666 application.SendNotification();
2667 application.Render();
2669 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2670 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2675 int UtcDaliTextEditorSetPaddingProperty(void)
2677 ToolkitTestApplication application;
2678 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2680 TextEditor editor = TextEditor::New();
2681 DALI_TEST_CHECK( editor );
2682 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2683 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2684 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2685 application.GetScene().Add( editor );
2687 application.SendNotification();
2688 application.Render();
2690 Vector3 originalSize = editor.GetNaturalSize();
2692 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2694 application.SendNotification();
2695 application.Render();
2697 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2699 Vector3 paddingAddedSize = editor.GetNaturalSize();
2701 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2703 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2708 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2710 ToolkitTestApplication application;
2711 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2713 TextEditor editor = TextEditor::New();
2714 DALI_TEST_CHECK( editor );
2715 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2716 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2717 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2718 application.GetScene().Add( editor );
2720 application.SendNotification();
2721 application.Render();
2723 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2724 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2726 // Check the enable shift selection property
2727 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2728 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2730 application.SendNotification();
2731 application.Render();
2736 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2738 ToolkitTestApplication application;
2739 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2741 TextEditor editor = TextEditor::New();
2742 DALI_TEST_CHECK( editor );
2743 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2744 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2745 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2746 application.GetScene().Add( editor );
2748 application.SendNotification();
2749 application.Render();
2751 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2752 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2754 // Check the enable grab handle property
2755 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2756 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2758 application.SendNotification();
2759 application.Render();
2764 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2766 ToolkitTestApplication application;
2767 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2769 TextEditor editor = TextEditor::New();
2770 DALI_TEST_CHECK( editor );
2771 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2772 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2773 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2774 application.GetScene().Add( editor );
2776 application.SendNotification();
2777 application.Render();
2779 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2780 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2782 // Check the enable match system language direction property
2783 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2784 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2786 application.SendNotification();
2787 application.Render();
2792 int UtcDaliTextEditorGetInputMethodContext(void)
2794 ToolkitTestApplication application;
2795 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2797 TextEditor editor = TextEditor::New();
2798 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2803 int utcDaliTextEditorMaxCharactersReached(void)
2805 ToolkitTestApplication application;
2806 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2808 TextEditor editor = TextEditor::New();
2809 DALI_TEST_CHECK( editor );
2811 application.GetScene().Add( editor );
2813 const int maxNumberOfCharacters = 1;
2814 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2815 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2817 editor.SetKeyInputFocus();
2819 // connect to the text changed signal.
2820 ConnectionTracker* testTracker = new ConnectionTracker();
2821 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2822 bool maxLengthReachedSignal = false;
2823 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2825 gMaxCharactersCallBackCalled = false;
2827 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2828 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2830 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2831 DALI_TEST_CHECK( maxLengthReachedSignal );