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";
106 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
107 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const unsigned int DEFAULT_FONT_SIZE = 1152u;
112 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
114 const int KEY_A_CODE = 38;
115 const int KEY_D_CODE = 40;
116 const int KEY_C_CODE = 54;
117 const int KEY_V_CODE = 55;
118 const int KEY_X_CODE = 53;
119 const int KEY_WHITE_SPACE_CODE = 65;
121 const int KEY_SHIFT_MODIFIER = 257;
122 const int KEY_CONTROL_MODIFIER = 258;
124 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
126 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
128 static bool gTextChangedCallBackCalled;
129 static bool gInputStyleChangedCallbackCalled;
130 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
132 struct CallbackFunctor
134 CallbackFunctor(bool* callbackFlag)
135 : mCallbackFlag( callbackFlag )
141 *mCallbackFlag = true;
146 static void TestTextChangedCallback( TextEditor control )
148 tet_infoline(" TestTextChangedCallback");
150 gTextChangedCallBackCalled = true;
153 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
155 tet_infoline(" TestInputStyleChangedCallback");
157 gInputStyleChangedCallbackCalled = true;
158 gInputStyleMask = mask;
161 // Generate a KeyEvent to send to Core.
162 Integration::KeyEvent GenerateKey( const std::string& keyName,
163 const std::string& logicalKey,
164 const std::string& keyString,
167 unsigned long timeStamp,
168 const Integration::KeyEvent::State& keyState,
169 const std::string& compose = "",
170 const std::string& deviceName = DEFAULT_DEVICE_NAME,
171 const Device::Class::Type& deviceClass = Device::Class::NONE,
172 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
174 return Integration::KeyEvent( keyName,
187 Dali::Integration::Point GetPointDownInside( Vector2& pos )
189 Dali::Integration::Point point;
190 point.SetState( PointState::DOWN );
191 point.SetScreenPosition( pos );
195 Dali::Integration::Point GetPointUpInside( Vector2& pos )
197 Dali::Integration::Point point;
198 point.SetState( PointState::UP );
199 point.SetScreenPosition( pos );
203 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
205 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
207 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
209 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
211 Property::Value* valueSet = NULL;
212 if ( valueGet.first.type == Property::Key::INDEX )
214 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
218 // Get Key is a string so searching Set Map for a string key
219 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
222 if( NULL != valueSet )
224 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
226 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
229 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
231 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
234 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
236 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
239 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
241 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
244 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
246 Vector2 vector2Get = valueGet.second.Get<Vector2>();
247 Vector2 vector2Set = valueSet->Get<Vector2>();
248 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
251 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
253 Vector4 vector4Get = valueGet.second.Get<Vector4>();
254 Vector4 vector4Set = valueSet->Get<Vector4>();
255 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 );
261 if ( valueGet.first.type == Property::Key::INDEX )
263 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
267 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
277 class ScrollStateChangeCallback : public Dali::ConnectionTracker
280 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
281 : mStartedCalled( startedCalled ),
282 mFinishedCalled( finishedCalled )
286 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
288 if( type == TextEditor::Scroll::STARTED )
290 mStartedCalled = true;
292 else if( type == TextEditor::Scroll::FINISHED )
294 mFinishedCalled = true;
298 bool& mStartedCalled;
299 bool& mFinishedCalled;
304 int UtcDaliToolkitTextEditorConstructorP(void)
306 ToolkitTestApplication application;
307 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
308 TextEditor textEditor;
309 DALI_TEST_CHECK( !textEditor );
313 int UtcDaliToolkitTextEditorNewP(void)
315 ToolkitTestApplication application;
316 tet_infoline(" UtcDaliToolkitTextEditorNewP");
317 TextEditor textEditor = TextEditor::New();
318 DALI_TEST_CHECK( textEditor );
322 int UtcDaliToolkitTextEditorDownCastP(void)
324 ToolkitTestApplication application;
325 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
326 TextEditor textEditor1 = TextEditor::New();
327 BaseHandle object( textEditor1 );
329 TextEditor textEditor2 = TextEditor::DownCast( object );
330 DALI_TEST_CHECK( textEditor2 );
332 TextEditor textEditor3 = DownCast< TextEditor >( object );
333 DALI_TEST_CHECK( textEditor3 );
337 int UtcDaliToolkitTextEditorDownCastN(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
341 BaseHandle uninitializedObject;
342 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
343 DALI_TEST_CHECK( !textEditor1 );
345 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
346 DALI_TEST_CHECK( !textEditor2 );
350 int UtcDaliToolkitTextEditorCopyConstructorP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
354 TextEditor textEditor = TextEditor::New();
355 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
357 TextEditor copy( textEditor );
358 DALI_TEST_CHECK( copy );
359 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
363 int UtcDaliTextEditorMoveConstructor(void)
365 ToolkitTestApplication application;
367 TextEditor textEditor = TextEditor::New();
368 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
369 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
371 TextEditor moved = std::move( textEditor );
372 DALI_TEST_CHECK( moved );
373 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
374 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
375 DALI_TEST_CHECK( !textEditor );
380 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
382 ToolkitTestApplication application;
383 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
384 TextEditor textEditor = TextEditor::New();
385 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
387 TextEditor copy = textEditor;
388 DALI_TEST_CHECK( copy );
389 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
393 int UtcDaliTextEditorMoveAssignment(void)
395 ToolkitTestApplication application;
397 TextEditor textEditor = TextEditor::New();
398 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
399 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
402 moved = std::move( textEditor );
403 DALI_TEST_CHECK( moved );
404 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
405 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
406 DALI_TEST_CHECK( !textEditor );
411 int UtcDaliTextEditorNewP(void)
413 ToolkitTestApplication application;
414 tet_infoline(" UtcDaliToolkitTextEditorNewP");
415 TextEditor textEditor = TextEditor::New();
416 DALI_TEST_CHECK( textEditor );
420 // Positive test case for a method
421 int UtcDaliTextEditorGetPropertyP(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
425 TextEditor editor = TextEditor::New();
426 DALI_TEST_CHECK( editor );
428 // Check Property Indices are correct
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
488 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
491 Property::Map imageMap;
492 imageMap[mapKey] =mapValue;
494 editor.SetProperty( property , imageMap );
495 Property::Value propValue = editor.GetProperty( property );
496 Property::Map* resultMap = propValue.GetMap();
498 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
506 // Positive test case for a method
507 int UtcDaliTextEditorSetPropertyP(void)
509 ToolkitTestApplication application;
510 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
511 TextEditor editor = TextEditor::New();
512 DALI_TEST_CHECK( editor );
513 application.GetScene().Add( editor );
515 // Note - we can't check the defaults since the stylesheets are platform-specific
517 // Check the render backend property.
518 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
519 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
521 // Check text property.
522 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
523 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
525 // Check text's color property
526 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
527 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
529 // Check font properties.
530 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
531 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
533 Property::Map fontStyleMapSet;
534 Property::Map fontStyleMapGet;
535 Property::Value* slantValue = NULL;
537 fontStyleMapSet.Insert( "weight", "bold" );
538 fontStyleMapSet.Insert( "width", "condensed" );
539 fontStyleMapSet.Insert( "slant", "italic" );
541 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
542 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
543 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
544 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
546 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
547 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
550 fontStyleMapSet.Clear();
551 fontStyleMapSet.Insert( "weight", "normal" );
552 fontStyleMapSet.Insert( "slant", "oblique" );
553 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
554 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
555 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
556 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
558 fontStyleMapSet.Clear();
559 fontStyleMapSet.Insert( "slant", "roman" );
560 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
561 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
563 // Replace 'roman' for 'normal'.
564 slantValue = fontStyleMapGet.Find( "slant" );
565 if( NULL != slantValue )
567 if( "normal" == slantValue->Get<std::string>() )
569 fontStyleMapGet["slant"] = "roman";
572 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
573 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
575 fontStyleMapSet.Clear();
577 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
578 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
579 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
580 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
582 // Check that the Alignment properties can be correctly set
583 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
584 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
586 // Check scroll properties.
587 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
588 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
589 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
590 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
592 // Check cursor properties
593 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
594 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
595 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
596 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
598 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
599 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
600 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
601 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
602 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
603 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
604 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
605 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
607 // Check handle images
608 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
609 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
610 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
611 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
612 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
614 // Check handle images
615 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
616 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
617 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
618 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
619 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
620 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
622 // Check the highlight color
623 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
624 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
626 // Decoration bounding box
627 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
628 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
630 // Check the enable markup property.
631 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
632 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
633 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
635 // Check input color property.
636 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
637 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
639 // Check input font properties.
640 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
641 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
643 fontStyleMapSet.Clear();
644 fontStyleMapSet.Insert( "weight", "bold" );
645 fontStyleMapSet.Insert( "width", "condensed" );
646 fontStyleMapSet.Insert( "slant", "italic" );
648 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
649 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
650 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
651 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
653 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
654 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
656 // Reset input font style.
657 fontStyleMapSet.Clear();
658 fontStyleMapSet.Insert( "weight", "normal" );
659 fontStyleMapSet.Insert( "slant", "oblique" );
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 fontStyleMapSet.Clear();
667 fontStyleMapSet.Insert( "slant", "roman" );
669 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
670 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
672 // Replace 'roman' for 'normal'.
673 slantValue = fontStyleMapGet.Find( "slant" );
674 if( NULL != slantValue )
676 if( "normal" == slantValue->Get<std::string>() )
678 fontStyleMapGet["slant"] = "roman";
681 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
682 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
684 fontStyleMapSet.Clear();
686 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
687 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
688 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
689 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
691 // Check the line spacing property
692 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
693 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
694 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
696 // Check the input line spacing property
697 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
698 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
699 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
701 // Check the underline property
703 Property::Map underlineMapSet;
704 Property::Map underlineMapGet;
706 underlineMapSet.Insert( "enable", true );
707 underlineMapSet.Insert( "color", Color::RED );
708 underlineMapSet.Insert( "height", 1 );
710 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
712 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
713 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
714 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
716 // Check the input underline property
717 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
718 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
720 // Check the shadow property
721 Property::Map shadowMapSet;
722 Property::Map shadowMapGet;
724 shadowMapSet.Insert( "color", Color::GREEN );
725 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
726 shadowMapSet.Insert( "blurRadius", 3.0f );
728 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
730 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
731 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
732 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
734 // Check the input shadow property
735 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
736 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
738 // Check the emboss property
739 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
740 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
742 // Check the input emboss property
743 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
744 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
746 // Check the outline property
748 // Test string type first
749 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
750 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
751 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
753 // Then test the property map type
754 Property::Map outlineMapSet;
755 Property::Map outlineMapGet;
757 outlineMapSet["color"] = Color::RED;
758 outlineMapSet["width"] = 2.0f;
760 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
762 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
763 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
764 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
766 // Check the input outline property
767 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
768 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
770 // Check the smooth scroll property
771 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
772 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
773 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
775 // Check the smooth scroll duration property
776 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
777 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
779 // Check the scroll bar property
780 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
781 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
782 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
784 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
785 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
786 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
787 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
789 // Check the pixel size of font
790 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
791 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
793 // Check placeholder text properties.
794 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
795 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
797 // Check placeholder text's color property.
798 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
799 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
801 // Check the enable selection property
802 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
803 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
805 // Check the placeholder property with pixel size
806 Property::Map placeholderPixelSizeMapSet;
807 Property::Map placeholderPixelSizeMapGet;
808 Property::Map placeholderFontstyleMap;
809 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
810 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
811 placeholderPixelSizeMapSet["color"] = Color::BLUE;
812 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
813 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
815 placeholderFontstyleMap.Insert( "weight", "bold" );
816 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
817 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
819 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
820 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
822 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
823 Property::Map placeholderConversionMap;
824 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
825 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
826 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
827 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
828 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
829 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
831 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
833 // Check the placeholder property with point size
834 Property::Map placeholderMapSet;
835 Property::Map placeholderMapGet;
836 placeholderMapSet["text"] = "Setting Placeholder Text";
837 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
838 placeholderMapSet["color"] = Color::RED;
839 placeholderMapSet["fontFamily"] = "Arial";
840 placeholderMapSet["pointSize"] = 12.0f;
841 // Check the placeholder font style property
842 placeholderFontstyleMap.Clear();
844 placeholderFontstyleMap.Insert( "weight", "bold" );
845 placeholderFontstyleMap.Insert( "width", "condensed" );
846 placeholderFontstyleMap.Insert( "slant", "italic" );
847 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
848 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
850 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
851 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
853 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
854 placeholderConversionMap.Clear();
855 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
856 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
857 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
858 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
859 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
860 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
861 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
864 placeholderFontstyleMap.Clear();
865 placeholderFontstyleMap.Insert( "weight", "normal" );
866 placeholderFontstyleMap.Insert( "slant", "oblique" );
867 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
868 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
870 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
871 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
872 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
873 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
875 placeholderFontstyleMap.Clear();
876 placeholderFontstyleMap.Insert( "slant", "roman" );
877 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
878 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
880 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
882 placeholderFontstyleMap.Clear();
883 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
885 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
886 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
887 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
888 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
889 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
891 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
892 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
894 application.SendNotification();
895 application.Render();
900 // Positive Atlas Text Renderer test
901 int utcDaliTextEditorAtlasRenderP(void)
903 ToolkitTestApplication application;
904 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
905 StyleManager styleManager = StyleManager::Get();
906 styleManager.ApplyDefaultTheme();
907 TextEditor editor = TextEditor::New();
908 DALI_TEST_CHECK( editor );
910 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
912 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
914 application.GetScene().Add( editor );
918 // Render some text with the shared atlas backend
919 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
920 application.SendNotification();
921 application.Render();
925 tet_result(TET_FAIL);
930 // Positive test for the textChanged signal.
931 int utcDaliTextEditorTextChangedP(void)
933 ToolkitTestApplication application;
934 tet_infoline(" utcDaliTextEditorTextChangedP");
935 TextEditor editor = TextEditor::New();
936 DALI_TEST_CHECK( editor );
938 application.GetScene().Add( editor );
940 // connect to the text changed signal.
941 ConnectionTracker* testTracker = new ConnectionTracker();
942 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
943 bool textChangedSignal = false;
944 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
946 gTextChangedCallBackCalled = false;
947 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
948 DALI_TEST_CHECK( gTextChangedCallBackCalled );
949 DALI_TEST_CHECK( textChangedSignal );
951 application.SendNotification();
953 editor.SetKeyInputFocus();
955 gTextChangedCallBackCalled = false;
956 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
957 DALI_TEST_CHECK( gTextChangedCallBackCalled );
962 int utcDaliTextEditorInputStyleChanged01(void)
964 // The text-editor emits signals when the input style changes. These changes of style are
965 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
966 // can't be emitted during the size negotiation as the callbacks may update the UI.
967 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
968 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
969 ToolkitTestApplication application;
970 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
974 char* pathNamePtr = get_current_dir_name();
975 const std::string pathName( pathNamePtr );
978 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
979 fontClient.SetDpi( 93u, 93u );
981 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
982 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
984 TextEditor editor = TextEditor::New();
985 DALI_TEST_CHECK( editor );
988 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
989 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
990 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
992 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
993 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
995 // connect to the text changed signal.
996 ConnectionTracker* testTracker = new ConnectionTracker();
997 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
998 bool inputStyleChangedSignal = false;
999 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1001 application.GetScene().Add( editor );
1003 // Render and notify
1004 application.SendNotification();
1005 application.Render();
1007 // Executes the idle callbacks added by the text control on the change of input style.
1008 application.RunIdles();
1010 gInputStyleChangedCallbackCalled = false;
1011 gInputStyleMask = TextEditor::InputStyle::NONE;
1012 inputStyleChangedSignal = false;
1014 // Create a tap event to touch the text editor.
1015 TestGenerateTap( application, 18.0f, 25.0f );
1017 // Render and notify
1018 application.SendNotification();
1019 application.Render();
1021 // Executes the idle callbacks added by the text control on the change of input style.
1022 application.RunIdles();
1024 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1025 if( gInputStyleChangedCallbackCalled )
1027 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1029 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1030 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1032 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1033 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1035 DALI_TEST_CHECK( inputStyleChangedSignal );
1037 gInputStyleChangedCallbackCalled = false;
1038 gInputStyleMask = TextEditor::InputStyle::NONE;
1039 inputStyleChangedSignal = false;
1041 // Create a tap event to touch the text editor.
1042 TestGenerateTap( application, 30.0f, 25.0f );
1044 // Render and notify
1045 application.SendNotification();
1046 application.Render();
1048 // Executes the idle callbacks added by the text control on the change of input style.
1049 application.RunIdles();
1051 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1052 DALI_TEST_CHECK( !inputStyleChangedSignal );
1054 gInputStyleChangedCallbackCalled = false;
1055 gInputStyleMask = TextEditor::InputStyle::NONE;
1056 inputStyleChangedSignal = false;
1058 // Create a tap event to touch the text editor.
1059 TestGenerateTap( application, 43.0f, 25.0f );
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 // Executes the idle callbacks added by the text control on the change of input style.
1066 application.RunIdles();
1068 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1069 if( gInputStyleChangedCallbackCalled )
1071 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1073 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1074 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1076 DALI_TEST_CHECK( inputStyleChangedSignal );
1078 gInputStyleChangedCallbackCalled = false;
1079 gInputStyleMask = TextEditor::InputStyle::NONE;
1080 inputStyleChangedSignal = false;
1082 // Create a tap event to touch the text editor.
1083 TestGenerateTap( application, 88.0f, 25.0f );
1085 // Render and notify
1086 application.SendNotification();
1087 application.Render();
1089 // Executes the idle callbacks added by the text control on the change of input style.
1090 application.RunIdles();
1092 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1093 if( gInputStyleChangedCallbackCalled )
1095 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1097 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1098 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1100 Property::Map fontStyleMapSet;
1101 Property::Map fontStyleMapGet;
1103 fontStyleMapSet.Insert( "weight", "bold" );
1105 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1106 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1107 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1109 DALI_TEST_CHECK( inputStyleChangedSignal );
1111 gInputStyleChangedCallbackCalled = false;
1112 gInputStyleMask = TextEditor::InputStyle::NONE;
1113 inputStyleChangedSignal = false;
1115 // Create a tap event to touch the text editor.
1116 TestGenerateTap( application, 115.0f, 25.0f );
1118 // Render and notify
1119 application.SendNotification();
1120 application.Render();
1122 // Executes the idle callbacks added by the text control on the change of input style.
1123 application.RunIdles();
1125 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1126 DALI_TEST_CHECK( !inputStyleChangedSignal );
1128 gInputStyleChangedCallbackCalled = false;
1129 gInputStyleMask = TextEditor::InputStyle::NONE;
1130 inputStyleChangedSignal = false;
1132 // Create a tap event to touch the text editor.
1133 TestGenerateTap( application, 164.0f, 25.0f );
1135 // Render and notify
1136 application.SendNotification();
1137 application.Render();
1139 // Executes the idle callbacks added by the text control on the change of input style.
1140 application.RunIdles();
1142 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1143 if( gInputStyleChangedCallbackCalled )
1145 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1147 Property::Map fontStyleMapSet;
1148 Property::Map fontStyleMapGet;
1150 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1151 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1152 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1154 DALI_TEST_CHECK( inputStyleChangedSignal );
1156 gInputStyleChangedCallbackCalled = false;
1157 gInputStyleMask = TextEditor::InputStyle::NONE;
1158 inputStyleChangedSignal = false;
1160 // Create a tap event to touch the text editor.
1161 TestGenerateTap( application, 191.0f, 25.0f );
1163 // Render and notify
1164 application.SendNotification();
1165 application.Render();
1167 // Executes the idle callbacks added by the text control on the change of input style.
1168 application.RunIdles();
1170 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1171 DALI_TEST_CHECK( !inputStyleChangedSignal );
1176 int utcDaliTextEditorInputStyleChanged02(void)
1178 // The text-editor emits signals when the input style changes. These changes of style are
1179 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1180 // can't be emitted during the size negotiation as the callbacks may update the UI.
1181 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1182 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1183 ToolkitTestApplication application;
1184 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1188 char* pathNamePtr = get_current_dir_name();
1189 const std::string pathName( pathNamePtr );
1190 free( pathNamePtr );
1192 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1193 fontClient.SetDpi( 93u, 93u );
1195 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1196 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1198 TextEditor editor = TextEditor::New();
1199 DALI_TEST_CHECK( editor );
1202 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1203 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1204 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1206 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1207 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>" );
1209 // connect to the text changed signal.
1210 ConnectionTracker* testTracker = new ConnectionTracker();
1211 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1212 bool inputStyleChangedSignal = false;
1213 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1215 application.GetScene().Add( editor );
1217 // Render and notify
1218 application.SendNotification();
1219 application.Render();
1221 // Executes the idle callbacks added by the text control on the change of input style.
1222 application.RunIdles();
1224 gInputStyleChangedCallbackCalled = false;
1225 gInputStyleMask = TextEditor::InputStyle::NONE;
1226 inputStyleChangedSignal = false;
1228 // Create a tap event to touch the text editor.
1229 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1230 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1232 // Render and notify
1233 application.SendNotification();
1234 application.Render();
1236 // Executes the idle callbacks added by the text control on the change of input style.
1237 application.RunIdles();
1239 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1240 if( gInputStyleChangedCallbackCalled )
1242 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1243 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1244 TextEditor::InputStyle::POINT_SIZE |
1245 TextEditor::InputStyle::COLOR ),
1248 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1249 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1251 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1252 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1254 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1255 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, 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 if( gInputStyleChangedCallbackCalled )
1275 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1276 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1279 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1280 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1282 DALI_TEST_CHECK( inputStyleChangedSignal );
1284 gInputStyleChangedCallbackCalled = false;
1285 gInputStyleMask = TextEditor::InputStyle::NONE;
1286 inputStyleChangedSignal = false;
1288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1290 // Render and notify
1291 application.SendNotification();
1292 application.Render();
1294 // Executes the idle callbacks added by the text control on the change of input style.
1295 application.RunIdles();
1297 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1298 DALI_TEST_CHECK( !inputStyleChangedSignal );
1300 gInputStyleChangedCallbackCalled = false;
1301 gInputStyleMask = TextEditor::InputStyle::NONE;
1302 inputStyleChangedSignal = false;
1304 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Executes the idle callbacks added by the text control on the change of input style.
1311 application.RunIdles();
1313 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1314 if( gInputStyleChangedCallbackCalled )
1316 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1317 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1320 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1321 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1323 DALI_TEST_CHECK( inputStyleChangedSignal );
1325 gInputStyleChangedCallbackCalled = false;
1326 gInputStyleMask = TextEditor::InputStyle::NONE;
1327 inputStyleChangedSignal = false;
1329 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1331 Property::Map fontStyleMapSet;
1332 fontStyleMapSet.Insert( "weight", "thin" );
1333 fontStyleMapSet.Insert( "width", "condensed" );
1334 fontStyleMapSet.Insert( "slant", "italic" );
1336 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1337 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1338 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1340 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1341 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1342 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1343 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1345 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1347 // Render and notify
1348 application.SendNotification();
1349 application.Render();
1351 // Executes the idle callbacks added by the text control on the change of input style.
1352 application.RunIdles();
1354 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1355 DALI_TEST_CHECK( !inputStyleChangedSignal );
1357 // Create a tap event to touch the text editor.
1358 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1360 // Render and notify
1361 application.SendNotification();
1362 application.Render();
1364 // Executes the idle callbacks added by the text control on the change of input style.
1365 application.RunIdles();
1367 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1368 if( gInputStyleChangedCallbackCalled )
1370 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1371 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1372 TextEditor::InputStyle::POINT_SIZE |
1373 TextEditor::InputStyle::FONT_STYLE |
1374 TextEditor::InputStyle::LINE_SPACING |
1375 TextEditor::InputStyle::UNDERLINE |
1376 TextEditor::InputStyle::SHADOW |
1377 TextEditor::InputStyle::EMBOSS |
1378 TextEditor::InputStyle::OUTLINE ),
1381 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1382 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1384 DALI_TEST_CHECK( inputStyleChangedSignal );
1386 gInputStyleChangedCallbackCalled = false;
1387 gInputStyleMask = TextEditor::InputStyle::NONE;
1388 inputStyleChangedSignal = false;
1390 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1392 fontStyleMapSet.Clear();
1393 fontStyleMapSet.Insert( "weight", "black" );
1394 fontStyleMapSet.Insert( "width", "expanded" );
1395 fontStyleMapSet.Insert( "slant", "oblique" );
1397 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1399 // Create a tap event to touch the text editor.
1400 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1402 // Render and notify
1403 application.SendNotification();
1404 application.Render();
1406 // Executes the idle callbacks added by the text control on the change of input style.
1407 application.RunIdles();
1409 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1410 if( gInputStyleChangedCallbackCalled )
1412 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1413 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1414 TextEditor::InputStyle::POINT_SIZE |
1415 TextEditor::InputStyle::FONT_STYLE ),
1418 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1419 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1421 DALI_TEST_CHECK( inputStyleChangedSignal );
1426 int utcDaliTextEditorEvent01(void)
1428 ToolkitTestApplication application;
1429 tet_infoline(" utcDaliTextEditorEvent01");
1431 // Creates a tap event. After creating a tap event the text editor should
1432 // have the focus and add text with key events should be possible.
1434 TextEditor editor = TextEditor::New();
1435 DALI_TEST_CHECK( editor );
1437 application.GetScene().Add( editor );
1439 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1440 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1441 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1443 // Avoid a crash when core load gl resources.
1444 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1446 // Render and notify
1447 application.SendNotification();
1448 application.Render();
1450 // Add a key event but as the text editor has not the focus it should do nothing.
1451 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
1457 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1459 // Create a tap event to touch the text editor.
1460 TestGenerateTap( application, 150.0f, 25.0f );
1462 // Render and notify
1463 application.SendNotification();
1464 application.Render();
1466 // Now the text editor has the focus, so it can handle the key events.
1467 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1468 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1470 // Render and notify
1471 application.SendNotification();
1472 application.Render();
1474 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1476 // Create a second text editor and send key events to it.
1477 TextEditor editor2 = TextEditor::New();
1479 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1480 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1481 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1482 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1484 application.GetScene().Add( editor2 );
1486 // Render and notify
1487 application.SendNotification();
1488 application.Render();
1490 // Create a tap event on the second text editor.
1491 TestGenerateTap( application, 150.0f, 125.0f );
1493 // Render and notify
1494 application.SendNotification();
1495 application.Render();
1497 // The second text editor has the focus. It should handle the key events.
1498 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1499 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1501 // Render and notify
1502 application.SendNotification();
1503 application.Render();
1505 // Check the text has been added to the second text editor.
1506 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1511 int utcDaliTextEditorEvent02(void)
1513 ToolkitTestApplication application;
1514 tet_infoline(" utcDaliTextEditorEvent02");
1516 // Checks if the right number of actors are created.
1518 TextEditor editor = TextEditor::New();
1519 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1520 DALI_TEST_CHECK( editor );
1522 application.GetScene().Add( editor );
1524 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1525 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1526 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1528 // Avoid a crash when core load gl resources.
1529 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // Check there are the expected number of children (the stencil).
1536 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1538 Actor stencil = editor.GetChildAt( 0u );
1540 // Create a tap event to touch the text editor.
1541 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1543 // Render and notify
1544 application.SendNotification();
1545 application.Render();
1547 Actor layer = editor.GetChildAt( 1u );
1548 DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
1550 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1551 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1553 // Now the text editor has the focus, so it can handle the key events.
1554 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1555 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1557 // Render and notify
1558 application.SendNotification();
1559 application.Render();
1561 // Checks the cursor and the renderer have been created.
1562 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1563 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1565 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1566 DALI_TEST_CHECK( cursor );
1568 // The stencil actor has a container with all the actors which contain the text renderers.
1569 Actor container = stencil.GetChildAt( 0u );
1570 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1572 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1573 DALI_TEST_CHECK( renderer );
1576 // Move the cursor and check the position changes.
1577 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1579 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1580 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1588 DALI_TEST_CHECK( position2.x < position1.x );
1590 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1591 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1593 // Render and notify
1594 application.SendNotification();
1595 application.Render();
1597 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1599 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1601 // Send some taps and check the cursor positions.
1603 // Try to tap at the beginning.
1604 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Cursor position should be the same than position1.
1611 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1613 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1615 // Tap away from the start position.
1616 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1618 // Render and notify
1619 application.SendNotification();
1620 application.Render();
1622 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1624 DALI_TEST_CHECK( position5.x > position4.x );
1626 // Remove all the text.
1627 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1629 editor.SetProperty( TextEditor::Property::TEXT, "" );
1631 // Render and notify
1632 application.SendNotification();
1633 application.Render();
1635 // Cursor position should be the same than position2.
1636 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1638 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1640 // Should not be a renderer.
1641 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1646 int utcDaliTextEditorEvent03(void)
1648 ToolkitTestApplication application;
1649 tet_infoline(" utcDaliTextEditorEvent03");
1651 // Checks if the highlight actor is created.
1653 TextEditor editor = TextEditor::New();
1654 DALI_TEST_CHECK( editor );
1656 application.GetScene().Add( editor );
1658 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1659 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1660 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1661 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1662 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1664 // Avoid a crash when core load gl resources.
1665 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1667 // Render and notify
1668 application.SendNotification();
1669 application.Render();
1671 // Send some taps and check text controller with clipboard window
1672 Dali::Clipboard clipboard = Clipboard::Get();
1673 clipboard.ShowClipboard();
1674 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1675 clipboard.HideClipboard();
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 // Tap first to get the focus.
1682 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1684 // Render and notify
1685 application.SendNotification();
1686 application.Render();
1688 // Double tap to select a word.
1689 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 // The stencil actor should have two actors: the renderer and the highlight actor.
1696 Actor stencil = editor.GetChildAt( 0u );
1698 // Highlight needs to be drawn before text, so should come first in child order
1699 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1700 DALI_TEST_CHECK( highlight );
1702 // The stencil actor has a container with all the actors which contain the text renderers.
1703 Actor container = stencil.GetChildAt( 1u );
1704 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1706 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1707 DALI_TEST_CHECK( renderer );
1710 // Double tap out of bounds
1711 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1712 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // The stencil actor should have one actors: the renderer actor.
1719 stencil = editor.GetChildAt( 0u );
1721 // The stencil actor has a container with all the actors which contain the text renderers.
1722 container = stencil.GetChildAt( 0u );
1723 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1725 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1726 DALI_TEST_CHECK( renderer );
1730 TestGenerateLongPress(application, 1.0f, 25.0f);
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1739 int utcDaliTextEditorEvent04(void)
1741 ToolkitTestApplication application;
1742 tet_infoline(" utcDaliTextEditorEvent04");
1744 // Checks if the highlight actor is created.
1746 TextEditor editor = TextEditor::New();
1747 DALI_TEST_CHECK( editor );
1749 application.GetScene().Add( editor );
1751 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1752 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1753 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1754 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1755 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1757 // Avoid a crash when core load gl resources.
1758 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1760 // Render and notify
1761 application.SendNotification();
1762 application.Render();
1764 // Tap on the text editor
1765 TestGenerateTap( application, 3.0f, 25.0f );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
1771 // Move at the end of the text.
1772 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 for( unsigned int index = 0u; index < 10u; ++index )
1781 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1782 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1790 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1792 // Render and notify
1793 application.SendNotification();
1794 application.Render();
1796 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1798 // Add some key events
1799 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1800 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1802 // Render and notify
1803 application.SendNotification();
1804 application.Render();
1806 for( unsigned int index = 0u; index < 10u; ++index )
1808 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1809 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1811 // Render and notify
1812 application.SendNotification();
1813 application.Render();
1817 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819 // Render and notify
1820 application.SendNotification();
1821 application.Render();
1823 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1828 int utcDaliTextEditorEvent05(void)
1830 ToolkitTestApplication application;
1831 tet_infoline(" utcDaliTextEditorEvent05");
1833 // Checks if the highlight actor is created.
1835 TextEditor editor = TextEditor::New();
1836 DALI_TEST_CHECK( editor );
1838 application.GetScene().Add( editor );
1840 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1841 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1842 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1843 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1844 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1845 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1846 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1847 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1848 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1849 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1851 // Avoid a crash when core load gl resources.
1852 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1858 // Tap on the text editor
1859 TestGenerateTap( application, 3.0f, 25.0f );
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1865 // Move at the end of the text.
1866 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1867 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1869 // Render and notify
1870 application.SendNotification();
1871 application.Render();
1873 for( unsigned int index = 0u; index < 10u; ++index )
1876 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1878 // Render and notify
1879 application.SendNotification();
1880 application.Render();
1882 // Modify duration after scroll is enabled
1883 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1885 // Continuous scroll left to increase coverage
1886 for( unsigned int index = 0u; index < 10u; ++index )
1888 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1890 // Render and notify
1891 application.SendNotification();
1892 application.Render();
1894 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1895 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1896 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1897 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1898 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1900 // Press Escape to increase coverage
1901 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902 application.SendNotification();
1903 application.Render();
1905 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1910 int utcDaliTextEditorEvent06(void)
1912 ToolkitTestApplication application;
1913 tet_infoline(" utcDaliTextEditorEvent06");
1915 // Checks if the highlight actor is created.
1917 TextEditor editor = TextEditor::New();
1918 DALI_TEST_CHECK( editor );
1920 application.GetScene().Add( editor );
1922 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1923 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1924 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1925 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1926 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1928 // Avoid a crash when core load gl resources.
1929 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1931 // Render and notify
1932 application.SendNotification();
1933 application.Render();
1935 // Tap on the text editor
1936 TestGenerateTap( application, 3.0f, 25.0f );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 // Move to seconds line of the text.
1943 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 float layoutHeight = editor.GetHeightForWidth( 100.f );
1952 // Add another script characters ( glyph height is defferent )
1953 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1954 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1956 // Delete characters
1957 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1958 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1960 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1962 // Render and notify
1963 application.SendNotification();
1964 application.Render();
1966 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1969 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1970 application.SendNotification();
1971 application.Render();
1973 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1974 application.SendNotification();
1975 application.Render();
1977 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1978 application.SendNotification();
1979 application.Render();
1981 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1982 application.SendNotification();
1983 application.Render();
1985 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1986 application.SendNotification();
1987 application.Render();
1989 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1990 application.SendNotification();
1991 application.Render();
1993 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1994 application.SendNotification();
1995 application.Render();
2000 int utcDaliTextEditorEvent07(void)
2002 ToolkitTestApplication application;
2003 tet_infoline(" utcDaliTextEditorEvent07");
2005 // Checks if the highlight actor is created.
2007 TextEditor editor = TextEditor::New();
2008 DALI_TEST_CHECK( editor );
2010 application.GetScene().Add( editor );
2012 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2013 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2014 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2015 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2016 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2018 // Avoid a crash when core load gl resources.
2019 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2021 // Render and notify
2022 application.SendNotification();
2023 application.Render();
2025 // Tap on the text editor
2026 TestGenerateTap( application, 3.0f, 25.0f );
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2032 // Move to second line of the text.
2033 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2035 // Render and notify
2036 application.SendNotification();
2037 application.Render();
2039 // Select some text in the right of the current cursor position
2040 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2041 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2043 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Cut the selected text
2050 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 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 ) );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2059 // Select some text in the left of the current cursor position
2060 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2061 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2063 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2069 // Copy the selected text
2070 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2071 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 ) );
2073 // Render and notify
2074 application.SendNotification();
2075 application.Render();
2077 // Move the cursor to the third line
2078 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2079 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081 // Render and notify
2082 application.SendNotification();
2083 application.Render();
2085 // Paste the selected text at the current cursor position
2086 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2087 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 ) );
2089 // Render and notify
2090 application.SendNotification();
2091 application.Render();
2093 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2096 // Disable Shift Selection
2097 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2099 // Test to select some text in the right of the current cursor position
2100 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2102 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2103 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2109 // Cut the selected text
2110 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2111 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2113 // Render and notify
2114 application.SendNotification();
2115 application.Render();
2117 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2118 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2120 // Test to select some text in the left of the current cursor position
2121 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2122 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2123 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2124 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2126 // Render and notify
2127 application.SendNotification();
2128 application.Render();
2130 // Copy the selected text
2131 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2132 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 ) );
2134 // Render and notify
2135 application.SendNotification();
2136 application.Render();
2138 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2139 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2144 int utcDaliTextEditorEvent08(void)
2146 ToolkitTestApplication application;
2147 tet_infoline(" utcDaliTextEditorEvent08");
2149 // Checks if the highlight actor is released correctly.
2151 TextEditor editor = TextEditor::New();
2152 DALI_TEST_CHECK( editor );
2154 application.GetScene().Add( editor );
2156 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2157 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2158 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2159 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2160 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2162 // Avoid a crash when core load gl resources.
2163 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2165 // Render and notify
2166 application.SendNotification();
2167 application.Render();
2169 // Tap on the text editor
2170 TestGenerateTap( application, 3.0f, 25.0f );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2177 // Test to select some text in the left of the current cursor position
2178 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2179 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2180 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2181 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2183 // Render and notify
2184 application.SendNotification();
2185 application.Render();
2187 // Test to the left selection handle position and the right selection handle position
2188 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 // Render and notify
2194 application.SendNotification();
2195 application.Render();
2197 // Test to select full text in the left of the current cursor position
2198 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2199 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2200 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2201 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // Test to release the current full text selection
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 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 to move the current cursor position correctly
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( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2233 // Test to select some text in the right 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_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2238 // Render and notify
2239 application.SendNotification();
2240 application.Render();
2242 // Test the cursor position with right arrow key
2243 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2245 // Render and notify
2246 application.SendNotification();
2247 application.Render();
2250 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2252 // Render and notify
2253 application.SendNotification();
2254 application.Render();
2256 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2258 // Test to select some text in the left of the current cursor position
2259 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2260 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2261 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265 // Render and notify
2266 application.SendNotification();
2267 application.Render();
2269 // Test the cursor position with left arrow key
2270 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 // Render and notify
2273 application.SendNotification();
2274 application.Render();
2277 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2285 // Test to select some text in the right of the current cursor position
2286 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2287 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 // Render and notify
2292 application.SendNotification();
2293 application.Render();
2295 // Test the cursor position with left arrow key
2296 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 // Render and notify
2299 application.SendNotification();
2300 application.Render();
2303 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2311 // Test to select some text in the left of the current cursor position
2312 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 // Test the cursor position with right arrow key
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 // Render and notify
2325 application.SendNotification();
2326 application.Render();
2329 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
2335 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2340 int utcDaliTextEditorHandles(void)
2342 ToolkitTestApplication application;
2343 tet_infoline(" utcDaliTextEditorHandles");
2345 TextEditor editor = TextEditor::New();
2346 DALI_TEST_CHECK( editor );
2348 application.GetScene().Add( editor );
2350 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2351 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2352 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2353 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2355 Property::Map imagePropertyMap;
2356 imagePropertyMap["type"] = "BufferImage";
2357 imagePropertyMap["width"] = 40;
2358 imagePropertyMap["height"] = 40;
2360 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2361 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2362 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2363 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2365 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2366 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2367 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2369 // Avoid a crash when core load gl resources.
2370 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 // Tap first to get the focus.
2377 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2379 // Render and notify
2380 application.SendNotification();
2381 application.Render();
2383 // Tap to create the grab handle.
2384 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // Get the active layer where the text's decoration is added.
2391 Actor activeLayer = editor.GetChildAt( 1u );
2393 // Get the handle's actor.
2394 Actor handle = activeLayer.GetChildAt( 1u );
2395 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2397 // Render and notify
2398 application.SendNotification();
2399 application.Render();
2401 // Touch the grab handle to set it as pressed.
2402 Vector2 touchPos( 10.0f, 50.0f );
2403 Dali::Integration::TouchEvent event;
2404 event = Dali::Integration::TouchEvent();
2405 event.AddPoint( GetPointDownInside( touchPos ) );
2406 application.ProcessEvent( event );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 // Release the grab handle.
2413 event = Dali::Integration::TouchEvent();
2414 event.AddPoint( GetPointUpInside( touchPos ) );
2415 application.ProcessEvent( event );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 // Tap first to get the focus.
2422 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2428 // Double tap to select a word and create the selection handles.
2429 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2431 // Render and notify
2432 application.SendNotification();
2433 application.Render();
2435 touchPos = Vector2( 10.0f, 50.0f );
2437 // Touch the left selection handle to set it as pressed.
2438 event = Dali::Integration::TouchEvent();
2439 event.AddPoint( GetPointDownInside( touchPos ) );
2440 application.ProcessEvent( event );
2442 // Render and notify
2443 application.SendNotification();
2444 application.Render();
2446 // Release the left selection handle.
2447 event = Dali::Integration::TouchEvent();
2448 event.AddPoint( GetPointUpInside( touchPos ) );
2449 application.ProcessEvent( event );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2458 int utcDaliTextEditorUnderPropertyStringP(void)
2460 ToolkitTestApplication application;
2461 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2462 TextEditor editor = TextEditor::New();
2463 DALI_TEST_CHECK( editor );
2465 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2467 application.GetScene().Add( editor );
2469 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2470 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2472 tet_infoline("Set underline settings with a map");
2473 // Check the input underline property
2474 Property::Map underlineMapSet;
2475 Property::Map underlineMapGet;
2476 underlineMapSet.Insert( "enable", true );
2477 underlineMapSet.Insert( "color", Color::BLUE );
2478 underlineMapSet.Insert( "height", 2 );
2480 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2481 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2482 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2483 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2485 tet_infoline("Set underline settings with a string");
2486 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2487 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2490 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2492 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2493 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2494 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2495 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2497 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2502 int utcDaliTextEditorShadowPropertyStringP(void)
2504 ToolkitTestApplication application;
2505 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2507 TextEditor editor = TextEditor::New();
2509 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2511 application.GetScene().Add( editor );
2513 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2515 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2519 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2524 int utcDaliTextEditorFontStylePropertyStringP(void)
2526 ToolkitTestApplication application;
2527 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2529 TextEditor editor = TextEditor::New();
2531 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2533 application.GetScene().Add( editor );
2535 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2537 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2541 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2546 int utcDaliTextEditorGetPropertyLinecountP(void)
2548 ToolkitTestApplication application;
2550 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2554 TextEditor editor = TextEditor::New();
2555 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2556 editor.SetProperty( TextEditor::Property::TEXT,
2557 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2559 application.GetScene().Add( editor );
2561 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2562 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2563 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2565 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2566 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2567 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2572 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2575 ToolkitTestApplication application;
2576 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2578 TextEditor editor = TextEditor::New();
2579 DALI_TEST_CHECK( editor );
2581 application.GetScene().Add( editor );
2583 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2584 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2585 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2586 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2587 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2588 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2590 bool startedCalled = false;
2591 bool finishedCalled = false;
2593 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2594 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2596 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2598 // Render and notify
2599 application.SendNotification();
2600 application.Render();
2602 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2603 application.SendNotification();
2604 application.Render(6000);
2606 application.SendNotification();
2607 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2608 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2613 int UtcDaliToolkitTextEditorTextWrapMode(void)
2615 ToolkitTestApplication application;
2616 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2620 TextEditor editor = TextEditor::New();
2621 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2622 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2624 application.GetScene().Add( editor );
2626 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2627 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2629 application.SendNotification();
2630 application.Render();
2632 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2633 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2635 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2636 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2638 application.SendNotification();
2639 application.Render();
2641 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2642 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2644 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2645 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2647 application.SendNotification();
2648 application.Render();
2650 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2651 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2653 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2654 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2656 application.SendNotification();
2657 application.Render();
2659 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2660 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2665 int UtcDaliTextEditorSetPaddingProperty(void)
2667 ToolkitTestApplication application;
2668 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2670 TextEditor editor = TextEditor::New();
2671 DALI_TEST_CHECK( editor );
2672 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2673 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2674 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2675 application.GetScene().Add( editor );
2677 application.SendNotification();
2678 application.Render();
2680 Vector3 originalSize = editor.GetNaturalSize();
2682 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2684 application.SendNotification();
2685 application.Render();
2687 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2689 Vector3 paddingAddedSize = editor.GetNaturalSize();
2691 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2693 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2698 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2700 ToolkitTestApplication application;
2701 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2703 TextEditor editor = TextEditor::New();
2704 DALI_TEST_CHECK( editor );
2705 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2706 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2707 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2708 application.GetScene().Add( editor );
2710 application.SendNotification();
2711 application.Render();
2713 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2714 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2716 // Check the enable shift selection property
2717 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2718 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2720 application.SendNotification();
2721 application.Render();
2726 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2728 ToolkitTestApplication application;
2729 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2731 TextEditor editor = TextEditor::New();
2732 DALI_TEST_CHECK( editor );
2733 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2734 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2735 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2736 application.GetScene().Add( editor );
2738 application.SendNotification();
2739 application.Render();
2741 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2742 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2744 // Check the enable grab handle property
2745 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2746 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2748 application.SendNotification();
2749 application.Render();
2754 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2756 ToolkitTestApplication application;
2757 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2759 TextEditor editor = TextEditor::New();
2760 DALI_TEST_CHECK( editor );
2761 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2762 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2763 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2764 application.GetScene().Add( editor );
2766 application.SendNotification();
2767 application.Render();
2769 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2770 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2772 // Check the enable match system language direction property
2773 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2774 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2776 application.SendNotification();
2777 application.Render();
2782 int UtcDaliTextEditorGetInputMethodContext(void)
2784 ToolkitTestApplication application;
2785 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2787 TextEditor editor = TextEditor::New();
2788 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );