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 UtcDaliToolkitTextEditorAssignmentOperatorP(void)
374 ToolkitTestApplication application;
375 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
376 TextEditor textEditor = TextEditor::New();
377 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
379 TextEditor copy = textEditor;
380 DALI_TEST_CHECK( copy );
381 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
385 int UtcDaliTextEditorNewP(void)
387 ToolkitTestApplication application;
388 tet_infoline(" UtcDaliToolkitTextEditorNewP");
389 TextEditor textEditor = TextEditor::New();
390 DALI_TEST_CHECK( textEditor );
394 // Positive test case for a method
395 int UtcDaliTextEditorGetPropertyP(void)
397 ToolkitTestApplication application;
398 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
399 TextEditor editor = TextEditor::New();
400 DALI_TEST_CHECK( editor );
402 // Check Property Indices are correct
403 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
404 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
405 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
406 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
407 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
408 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
409 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
410 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
411 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
412 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
413 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
414 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
415 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
416 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
417 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
463 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
466 Property::Map imageMap;
467 imageMap[mapKey] =mapValue;
469 editor.SetProperty( property , imageMap );
470 Property::Value propValue = editor.GetProperty( property );
471 Property::Map* resultMap = propValue.GetMap();
473 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
481 // Positive test case for a method
482 int UtcDaliTextEditorSetPropertyP(void)
484 ToolkitTestApplication application;
485 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
486 TextEditor editor = TextEditor::New();
487 DALI_TEST_CHECK( editor );
488 application.GetScene().Add( editor );
490 // Note - we can't check the defaults since the stylesheets are platform-specific
492 // Check the render backend property.
493 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
494 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
496 // Check text property.
497 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
498 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
500 // Check text's color property
501 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
502 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
504 // Check font properties.
505 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
506 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
508 Property::Map fontStyleMapSet;
509 Property::Map fontStyleMapGet;
510 Property::Value* slantValue = NULL;
512 fontStyleMapSet.Insert( "weight", "bold" );
513 fontStyleMapSet.Insert( "width", "condensed" );
514 fontStyleMapSet.Insert( "slant", "italic" );
516 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
517 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
518 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
519 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
521 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
522 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
525 fontStyleMapSet.Clear();
526 fontStyleMapSet.Insert( "weight", "normal" );
527 fontStyleMapSet.Insert( "slant", "oblique" );
528 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
529 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
530 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
531 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
533 fontStyleMapSet.Clear();
534 fontStyleMapSet.Insert( "slant", "roman" );
535 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
536 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
538 // Replace 'roman' for 'normal'.
539 slantValue = fontStyleMapGet.Find( "slant" );
540 if( NULL != slantValue )
542 if( "normal" == slantValue->Get<std::string>() )
544 fontStyleMapGet["slant"] = "roman";
547 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
548 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
550 fontStyleMapSet.Clear();
552 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
553 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
554 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
555 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
557 // Check that the Alignment properties can be correctly set
558 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
559 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
561 // Check scroll properties.
562 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
563 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
564 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
565 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
567 // Check cursor properties
568 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
569 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
570 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
571 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
573 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
574 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
575 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
576 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
577 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
578 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
579 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
580 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
582 // Check handle images
583 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
584 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
585 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
586 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
587 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
589 // Check handle images
590 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
591 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
592 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
593 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
594 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
595 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
597 // Check the highlight color
598 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
599 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
601 // Decoration bounding box
602 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
603 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
605 // Check the enable markup property.
606 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
607 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
608 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
610 // Check input color property.
611 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
612 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
614 // Check input font properties.
615 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
616 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
618 fontStyleMapSet.Clear();
619 fontStyleMapSet.Insert( "weight", "bold" );
620 fontStyleMapSet.Insert( "width", "condensed" );
621 fontStyleMapSet.Insert( "slant", "italic" );
623 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
624 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
625 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
626 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
628 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
629 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631 // Reset input font style.
632 fontStyleMapSet.Clear();
633 fontStyleMapSet.Insert( "weight", "normal" );
634 fontStyleMapSet.Insert( "slant", "oblique" );
636 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
637 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
638 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
639 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
641 fontStyleMapSet.Clear();
642 fontStyleMapSet.Insert( "slant", "roman" );
644 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
645 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
647 // Replace 'roman' for 'normal'.
648 slantValue = fontStyleMapGet.Find( "slant" );
649 if( NULL != slantValue )
651 if( "normal" == slantValue->Get<std::string>() )
653 fontStyleMapGet["slant"] = "roman";
656 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
657 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
659 fontStyleMapSet.Clear();
661 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
662 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
663 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
664 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
666 // Check the line spacing property
667 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
669 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
671 // Check the input line spacing property
672 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
673 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
674 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
676 // Check the underline property
678 Property::Map underlineMapSet;
679 Property::Map underlineMapGet;
681 underlineMapSet.Insert( "enable", true );
682 underlineMapSet.Insert( "color", Color::RED );
683 underlineMapSet.Insert( "height", 1 );
685 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
687 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
688 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
689 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
691 // Check the input underline property
692 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
693 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
695 // Check the shadow property
696 Property::Map shadowMapSet;
697 Property::Map shadowMapGet;
699 shadowMapSet.Insert( "color", Color::GREEN );
700 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
701 shadowMapSet.Insert( "blurRadius", 3.0f );
703 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
705 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
706 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
707 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
709 // Check the input shadow property
710 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
711 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
713 // Check the emboss property
714 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
715 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
717 // Check the input emboss property
718 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
719 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
721 // Check the outline property
723 // Test string type first
724 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
725 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
726 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
728 // Then test the property map type
729 Property::Map outlineMapSet;
730 Property::Map outlineMapGet;
732 outlineMapSet["color"] = Color::RED;
733 outlineMapSet["width"] = 2.0f;
735 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
737 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
738 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
739 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
741 // Check the input outline property
742 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
743 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
745 // Check the smooth scroll property
746 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
747 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
748 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
750 // Check the smooth scroll duration property
751 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
752 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 // Check the scroll bar property
755 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
756 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
757 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
759 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
760 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
761 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
762 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
764 // Check the pixel size of font
765 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
766 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
768 // Check placeholder text properties.
769 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
770 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
772 // Check placeholder text's color property.
773 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
774 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
776 // Check the enable selection property
777 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
778 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
780 // Check the placeholder property with pixel size
781 Property::Map placeholderPixelSizeMapSet;
782 Property::Map placeholderPixelSizeMapGet;
783 Property::Map placeholderFontstyleMap;
784 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
785 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
786 placeholderPixelSizeMapSet["color"] = Color::BLUE;
787 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
788 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
790 placeholderFontstyleMap.Insert( "weight", "bold" );
791 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
792 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
794 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
795 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
797 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
798 Property::Map placeholderConversionMap;
799 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
800 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
801 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
802 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
803 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
804 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
806 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
808 // Check the placeholder property with point size
809 Property::Map placeholderMapSet;
810 Property::Map placeholderMapGet;
811 placeholderMapSet["text"] = "Setting Placeholder Text";
812 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
813 placeholderMapSet["color"] = Color::RED;
814 placeholderMapSet["fontFamily"] = "Arial";
815 placeholderMapSet["pointSize"] = 12.0f;
816 // Check the placeholder font style property
817 placeholderFontstyleMap.Clear();
819 placeholderFontstyleMap.Insert( "weight", "bold" );
820 placeholderFontstyleMap.Insert( "width", "condensed" );
821 placeholderFontstyleMap.Insert( "slant", "italic" );
822 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
823 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
825 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
826 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
828 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
829 placeholderConversionMap.Clear();
830 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
831 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
832 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
833 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
834 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
835 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
836 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
839 placeholderFontstyleMap.Clear();
840 placeholderFontstyleMap.Insert( "weight", "normal" );
841 placeholderFontstyleMap.Insert( "slant", "oblique" );
842 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
843 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
845 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
846 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
847 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
848 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
850 placeholderFontstyleMap.Clear();
851 placeholderFontstyleMap.Insert( "slant", "roman" );
852 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
853 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
855 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
857 placeholderFontstyleMap.Clear();
858 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
860 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
861 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
862 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
863 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
864 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
866 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
867 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
869 application.SendNotification();
870 application.Render();
875 // Positive Atlas Text Renderer test
876 int utcDaliTextEditorAtlasRenderP(void)
878 ToolkitTestApplication application;
879 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
880 StyleManager styleManager = StyleManager::Get();
881 styleManager.ApplyDefaultTheme();
882 TextEditor editor = TextEditor::New();
883 DALI_TEST_CHECK( editor );
885 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
887 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
889 application.GetScene().Add( editor );
893 // Render some text with the shared atlas backend
894 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
895 application.SendNotification();
896 application.Render();
900 tet_result(TET_FAIL);
905 // Positive test for the textChanged signal.
906 int utcDaliTextEditorTextChangedP(void)
908 ToolkitTestApplication application;
909 tet_infoline(" utcDaliTextEditorTextChangedP");
910 TextEditor editor = TextEditor::New();
911 DALI_TEST_CHECK( editor );
913 application.GetScene().Add( editor );
915 // connect to the text changed signal.
916 ConnectionTracker* testTracker = new ConnectionTracker();
917 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
918 bool textChangedSignal = false;
919 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
921 gTextChangedCallBackCalled = false;
922 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
923 DALI_TEST_CHECK( gTextChangedCallBackCalled );
924 DALI_TEST_CHECK( textChangedSignal );
926 application.SendNotification();
928 editor.SetKeyInputFocus();
930 gTextChangedCallBackCalled = false;
931 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
932 DALI_TEST_CHECK( gTextChangedCallBackCalled );
937 int utcDaliTextEditorInputStyleChanged01(void)
939 // The text-editor emits signals when the input style changes. These changes of style are
940 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
941 // can't be emitted during the size negotiation as the callbacks may update the UI.
942 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
943 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
944 ToolkitTestApplication application;
945 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
949 char* pathNamePtr = get_current_dir_name();
950 const std::string pathName( pathNamePtr );
953 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
954 fontClient.SetDpi( 93u, 93u );
956 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
957 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
959 TextEditor editor = TextEditor::New();
960 DALI_TEST_CHECK( editor );
963 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
964 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
965 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
967 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
968 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
970 // connect to the text changed signal.
971 ConnectionTracker* testTracker = new ConnectionTracker();
972 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
973 bool inputStyleChangedSignal = false;
974 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
976 application.GetScene().Add( editor );
979 application.SendNotification();
980 application.Render();
982 // Executes the idle callbacks added by the text control on the change of input style.
983 application.RunIdles();
985 gInputStyleChangedCallbackCalled = false;
986 gInputStyleMask = TextEditor::InputStyle::NONE;
987 inputStyleChangedSignal = false;
989 // Create a tap event to touch the text editor.
990 TestGenerateTap( application, 18.0f, 25.0f );
993 application.SendNotification();
994 application.Render();
996 // Executes the idle callbacks added by the text control on the change of input style.
997 application.RunIdles();
999 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1000 if( gInputStyleChangedCallbackCalled )
1002 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1004 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1005 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1007 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1008 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1010 DALI_TEST_CHECK( inputStyleChangedSignal );
1012 gInputStyleChangedCallbackCalled = false;
1013 gInputStyleMask = TextEditor::InputStyle::NONE;
1014 inputStyleChangedSignal = false;
1016 // Create a tap event to touch the text editor.
1017 TestGenerateTap( application, 30.0f, 25.0f );
1019 // Render and notify
1020 application.SendNotification();
1021 application.Render();
1023 // Executes the idle callbacks added by the text control on the change of input style.
1024 application.RunIdles();
1026 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1027 DALI_TEST_CHECK( !inputStyleChangedSignal );
1029 gInputStyleChangedCallbackCalled = false;
1030 gInputStyleMask = TextEditor::InputStyle::NONE;
1031 inputStyleChangedSignal = false;
1033 // Create a tap event to touch the text editor.
1034 TestGenerateTap( application, 43.0f, 25.0f );
1036 // Render and notify
1037 application.SendNotification();
1038 application.Render();
1040 // Executes the idle callbacks added by the text control on the change of input style.
1041 application.RunIdles();
1043 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1044 if( gInputStyleChangedCallbackCalled )
1046 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1048 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1049 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1051 DALI_TEST_CHECK( inputStyleChangedSignal );
1053 gInputStyleChangedCallbackCalled = false;
1054 gInputStyleMask = TextEditor::InputStyle::NONE;
1055 inputStyleChangedSignal = false;
1057 // Create a tap event to touch the text editor.
1058 TestGenerateTap( application, 88.0f, 25.0f );
1060 // Render and notify
1061 application.SendNotification();
1062 application.Render();
1064 // Executes the idle callbacks added by the text control on the change of input style.
1065 application.RunIdles();
1067 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1068 if( gInputStyleChangedCallbackCalled )
1070 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1072 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1073 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1075 Property::Map fontStyleMapSet;
1076 Property::Map fontStyleMapGet;
1078 fontStyleMapSet.Insert( "weight", "bold" );
1080 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1081 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1082 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1084 DALI_TEST_CHECK( inputStyleChangedSignal );
1086 gInputStyleChangedCallbackCalled = false;
1087 gInputStyleMask = TextEditor::InputStyle::NONE;
1088 inputStyleChangedSignal = false;
1090 // Create a tap event to touch the text editor.
1091 TestGenerateTap( application, 115.0f, 25.0f );
1093 // Render and notify
1094 application.SendNotification();
1095 application.Render();
1097 // Executes the idle callbacks added by the text control on the change of input style.
1098 application.RunIdles();
1100 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1101 DALI_TEST_CHECK( !inputStyleChangedSignal );
1103 gInputStyleChangedCallbackCalled = false;
1104 gInputStyleMask = TextEditor::InputStyle::NONE;
1105 inputStyleChangedSignal = false;
1107 // Create a tap event to touch the text editor.
1108 TestGenerateTap( application, 164.0f, 25.0f );
1110 // Render and notify
1111 application.SendNotification();
1112 application.Render();
1114 // Executes the idle callbacks added by the text control on the change of input style.
1115 application.RunIdles();
1117 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1118 if( gInputStyleChangedCallbackCalled )
1120 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1122 Property::Map fontStyleMapSet;
1123 Property::Map fontStyleMapGet;
1125 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1126 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1127 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1129 DALI_TEST_CHECK( inputStyleChangedSignal );
1131 gInputStyleChangedCallbackCalled = false;
1132 gInputStyleMask = TextEditor::InputStyle::NONE;
1133 inputStyleChangedSignal = false;
1135 // Create a tap event to touch the text editor.
1136 TestGenerateTap( application, 191.0f, 25.0f );
1138 // Render and notify
1139 application.SendNotification();
1140 application.Render();
1142 // Executes the idle callbacks added by the text control on the change of input style.
1143 application.RunIdles();
1145 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1146 DALI_TEST_CHECK( !inputStyleChangedSignal );
1151 int utcDaliTextEditorInputStyleChanged02(void)
1153 // The text-editor emits signals when the input style changes. These changes of style are
1154 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1155 // can't be emitted during the size negotiation as the callbacks may update the UI.
1156 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1157 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1158 ToolkitTestApplication application;
1159 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1163 char* pathNamePtr = get_current_dir_name();
1164 const std::string pathName( pathNamePtr );
1165 free( pathNamePtr );
1167 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1168 fontClient.SetDpi( 93u, 93u );
1170 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1171 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1173 TextEditor editor = TextEditor::New();
1174 DALI_TEST_CHECK( editor );
1177 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1178 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1179 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1181 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1182 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>" );
1184 // connect to the text changed signal.
1185 ConnectionTracker* testTracker = new ConnectionTracker();
1186 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1187 bool inputStyleChangedSignal = false;
1188 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1190 application.GetScene().Add( editor );
1192 // Render and notify
1193 application.SendNotification();
1194 application.Render();
1196 // Executes the idle callbacks added by the text control on the change of input style.
1197 application.RunIdles();
1199 gInputStyleChangedCallbackCalled = false;
1200 gInputStyleMask = TextEditor::InputStyle::NONE;
1201 inputStyleChangedSignal = false;
1203 // Create a tap event to touch the text editor.
1204 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1205 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1207 // Render and notify
1208 application.SendNotification();
1209 application.Render();
1211 // Executes the idle callbacks added by the text control on the change of input style.
1212 application.RunIdles();
1214 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1215 if( gInputStyleChangedCallbackCalled )
1217 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1218 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1219 TextEditor::InputStyle::POINT_SIZE |
1220 TextEditor::InputStyle::COLOR ),
1223 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1224 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1226 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1227 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1229 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1230 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1232 DALI_TEST_CHECK( inputStyleChangedSignal );
1234 gInputStyleChangedCallbackCalled = false;
1235 gInputStyleMask = TextEditor::InputStyle::NONE;
1236 inputStyleChangedSignal = false;
1238 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1240 // Render and notify
1241 application.SendNotification();
1242 application.Render();
1244 // Executes the idle callbacks added by the text control on the change of input style.
1245 application.RunIdles();
1247 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1248 if( gInputStyleChangedCallbackCalled )
1250 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1251 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1254 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1255 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1257 DALI_TEST_CHECK( inputStyleChangedSignal );
1259 gInputStyleChangedCallbackCalled = false;
1260 gInputStyleMask = TextEditor::InputStyle::NONE;
1261 inputStyleChangedSignal = false;
1263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1265 // Render and notify
1266 application.SendNotification();
1267 application.Render();
1269 // Executes the idle callbacks added by the text control on the change of input style.
1270 application.RunIdles();
1272 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1273 DALI_TEST_CHECK( !inputStyleChangedSignal );
1275 gInputStyleChangedCallbackCalled = false;
1276 gInputStyleMask = TextEditor::InputStyle::NONE;
1277 inputStyleChangedSignal = false;
1279 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1281 // Render and notify
1282 application.SendNotification();
1283 application.Render();
1285 // Executes the idle callbacks added by the text control on the change of input style.
1286 application.RunIdles();
1288 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1289 if( gInputStyleChangedCallbackCalled )
1291 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1292 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1295 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1296 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1298 DALI_TEST_CHECK( inputStyleChangedSignal );
1300 gInputStyleChangedCallbackCalled = false;
1301 gInputStyleMask = TextEditor::InputStyle::NONE;
1302 inputStyleChangedSignal = false;
1304 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1306 Property::Map fontStyleMapSet;
1307 fontStyleMapSet.Insert( "weight", "thin" );
1308 fontStyleMapSet.Insert( "width", "condensed" );
1309 fontStyleMapSet.Insert( "slant", "italic" );
1311 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1312 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1313 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1315 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1316 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1317 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1318 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1320 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1322 // Render and notify
1323 application.SendNotification();
1324 application.Render();
1326 // Executes the idle callbacks added by the text control on the change of input style.
1327 application.RunIdles();
1329 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1330 DALI_TEST_CHECK( !inputStyleChangedSignal );
1332 // Create a tap event to touch the text editor.
1333 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Executes the idle callbacks added by the text control on the change of input style.
1340 application.RunIdles();
1342 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1343 if( gInputStyleChangedCallbackCalled )
1345 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1346 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1347 TextEditor::InputStyle::POINT_SIZE |
1348 TextEditor::InputStyle::FONT_STYLE |
1349 TextEditor::InputStyle::LINE_SPACING |
1350 TextEditor::InputStyle::UNDERLINE |
1351 TextEditor::InputStyle::SHADOW |
1352 TextEditor::InputStyle::EMBOSS |
1353 TextEditor::InputStyle::OUTLINE ),
1356 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1357 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1359 DALI_TEST_CHECK( inputStyleChangedSignal );
1361 gInputStyleChangedCallbackCalled = false;
1362 gInputStyleMask = TextEditor::InputStyle::NONE;
1363 inputStyleChangedSignal = false;
1365 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1367 fontStyleMapSet.Clear();
1368 fontStyleMapSet.Insert( "weight", "black" );
1369 fontStyleMapSet.Insert( "width", "expanded" );
1370 fontStyleMapSet.Insert( "slant", "oblique" );
1372 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1374 // Create a tap event to touch the text editor.
1375 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1377 // Render and notify
1378 application.SendNotification();
1379 application.Render();
1381 // Executes the idle callbacks added by the text control on the change of input style.
1382 application.RunIdles();
1384 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1385 if( gInputStyleChangedCallbackCalled )
1387 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1388 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1389 TextEditor::InputStyle::POINT_SIZE |
1390 TextEditor::InputStyle::FONT_STYLE ),
1393 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1394 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1396 DALI_TEST_CHECK( inputStyleChangedSignal );
1401 int utcDaliTextEditorEvent01(void)
1403 ToolkitTestApplication application;
1404 tet_infoline(" utcDaliTextEditorEvent01");
1406 // Creates a tap event. After creating a tap event the text editor should
1407 // have the focus and add text with key events should be possible.
1409 TextEditor editor = TextEditor::New();
1410 DALI_TEST_CHECK( editor );
1412 application.GetScene().Add( editor );
1414 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1415 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1416 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1418 // Avoid a crash when core load gl resources.
1419 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1421 // Render and notify
1422 application.SendNotification();
1423 application.Render();
1425 // Add a key event but as the text editor has not the focus it should do nothing.
1426 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1428 // Render and notify
1429 application.SendNotification();
1430 application.Render();
1432 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1434 // Create a tap event to touch the text editor.
1435 TestGenerateTap( application, 150.0f, 25.0f );
1437 // Render and notify
1438 application.SendNotification();
1439 application.Render();
1441 // Now the text editor has the focus, so it can handle the key events.
1442 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1443 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1445 // Render and notify
1446 application.SendNotification();
1447 application.Render();
1449 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1451 // Create a second text editor and send key events to it.
1452 TextEditor editor2 = TextEditor::New();
1454 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1455 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1456 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1457 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1459 application.GetScene().Add( editor2 );
1461 // Render and notify
1462 application.SendNotification();
1463 application.Render();
1465 // Create a tap event on the second text editor.
1466 TestGenerateTap( application, 150.0f, 125.0f );
1468 // Render and notify
1469 application.SendNotification();
1470 application.Render();
1472 // The second text editor has the focus. It should handle the key events.
1473 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1474 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Check the text has been added to the second text editor.
1481 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1486 int utcDaliTextEditorEvent02(void)
1488 ToolkitTestApplication application;
1489 tet_infoline(" utcDaliTextEditorEvent02");
1491 // Checks if the right number of actors are created.
1493 TextEditor editor = TextEditor::New();
1494 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1495 DALI_TEST_CHECK( editor );
1497 application.GetScene().Add( editor );
1499 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1500 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1501 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1503 // Avoid a crash when core load gl resources.
1504 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1506 // Render and notify
1507 application.SendNotification();
1508 application.Render();
1510 // Check there are the expected number of children (the stencil).
1511 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1513 Actor stencil = editor.GetChildAt( 0u );
1515 // Create a tap event to touch the text editor.
1516 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 Actor layer = editor.GetChildAt( 1u );
1523 DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
1525 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1526 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1528 // Now the text editor has the focus, so it can handle the key events.
1529 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1530 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 // Checks the cursor and the renderer have been created.
1537 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1538 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1540 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1541 DALI_TEST_CHECK( cursor );
1543 // The stencil actor has a container with all the actors which contain the text renderers.
1544 Actor container = stencil.GetChildAt( 0u );
1545 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1547 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1548 DALI_TEST_CHECK( renderer );
1551 // Move the cursor and check the position changes.
1552 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1554 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1555 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1557 // Render and notify
1558 application.SendNotification();
1559 application.Render();
1561 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1563 DALI_TEST_CHECK( position2.x < position1.x );
1565 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1566 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1568 // Render and notify
1569 application.SendNotification();
1570 application.Render();
1572 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1574 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1576 // Send some taps and check the cursor positions.
1578 // Try to tap at the beginning.
1579 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1581 // Render and notify
1582 application.SendNotification();
1583 application.Render();
1585 // Cursor position should be the same than position1.
1586 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1588 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1590 // Tap away from the start position.
1591 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1593 // Render and notify
1594 application.SendNotification();
1595 application.Render();
1597 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1599 DALI_TEST_CHECK( position5.x > position4.x );
1601 // Remove all the text.
1602 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1604 editor.SetProperty( TextEditor::Property::TEXT, "" );
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Cursor position should be the same than position2.
1611 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1613 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1615 // Should not be a renderer.
1616 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1621 int utcDaliTextEditorEvent03(void)
1623 ToolkitTestApplication application;
1624 tet_infoline(" utcDaliTextEditorEvent03");
1626 // Checks if the highlight actor is created.
1628 TextEditor editor = TextEditor::New();
1629 DALI_TEST_CHECK( editor );
1631 application.GetScene().Add( editor );
1633 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1634 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1635 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1636 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1637 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1639 // Avoid a crash when core load gl resources.
1640 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1642 // Render and notify
1643 application.SendNotification();
1644 application.Render();
1646 // Send some taps and check text controller with clipboard window
1647 Dali::Clipboard clipboard = Clipboard::Get();
1648 clipboard.ShowClipboard();
1649 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1650 clipboard.HideClipboard();
1652 // Render and notify
1653 application.SendNotification();
1654 application.Render();
1656 // Tap first to get the focus.
1657 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 // Double tap to select a word.
1664 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 // The stencil actor should have two actors: the renderer and the highlight actor.
1671 Actor stencil = editor.GetChildAt( 0u );
1673 // Highlight needs to be drawn before text, so should come first in child order
1674 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1675 DALI_TEST_CHECK( highlight );
1677 // The stencil actor has a container with all the actors which contain the text renderers.
1678 Actor container = stencil.GetChildAt( 1u );
1679 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1681 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1682 DALI_TEST_CHECK( renderer );
1685 // Double tap out of bounds
1686 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1687 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1693 // The stencil actor should have one actors: the renderer actor.
1694 stencil = editor.GetChildAt( 0u );
1696 // The stencil actor has a container with all the actors which contain the text renderers.
1697 container = stencil.GetChildAt( 0u );
1698 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1700 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1701 DALI_TEST_CHECK( renderer );
1705 TestGenerateLongPress(application, 1.0f, 25.0f);
1707 // Render and notify
1708 application.SendNotification();
1709 application.Render();
1714 int utcDaliTextEditorEvent04(void)
1716 ToolkitTestApplication application;
1717 tet_infoline(" utcDaliTextEditorEvent04");
1719 // Checks if the highlight actor is created.
1721 TextEditor editor = TextEditor::New();
1722 DALI_TEST_CHECK( editor );
1724 application.GetScene().Add( editor );
1726 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1727 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1728 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1729 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1730 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1732 // Avoid a crash when core load gl resources.
1733 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1735 // Render and notify
1736 application.SendNotification();
1737 application.Render();
1739 // Tap on the text editor
1740 TestGenerateTap( application, 3.0f, 25.0f );
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1746 // Move at the end of the text.
1747 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1748 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1754 for( unsigned int index = 0u; index < 10u; ++index )
1756 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1757 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1759 // Render and notify
1760 application.SendNotification();
1761 application.Render();
1765 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
1771 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1773 // Add some key events
1774 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1775 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1781 for( unsigned int index = 0u; index < 10u; ++index )
1783 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1784 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1792 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1803 int utcDaliTextEditorEvent05(void)
1805 ToolkitTestApplication application;
1806 tet_infoline(" utcDaliTextEditorEvent05");
1808 // Checks if the highlight actor is created.
1810 TextEditor editor = TextEditor::New();
1811 DALI_TEST_CHECK( editor );
1813 application.GetScene().Add( editor );
1815 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1816 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1817 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1818 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1819 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1820 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1821 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1822 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1823 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1824 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1826 // Avoid a crash when core load gl resources.
1827 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1829 // Render and notify
1830 application.SendNotification();
1831 application.Render();
1833 // Tap on the text editor
1834 TestGenerateTap( application, 3.0f, 25.0f );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 // Move at the end of the text.
1841 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1842 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1844 // Render and notify
1845 application.SendNotification();
1846 application.Render();
1848 for( unsigned int index = 0u; index < 10u; ++index )
1851 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1853 // Render and notify
1854 application.SendNotification();
1855 application.Render();
1857 // Modify duration after scroll is enabled
1858 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1860 // Continuous scroll left to increase coverage
1861 for( unsigned int index = 0u; index < 10u; ++index )
1863 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1869 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1870 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1871 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1872 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1873 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1875 // Press Escape to increase coverage
1876 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1877 application.SendNotification();
1878 application.Render();
1880 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1885 int utcDaliTextEditorEvent06(void)
1887 ToolkitTestApplication application;
1888 tet_infoline(" utcDaliTextEditorEvent06");
1890 // Checks if the highlight actor is created.
1892 TextEditor editor = TextEditor::New();
1893 DALI_TEST_CHECK( editor );
1895 application.GetScene().Add( editor );
1897 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1898 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1899 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1900 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1901 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1903 // Avoid a crash when core load gl resources.
1904 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Tap on the text editor
1911 TestGenerateTap( application, 3.0f, 25.0f );
1913 // Render and notify
1914 application.SendNotification();
1915 application.Render();
1917 // Move to seconds line of the text.
1918 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1920 // Render and notify
1921 application.SendNotification();
1922 application.Render();
1924 float layoutHeight = editor.GetHeightForWidth( 100.f );
1927 // Add another script characters ( glyph height is defferent )
1928 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1929 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1931 // Delete characters
1932 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1933 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1935 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1941 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1944 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1945 application.SendNotification();
1946 application.Render();
1948 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1949 application.SendNotification();
1950 application.Render();
1952 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1953 application.SendNotification();
1954 application.Render();
1956 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1957 application.SendNotification();
1958 application.Render();
1960 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1961 application.SendNotification();
1962 application.Render();
1964 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1965 application.SendNotification();
1966 application.Render();
1968 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1969 application.SendNotification();
1970 application.Render();
1975 int utcDaliTextEditorEvent07(void)
1977 ToolkitTestApplication application;
1978 tet_infoline(" utcDaliTextEditorEvent07");
1980 // Checks if the highlight actor is created.
1982 TextEditor editor = TextEditor::New();
1983 DALI_TEST_CHECK( editor );
1985 application.GetScene().Add( editor );
1987 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1988 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1989 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1990 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1991 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1993 // Avoid a crash when core load gl resources.
1994 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1996 // Render and notify
1997 application.SendNotification();
1998 application.Render();
2000 // Tap on the text editor
2001 TestGenerateTap( application, 3.0f, 25.0f );
2003 // Render and notify
2004 application.SendNotification();
2005 application.Render();
2007 // Move to second line of the text.
2008 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2014 // Select some text in the right of the current cursor position
2015 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2016 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2017 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2018 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 // Cut the selected text
2025 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2026 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 ) );
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2032 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2034 // Select some text in the left of the current cursor position
2035 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2036 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2037 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2038 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2044 // Copy the selected text
2045 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 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 ) );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 // Move the cursor to the third line
2053 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2054 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 // Paste the selected text at the current cursor position
2061 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062 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 ) );
2064 // Render and notify
2065 application.SendNotification();
2066 application.Render();
2068 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2071 // Disable Shift Selection
2072 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2074 // Test to select some text in the right of the current cursor position
2075 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2076 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2077 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 // Cut the selected text
2085 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2086 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 ) );
2088 // Render and notify
2089 application.SendNotification();
2090 application.Render();
2092 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2093 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2095 // Test to select some text in the left of the current cursor position
2096 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2097 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2098 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 // Copy the selected text
2106 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107 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 ) );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2113 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2114 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2119 int utcDaliTextEditorEvent08(void)
2121 ToolkitTestApplication application;
2122 tet_infoline(" utcDaliTextEditorEvent08");
2124 // Checks if the highlight actor is released correctly.
2126 TextEditor editor = TextEditor::New();
2127 DALI_TEST_CHECK( editor );
2129 application.GetScene().Add( editor );
2131 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2132 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2133 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2134 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2135 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2137 // Avoid a crash when core load gl resources.
2138 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2140 // Render and notify
2141 application.SendNotification();
2142 application.Render();
2144 // Tap on the text editor
2145 TestGenerateTap( application, 3.0f, 25.0f );
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2152 // Test to select some text in the left of the current cursor position
2153 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2154 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2155 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 // Test to the left selection handle position and the right selection handle position
2163 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2166 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 // Test to select full text in the left of the current cursor position
2173 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2174 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2175 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2176 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2177 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2178 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 // Test to release the current full text selection
2185 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2186 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 // Render and notify
2189 application.SendNotification();
2190 application.Render();
2192 // Test to move the current cursor position correctly
2193 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2195 // Render and notify
2196 application.SendNotification();
2197 application.Render();
2200 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2206 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2208 // Test to select some text in the right of the current cursor position
2209 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 // Test the cursor position with right arrow key
2218 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2225 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2233 // Test to select some text in the left of the current cursor position
2234 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2238 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 // Render and notify
2241 application.SendNotification();
2242 application.Render();
2244 // Test the cursor position with left arrow key
2245 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2247 // Render and notify
2248 application.SendNotification();
2249 application.Render();
2252 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2260 // Test to select some text in the right of the current cursor position
2261 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2264 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2270 // Test the cursor position with left arrow key
2271 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 // Render and notify
2274 application.SendNotification();
2275 application.Render();
2278 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 // Render and notify
2281 application.SendNotification();
2282 application.Render();
2284 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2286 // Test to select some text in the left of the current cursor position
2287 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2296 // Test the cursor position with right arrow key
2297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 // Render and notify
2300 application.SendNotification();
2301 application.Render();
2304 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2315 int utcDaliTextEditorHandles(void)
2317 ToolkitTestApplication application;
2318 tet_infoline(" utcDaliTextEditorHandles");
2320 TextEditor editor = TextEditor::New();
2321 DALI_TEST_CHECK( editor );
2323 application.GetScene().Add( editor );
2325 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2326 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2327 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2328 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2330 Property::Map imagePropertyMap;
2331 imagePropertyMap["type"] = "BufferImage";
2332 imagePropertyMap["width"] = 40;
2333 imagePropertyMap["height"] = 40;
2335 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2336 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2337 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2338 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2340 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2341 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2342 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2344 // Avoid a crash when core load gl resources.
2345 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Tap first to get the focus.
2352 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // Tap to create the grab handle.
2359 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2365 // Get the active layer where the text's decoration is added.
2366 Actor activeLayer = editor.GetChildAt( 1u );
2368 // Get the handle's actor.
2369 Actor handle = activeLayer.GetChildAt( 1u );
2370 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 // Touch the grab handle to set it as pressed.
2377 Vector2 touchPos( 10.0f, 50.0f );
2378 Dali::Integration::TouchEvent event;
2379 event = Dali::Integration::TouchEvent();
2380 event.AddPoint( GetPointDownInside( touchPos ) );
2381 application.ProcessEvent( event );
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 // Release the grab handle.
2388 event = Dali::Integration::TouchEvent();
2389 event.AddPoint( GetPointUpInside( touchPos ) );
2390 application.ProcessEvent( event );
2392 // Render and notify
2393 application.SendNotification();
2394 application.Render();
2396 // Tap first to get the focus.
2397 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2399 // Render and notify
2400 application.SendNotification();
2401 application.Render();
2403 // Double tap to select a word and create the selection handles.
2404 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 touchPos = Vector2( 10.0f, 50.0f );
2412 // Touch the left selection handle to set it as pressed.
2413 event = Dali::Integration::TouchEvent();
2414 event.AddPoint( GetPointDownInside( touchPos ) );
2415 application.ProcessEvent( event );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 // Release the left selection handle.
2422 event = Dali::Integration::TouchEvent();
2423 event.AddPoint( GetPointUpInside( touchPos ) );
2424 application.ProcessEvent( event );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2433 int utcDaliTextEditorUnderPropertyStringP(void)
2435 ToolkitTestApplication application;
2436 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2437 TextEditor editor = TextEditor::New();
2438 DALI_TEST_CHECK( editor );
2440 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2442 application.GetScene().Add( editor );
2444 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2445 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2447 tet_infoline("Set underline settings with a map");
2448 // Check the input underline property
2449 Property::Map underlineMapSet;
2450 Property::Map underlineMapGet;
2451 underlineMapSet.Insert( "enable", true );
2452 underlineMapSet.Insert( "color", Color::BLUE );
2453 underlineMapSet.Insert( "height", 2 );
2455 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2456 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2457 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2458 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2460 tet_infoline("Set underline settings with a string");
2461 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2462 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2465 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2467 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2468 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2469 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2470 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2472 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2477 int utcDaliTextEditorShadowPropertyStringP(void)
2479 ToolkitTestApplication application;
2480 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2482 TextEditor editor = TextEditor::New();
2484 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2486 application.GetScene().Add( editor );
2488 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2490 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2494 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2499 int utcDaliTextEditorFontStylePropertyStringP(void)
2501 ToolkitTestApplication application;
2502 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2504 TextEditor editor = TextEditor::New();
2506 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2508 application.GetScene().Add( editor );
2510 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2512 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2516 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2521 int utcDaliTextEditorGetPropertyLinecountP(void)
2523 ToolkitTestApplication application;
2525 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2529 TextEditor editor = TextEditor::New();
2530 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2531 editor.SetProperty( TextEditor::Property::TEXT,
2532 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2534 application.GetScene().Add( editor );
2536 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2537 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2538 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2540 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2541 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2542 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2547 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2550 ToolkitTestApplication application;
2551 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2553 TextEditor editor = TextEditor::New();
2554 DALI_TEST_CHECK( editor );
2556 application.GetScene().Add( editor );
2558 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2559 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2560 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2561 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2562 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2563 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2565 bool startedCalled = false;
2566 bool finishedCalled = false;
2568 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2569 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2571 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2573 // Render and notify
2574 application.SendNotification();
2575 application.Render();
2577 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2578 application.SendNotification();
2579 application.Render(6000);
2581 application.SendNotification();
2582 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2583 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2588 int UtcDaliToolkitTextEditorTextWrapMode(void)
2590 ToolkitTestApplication application;
2591 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2595 TextEditor editor = TextEditor::New();
2596 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2597 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2599 application.GetScene().Add( editor );
2601 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2602 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2604 application.SendNotification();
2605 application.Render();
2607 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2608 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2610 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2611 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2613 application.SendNotification();
2614 application.Render();
2616 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2617 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2619 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2620 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2622 application.SendNotification();
2623 application.Render();
2625 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2626 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2628 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2629 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2631 application.SendNotification();
2632 application.Render();
2634 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2635 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2640 int UtcDaliTextEditorSetPaddingProperty(void)
2642 ToolkitTestApplication application;
2643 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2645 TextEditor editor = TextEditor::New();
2646 DALI_TEST_CHECK( editor );
2647 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2648 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2649 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2650 application.GetScene().Add( editor );
2652 application.SendNotification();
2653 application.Render();
2655 Vector3 originalSize = editor.GetNaturalSize();
2657 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2659 application.SendNotification();
2660 application.Render();
2662 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2664 Vector3 paddingAddedSize = editor.GetNaturalSize();
2666 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2668 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2673 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2675 ToolkitTestApplication application;
2676 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2678 TextEditor editor = TextEditor::New();
2679 DALI_TEST_CHECK( editor );
2680 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2681 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2682 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2683 application.GetScene().Add( editor );
2685 application.SendNotification();
2686 application.Render();
2688 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2689 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2691 // Check the enable shift selection property
2692 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2693 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2695 application.SendNotification();
2696 application.Render();
2701 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2703 ToolkitTestApplication application;
2704 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2706 TextEditor editor = TextEditor::New();
2707 DALI_TEST_CHECK( editor );
2708 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2709 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2710 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2711 application.GetScene().Add( editor );
2713 application.SendNotification();
2714 application.Render();
2716 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2717 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2719 // Check the enable grab handle property
2720 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2721 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2723 application.SendNotification();
2724 application.Render();
2729 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2731 ToolkitTestApplication application;
2732 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2734 TextEditor editor = TextEditor::New();
2735 DALI_TEST_CHECK( editor );
2736 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2737 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2738 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2739 application.GetScene().Add( editor );
2741 application.SendNotification();
2742 application.Render();
2744 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2745 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2747 // Check the enable match system language direction property
2748 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2749 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2751 application.SendNotification();
2752 application.Render();
2757 int UtcDaliTextEditorGetInputMethodContext(void)
2759 ToolkitTestApplication application;
2760 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2762 TextEditor editor = TextEditor::New();
2763 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2768 int utcDaliTextEditorMaxCharactersReached(void)
2770 ToolkitTestApplication application;
2771 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2773 TextEditor editor = TextEditor::New();
2774 DALI_TEST_CHECK( editor );
2776 application.GetScene().Add( editor );
2778 const int maxNumberOfCharacters = 1;
2779 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2780 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2782 editor.SetKeyInputFocus();
2784 // connect to the text changed signal.
2785 ConnectionTracker* testTracker = new ConnectionTracker();
2786 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2787 bool maxLengthReachedSignal = false;
2788 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2790 gMaxCharactersCallBackCalled = false;
2792 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2793 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2795 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2796 DALI_TEST_CHECK( maxLengthReachedSignal );