2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
102 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
103 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
104 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
105 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
108 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
109 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const unsigned int DEFAULT_FONT_SIZE = 1152u;
114 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
116 const int KEY_A_CODE = 38;
117 const int KEY_D_CODE = 40;
118 const int KEY_C_CODE = 54;
119 const int KEY_V_CODE = 55;
120 const int KEY_X_CODE = 53;
121 const int KEY_WHITE_SPACE_CODE = 65;
123 const int KEY_SHIFT_MODIFIER = 257;
124 const int KEY_CONTROL_MODIFIER = 258;
126 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
127 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
128 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
130 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
132 static bool gTextChangedCallBackCalled;
133 static bool gInputStyleChangedCallbackCalled;
134 static bool gMaxCharactersCallBackCalled;
135 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
137 struct CallbackFunctor
139 CallbackFunctor(bool* callbackFlag)
140 : mCallbackFlag( callbackFlag )
146 *mCallbackFlag = true;
151 static void TestTextChangedCallback( TextEditor control )
153 tet_infoline(" TestTextChangedCallback");
155 gTextChangedCallBackCalled = true;
158 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
160 tet_infoline(" TestInputStyleChangedCallback");
162 gInputStyleChangedCallbackCalled = true;
163 gInputStyleMask = mask;
166 static void TestMaxLengthReachedCallback( TextEditor control )
168 tet_infoline(" TestMaxLengthReachedCallback");
170 gMaxCharactersCallBackCalled = true;
173 // Generate a KeyEvent to send to Core.
174 Integration::KeyEvent GenerateKey( const std::string& keyName,
175 const std::string& logicalKey,
176 const std::string& keyString,
179 unsigned long timeStamp,
180 const Integration::KeyEvent::State& keyState,
181 const std::string& compose = "",
182 const std::string& deviceName = DEFAULT_DEVICE_NAME,
183 const Device::Class::Type& deviceClass = Device::Class::NONE,
184 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
186 return Integration::KeyEvent( keyName,
199 Dali::Integration::Point GetPointDownInside( Vector2& pos )
201 Dali::Integration::Point point;
202 point.SetState( PointState::DOWN );
203 point.SetScreenPosition( pos );
207 Dali::Integration::Point GetPointUpInside( Vector2& pos )
209 Dali::Integration::Point point;
210 point.SetState( PointState::UP );
211 point.SetScreenPosition( pos );
215 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
217 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
219 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
221 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
223 Property::Value* valueSet = NULL;
224 if ( valueGet.first.type == Property::Key::INDEX )
226 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
230 // Get Key is a string so searching Set Map for a string key
231 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
234 if( NULL != valueSet )
236 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
238 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
241 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
243 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
246 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
248 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
251 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
253 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
256 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
258 Vector2 vector2Get = valueGet.second.Get<Vector2>();
259 Vector2 vector2Set = valueSet->Get<Vector2>();
260 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
263 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
265 Vector4 vector4Get = valueGet.second.Get<Vector4>();
266 Vector4 vector4Set = valueSet->Get<Vector4>();
267 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
273 if ( valueGet.first.type == Property::Key::INDEX )
275 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
279 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
289 class ScrollStateChangeCallback : public Dali::ConnectionTracker
292 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
293 : mStartedCalled( startedCalled ),
294 mFinishedCalled( finishedCalled )
298 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
300 if( type == TextEditor::Scroll::STARTED )
302 mStartedCalled = true;
304 else if( type == TextEditor::Scroll::FINISHED )
306 mFinishedCalled = true;
310 bool& mStartedCalled;
311 bool& mFinishedCalled;
316 int UtcDaliToolkitTextEditorConstructorP(void)
318 ToolkitTestApplication application;
319 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
320 TextEditor textEditor;
321 DALI_TEST_CHECK( !textEditor );
325 int UtcDaliToolkitTextEditorNewP(void)
327 ToolkitTestApplication application;
328 tet_infoline(" UtcDaliToolkitTextEditorNewP");
329 TextEditor textEditor = TextEditor::New();
330 DALI_TEST_CHECK( textEditor );
334 int UtcDaliToolkitTextEditorDownCastP(void)
336 ToolkitTestApplication application;
337 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
338 TextEditor textEditor1 = TextEditor::New();
339 BaseHandle object( textEditor1 );
341 TextEditor textEditor2 = TextEditor::DownCast( object );
342 DALI_TEST_CHECK( textEditor2 );
344 TextEditor textEditor3 = DownCast< TextEditor >( object );
345 DALI_TEST_CHECK( textEditor3 );
349 int UtcDaliToolkitTextEditorDownCastN(void)
351 ToolkitTestApplication application;
352 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
353 BaseHandle uninitializedObject;
354 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
355 DALI_TEST_CHECK( !textEditor1 );
357 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
358 DALI_TEST_CHECK( !textEditor2 );
362 int UtcDaliToolkitTextEditorCopyConstructorP(void)
364 ToolkitTestApplication application;
365 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
366 TextEditor textEditor = TextEditor::New();
367 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
369 TextEditor copy( textEditor );
370 DALI_TEST_CHECK( copy );
371 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
375 int UtcDaliTextEditorMoveConstructor(void)
377 ToolkitTestApplication application;
379 TextEditor textEditor = TextEditor::New();
380 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
381 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
383 TextEditor moved = std::move( textEditor );
384 DALI_TEST_CHECK( moved );
385 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
386 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
387 DALI_TEST_CHECK( !textEditor );
392 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
394 ToolkitTestApplication application;
395 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
396 TextEditor textEditor = TextEditor::New();
397 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
399 TextEditor copy = textEditor;
400 DALI_TEST_CHECK( copy );
401 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
405 int UtcDaliTextEditorMoveAssignment(void)
407 ToolkitTestApplication application;
409 TextEditor textEditor = TextEditor::New();
410 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
411 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
414 moved = std::move( textEditor );
415 DALI_TEST_CHECK( moved );
416 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
417 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
418 DALI_TEST_CHECK( !textEditor );
423 int UtcDaliTextEditorNewP(void)
425 ToolkitTestApplication application;
426 tet_infoline(" UtcDaliToolkitTextEditorNewP");
427 TextEditor textEditor = TextEditor::New();
428 DALI_TEST_CHECK( textEditor );
432 // Positive test case for a method
433 int UtcDaliTextEditorGetPropertyP(void)
435 ToolkitTestApplication application;
436 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
437 TextEditor editor = TextEditor::New();
438 DALI_TEST_CHECK( editor );
440 // Check Property Indices are correct
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
503 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
506 Property::Map imageMap;
507 imageMap[mapKey] =mapValue;
509 editor.SetProperty( property , imageMap );
510 Property::Value propValue = editor.GetProperty( property );
511 Property::Map* resultMap = propValue.GetMap();
513 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
521 // Positive test case for a method
522 int UtcDaliTextEditorSetPropertyP(void)
524 ToolkitTestApplication application;
525 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
526 TextEditor editor = TextEditor::New();
527 DALI_TEST_CHECK( editor );
528 application.GetScene().Add( editor );
530 // Note - we can't check the defaults since the stylesheets are platform-specific
532 // Check the render backend property.
533 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
534 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
536 // Check text property.
537 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
538 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
540 // Check text's color property
541 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
542 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
544 // Check font properties.
545 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
546 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
548 Property::Map fontStyleMapSet;
549 Property::Map fontStyleMapGet;
550 Property::Value* slantValue = NULL;
552 fontStyleMapSet.Insert( "weight", "bold" );
553 fontStyleMapSet.Insert( "width", "condensed" );
554 fontStyleMapSet.Insert( "slant", "italic" );
556 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
557 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
558 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
559 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
561 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
562 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
564 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
565 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
566 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
569 fontStyleMapSet.Clear();
570 fontStyleMapSet.Insert( "weight", "normal" );
571 fontStyleMapSet.Insert( "slant", "oblique" );
572 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
574 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
575 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
577 fontStyleMapSet.Clear();
578 fontStyleMapSet.Insert( "slant", "roman" );
579 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
580 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
582 // Replace 'roman' for 'normal'.
583 slantValue = fontStyleMapGet.Find( "slant" );
584 if( NULL != slantValue )
586 if( "normal" == slantValue->Get<std::string>() )
588 fontStyleMapGet["slant"] = "roman";
591 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
594 fontStyleMapSet.Clear();
596 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
597 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
598 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
599 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
601 // Check that the Alignment properties can be correctly set
602 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
603 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
605 // Check scroll properties.
606 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
607 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
608 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
609 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
611 // Check cursor properties
612 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
613 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
614 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
615 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
617 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
618 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
619 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
620 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
621 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
622 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
624 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
626 // Check handle images
627 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
628 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
629 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
630 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
631 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
633 // Check handle images
634 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
635 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
641 // Check the highlight color
642 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
643 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
645 // Decoration bounding box
646 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
647 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
649 // Check the enable markup property.
650 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
651 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
652 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
654 // Check input color property.
655 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
656 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
658 // Check input font properties.
659 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
660 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
662 fontStyleMapSet.Clear();
663 fontStyleMapSet.Insert( "weight", "bold" );
664 fontStyleMapSet.Insert( "width", "condensed" );
665 fontStyleMapSet.Insert( "slant", "italic" );
667 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
668 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
669 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
670 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
672 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
673 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
675 // Reset input font style.
676 fontStyleMapSet.Clear();
677 fontStyleMapSet.Insert( "weight", "normal" );
678 fontStyleMapSet.Insert( "slant", "oblique" );
680 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
681 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
682 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
683 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
685 fontStyleMapSet.Clear();
686 fontStyleMapSet.Insert( "slant", "roman" );
688 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
689 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
691 // Replace 'roman' for 'normal'.
692 slantValue = fontStyleMapGet.Find( "slant" );
693 if( NULL != slantValue )
695 if( "normal" == slantValue->Get<std::string>() )
697 fontStyleMapGet["slant"] = "roman";
700 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
701 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
703 fontStyleMapSet.Clear();
705 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
706 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
707 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
708 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
710 // Check the line spacing property
711 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
712 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
713 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715 // Check the input line spacing property
716 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
718 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
720 // Check the underline property
722 Property::Map underlineMapSet;
723 Property::Map underlineMapGet;
725 underlineMapSet.Insert( "enable", true );
726 underlineMapSet.Insert( "color", Color::RED );
727 underlineMapSet.Insert( "height", 1 );
729 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
731 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
732 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
733 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
735 // Check the input underline property
736 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
737 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
739 // Check the shadow property
740 Property::Map shadowMapSet;
741 Property::Map shadowMapGet;
743 shadowMapSet.Insert( "color", Color::GREEN );
744 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
745 shadowMapSet.Insert( "blurRadius", 3.0f );
747 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
749 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
750 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
751 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
753 // Check the input shadow property
754 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
755 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
757 // Check the emboss property
758 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
759 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
761 // Check the input emboss property
762 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
763 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
765 // Check the outline property
767 // Test string type first
768 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
769 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
770 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
772 // Then test the property map type
773 Property::Map outlineMapSet;
774 Property::Map outlineMapGet;
776 outlineMapSet["color"] = Color::RED;
777 outlineMapSet["width"] = 2.0f;
779 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
781 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
782 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
783 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
785 // Check the input outline property
786 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
787 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
789 // Check the smooth scroll property
790 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
791 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
792 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
794 // Check the smooth scroll duration property
795 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
796 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
798 // Check the scroll bar property
799 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
800 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
801 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
803 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
804 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
805 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
806 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
808 // Check the pixel size of font
809 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
810 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
812 // Check placeholder text properties.
813 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
814 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
816 // Check placeholder text's color property.
817 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
818 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
820 // Check the enable selection property
821 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
822 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
824 // Check the placeholder property with pixel size
825 Property::Map placeholderPixelSizeMapSet;
826 Property::Map placeholderPixelSizeMapGet;
827 Property::Map placeholderFontstyleMap;
828 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
829 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
830 placeholderPixelSizeMapSet["color"] = Color::BLUE;
831 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
832 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
834 placeholderFontstyleMap.Insert( "weight", "bold" );
835 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
836 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
838 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
839 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
841 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
842 Property::Map placeholderConversionMap;
843 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
844 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
845 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
846 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
847 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
848 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
850 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
852 // Check the placeholder property with point size
853 Property::Map placeholderMapSet;
854 Property::Map placeholderMapGet;
855 placeholderMapSet["text"] = "Setting Placeholder Text";
856 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
857 placeholderMapSet["color"] = Color::RED;
858 placeholderMapSet["fontFamily"] = "Arial";
859 placeholderMapSet["pointSize"] = 12.0f;
860 // Check the placeholder font style property
861 placeholderFontstyleMap.Clear();
863 placeholderFontstyleMap.Insert( "weight", "bold" );
864 placeholderFontstyleMap.Insert( "width", "condensed" );
865 placeholderFontstyleMap.Insert( "slant", "italic" );
866 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
867 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
869 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
870 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
872 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
873 placeholderConversionMap.Clear();
874 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
875 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
876 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
877 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
878 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
879 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
880 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
883 placeholderFontstyleMap.Clear();
884 placeholderFontstyleMap.Insert( "weight", "normal" );
885 placeholderFontstyleMap.Insert( "slant", "oblique" );
886 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
887 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
889 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
890 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
891 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
892 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
894 placeholderFontstyleMap.Clear();
895 placeholderFontstyleMap.Insert( "slant", "roman" );
896 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
897 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
899 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
901 placeholderFontstyleMap.Clear();
902 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
904 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
905 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
906 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
907 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
908 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
910 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
911 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
913 application.SendNotification();
914 application.Render();
919 // Positive Atlas Text Renderer test
920 int utcDaliTextEditorAtlasRenderP(void)
922 ToolkitTestApplication application;
923 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
924 StyleManager styleManager = StyleManager::Get();
925 styleManager.ApplyDefaultTheme();
926 TextEditor editor = TextEditor::New();
927 DALI_TEST_CHECK( editor );
929 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
931 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
933 application.GetScene().Add( editor );
937 // Render some text with the shared atlas backend
938 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
939 application.SendNotification();
940 application.Render();
944 tet_result(TET_FAIL);
949 // Positive test for the textChanged signal.
950 int utcDaliTextEditorTextChangedP(void)
952 ToolkitTestApplication application;
953 tet_infoline(" utcDaliTextEditorTextChangedP");
954 TextEditor editor = TextEditor::New();
955 DALI_TEST_CHECK( editor );
957 application.GetScene().Add( editor );
959 // connect to the text changed signal.
960 ConnectionTracker* testTracker = new ConnectionTracker();
961 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
962 bool textChangedSignal = false;
963 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
965 gTextChangedCallBackCalled = false;
966 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
967 DALI_TEST_CHECK( gTextChangedCallBackCalled );
968 DALI_TEST_CHECK( textChangedSignal );
970 application.SendNotification();
972 editor.SetKeyInputFocus();
974 gTextChangedCallBackCalled = false;
975 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
976 DALI_TEST_CHECK( gTextChangedCallBackCalled );
979 editor.SetProperty( TextField::Property::TEXT, "" );
981 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
982 gTextChangedCallBackCalled = false;
983 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
984 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
986 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
987 gTextChangedCallBackCalled = false;
988 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
989 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
994 int utcDaliTextEditorInputStyleChanged01(void)
996 // The text-editor emits signals when the input style changes. These changes of style are
997 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
998 // can't be emitted during the size negotiation as the callbacks may update the UI.
999 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1000 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1001 ToolkitTestApplication application;
1002 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1006 char* pathNamePtr = get_current_dir_name();
1007 const std::string pathName( pathNamePtr );
1008 free( pathNamePtr );
1010 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1011 fontClient.SetDpi( 93u, 93u );
1013 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1014 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1016 TextEditor editor = TextEditor::New();
1017 DALI_TEST_CHECK( editor );
1020 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1021 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1022 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1024 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1025 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1027 // connect to the text changed signal.
1028 ConnectionTracker* testTracker = new ConnectionTracker();
1029 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1030 bool inputStyleChangedSignal = false;
1031 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1033 application.GetScene().Add( editor );
1035 // Render and notify
1036 application.SendNotification();
1037 application.Render();
1039 // Executes the idle callbacks added by the text control on the change of input style.
1040 application.RunIdles();
1042 gInputStyleChangedCallbackCalled = false;
1043 gInputStyleMask = TextEditor::InputStyle::NONE;
1044 inputStyleChangedSignal = false;
1046 // Create a tap event to touch the text editor.
1047 TestGenerateTap( application, 18.0f, 25.0f );
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Executes the idle callbacks added by the text control on the change of input style.
1054 application.RunIdles();
1056 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1057 if( gInputStyleChangedCallbackCalled )
1059 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1061 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1062 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1064 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1065 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1067 DALI_TEST_CHECK( inputStyleChangedSignal );
1069 gInputStyleChangedCallbackCalled = false;
1070 gInputStyleMask = TextEditor::InputStyle::NONE;
1071 inputStyleChangedSignal = false;
1073 // Create a tap event to touch the text editor.
1074 TestGenerateTap( application, 30.0f, 25.0f );
1076 // Render and notify
1077 application.SendNotification();
1078 application.Render();
1080 // Executes the idle callbacks added by the text control on the change of input style.
1081 application.RunIdles();
1083 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1084 DALI_TEST_CHECK( !inputStyleChangedSignal );
1086 gInputStyleChangedCallbackCalled = false;
1087 gInputStyleMask = TextEditor::InputStyle::NONE;
1088 inputStyleChangedSignal = false;
1090 // Create a tap event to touch the text editor.
1091 TestGenerateTap( application, 43.0f, 25.0f );
1093 // Render and notify
1094 application.SendNotification();
1095 application.Render();
1097 // Executes the idle callbacks added by the text control on the change of input style.
1098 application.RunIdles();
1100 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1101 if( gInputStyleChangedCallbackCalled )
1103 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1105 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1106 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1108 DALI_TEST_CHECK( inputStyleChangedSignal );
1110 gInputStyleChangedCallbackCalled = false;
1111 gInputStyleMask = TextEditor::InputStyle::NONE;
1112 inputStyleChangedSignal = false;
1114 // Create a tap event to touch the text editor.
1115 TestGenerateTap( application, 88.0f, 25.0f );
1117 // Render and notify
1118 application.SendNotification();
1119 application.Render();
1121 // Executes the idle callbacks added by the text control on the change of input style.
1122 application.RunIdles();
1124 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1125 if( gInputStyleChangedCallbackCalled )
1127 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1129 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1130 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1132 Property::Map fontStyleMapSet;
1133 Property::Map fontStyleMapGet;
1135 fontStyleMapSet.Insert( "weight", "bold" );
1137 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1138 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1139 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1141 DALI_TEST_CHECK( inputStyleChangedSignal );
1143 gInputStyleChangedCallbackCalled = false;
1144 gInputStyleMask = TextEditor::InputStyle::NONE;
1145 inputStyleChangedSignal = false;
1147 // Create a tap event to touch the text editor.
1148 TestGenerateTap( application, 115.0f, 25.0f );
1150 // Render and notify
1151 application.SendNotification();
1152 application.Render();
1154 // Executes the idle callbacks added by the text control on the change of input style.
1155 application.RunIdles();
1157 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1158 DALI_TEST_CHECK( !inputStyleChangedSignal );
1160 gInputStyleChangedCallbackCalled = false;
1161 gInputStyleMask = TextEditor::InputStyle::NONE;
1162 inputStyleChangedSignal = false;
1164 // Create a tap event to touch the text editor.
1165 TestGenerateTap( application, 164.0f, 25.0f );
1167 // Render and notify
1168 application.SendNotification();
1169 application.Render();
1171 // Executes the idle callbacks added by the text control on the change of input style.
1172 application.RunIdles();
1174 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1175 if( gInputStyleChangedCallbackCalled )
1177 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1179 Property::Map fontStyleMapSet;
1180 Property::Map fontStyleMapGet;
1182 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1183 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1184 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1186 DALI_TEST_CHECK( inputStyleChangedSignal );
1188 gInputStyleChangedCallbackCalled = false;
1189 gInputStyleMask = TextEditor::InputStyle::NONE;
1190 inputStyleChangedSignal = false;
1192 // Create a tap event to touch the text editor.
1193 TestGenerateTap( application, 191.0f, 25.0f );
1195 // Render and notify
1196 application.SendNotification();
1197 application.Render();
1199 // Executes the idle callbacks added by the text control on the change of input style.
1200 application.RunIdles();
1202 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1203 DALI_TEST_CHECK( !inputStyleChangedSignal );
1208 int utcDaliTextEditorInputStyleChanged02(void)
1210 // The text-editor emits signals when the input style changes. These changes of style are
1211 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1212 // can't be emitted during the size negotiation as the callbacks may update the UI.
1213 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1214 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1215 ToolkitTestApplication application;
1216 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1220 char* pathNamePtr = get_current_dir_name();
1221 const std::string pathName( pathNamePtr );
1222 free( pathNamePtr );
1224 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1225 fontClient.SetDpi( 93u, 93u );
1227 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1228 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1230 TextEditor editor = TextEditor::New();
1231 DALI_TEST_CHECK( editor );
1234 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1235 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1236 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1238 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1239 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>" );
1241 // connect to the text changed signal.
1242 ConnectionTracker* testTracker = new ConnectionTracker();
1243 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1244 bool inputStyleChangedSignal = false;
1245 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1247 application.GetScene().Add( editor );
1249 // Render and notify
1250 application.SendNotification();
1251 application.Render();
1253 // Executes the idle callbacks added by the text control on the change of input style.
1254 application.RunIdles();
1256 gInputStyleChangedCallbackCalled = false;
1257 gInputStyleMask = TextEditor::InputStyle::NONE;
1258 inputStyleChangedSignal = false;
1260 // Create a tap event to touch the text editor.
1261 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1262 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1264 // Render and notify
1265 application.SendNotification();
1266 application.Render();
1268 // Executes the idle callbacks added by the text control on the change of input style.
1269 application.RunIdles();
1271 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1272 if( gInputStyleChangedCallbackCalled )
1274 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1275 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1276 TextEditor::InputStyle::POINT_SIZE |
1277 TextEditor::InputStyle::COLOR ),
1280 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1281 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1283 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1284 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1286 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1287 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1289 DALI_TEST_CHECK( inputStyleChangedSignal );
1291 gInputStyleChangedCallbackCalled = false;
1292 gInputStyleMask = TextEditor::InputStyle::NONE;
1293 inputStyleChangedSignal = false;
1295 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1297 // Render and notify
1298 application.SendNotification();
1299 application.Render();
1301 // Executes the idle callbacks added by the text control on the change of input style.
1302 application.RunIdles();
1304 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1305 if( gInputStyleChangedCallbackCalled )
1307 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1308 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1311 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1312 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1314 DALI_TEST_CHECK( inputStyleChangedSignal );
1316 gInputStyleChangedCallbackCalled = false;
1317 gInputStyleMask = TextEditor::InputStyle::NONE;
1318 inputStyleChangedSignal = false;
1320 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1322 // Render and notify
1323 application.SendNotification();
1324 application.Render();
1326 // Executes the idle callbacks added by the text control on the change of input style.
1327 application.RunIdles();
1329 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1330 DALI_TEST_CHECK( !inputStyleChangedSignal );
1332 gInputStyleChangedCallbackCalled = false;
1333 gInputStyleMask = TextEditor::InputStyle::NONE;
1334 inputStyleChangedSignal = false;
1336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Executes the idle callbacks added by the text control on the change of input style.
1343 application.RunIdles();
1345 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1346 if( gInputStyleChangedCallbackCalled )
1348 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1349 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1352 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1353 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1355 DALI_TEST_CHECK( inputStyleChangedSignal );
1357 gInputStyleChangedCallbackCalled = false;
1358 gInputStyleMask = TextEditor::InputStyle::NONE;
1359 inputStyleChangedSignal = false;
1361 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1363 Property::Map fontStyleMapSet;
1364 fontStyleMapSet.Insert( "weight", "thin" );
1365 fontStyleMapSet.Insert( "width", "condensed" );
1366 fontStyleMapSet.Insert( "slant", "italic" );
1368 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1369 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1370 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1372 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1373 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1374 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1375 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1377 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Executes the idle callbacks added by the text control on the change of input style.
1384 application.RunIdles();
1386 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1387 DALI_TEST_CHECK( !inputStyleChangedSignal );
1389 // Create a tap event to touch the text editor.
1390 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1392 // Render and notify
1393 application.SendNotification();
1394 application.Render();
1396 // Executes the idle callbacks added by the text control on the change of input style.
1397 application.RunIdles();
1399 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1400 if( gInputStyleChangedCallbackCalled )
1402 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1403 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1404 TextEditor::InputStyle::POINT_SIZE |
1405 TextEditor::InputStyle::FONT_STYLE |
1406 TextEditor::InputStyle::LINE_SPACING |
1407 TextEditor::InputStyle::UNDERLINE |
1408 TextEditor::InputStyle::SHADOW |
1409 TextEditor::InputStyle::EMBOSS |
1410 TextEditor::InputStyle::OUTLINE ),
1413 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1414 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1416 DALI_TEST_CHECK( inputStyleChangedSignal );
1418 gInputStyleChangedCallbackCalled = false;
1419 gInputStyleMask = TextEditor::InputStyle::NONE;
1420 inputStyleChangedSignal = false;
1422 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1424 fontStyleMapSet.Clear();
1425 fontStyleMapSet.Insert( "weight", "black" );
1426 fontStyleMapSet.Insert( "width", "expanded" );
1427 fontStyleMapSet.Insert( "slant", "oblique" );
1429 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1431 // Create a tap event to touch the text editor.
1432 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1434 // Render and notify
1435 application.SendNotification();
1436 application.Render();
1438 // Executes the idle callbacks added by the text control on the change of input style.
1439 application.RunIdles();
1441 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1442 if( gInputStyleChangedCallbackCalled )
1444 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1445 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1446 TextEditor::InputStyle::POINT_SIZE |
1447 TextEditor::InputStyle::FONT_STYLE ),
1450 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1451 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1453 DALI_TEST_CHECK( inputStyleChangedSignal );
1458 int utcDaliTextEditorEvent01(void)
1460 ToolkitTestApplication application;
1461 tet_infoline(" utcDaliTextEditorEvent01");
1463 // Creates a tap event. After creating a tap event the text editor should
1464 // have the focus and add text with key events should be possible.
1466 TextEditor editor = TextEditor::New();
1467 DALI_TEST_CHECK( editor );
1469 application.GetScene().Add( editor );
1471 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1472 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1473 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1475 // Avoid a crash when core load gl resources.
1476 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1478 // Render and notify
1479 application.SendNotification();
1480 application.Render();
1482 // Add a key event but as the text editor has not the focus it should do nothing.
1483 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1485 // Render and notify
1486 application.SendNotification();
1487 application.Render();
1489 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1491 // Create a tap event to touch the text editor.
1492 TestGenerateTap( application, 150.0f, 25.0f );
1494 // Render and notify
1495 application.SendNotification();
1496 application.Render();
1498 // Now the text editor has the focus, so it can handle the key events.
1499 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1500 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1502 // Render and notify
1503 application.SendNotification();
1504 application.Render();
1506 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1508 // Create a second text editor and send key events to it.
1509 TextEditor editor2 = TextEditor::New();
1511 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1512 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1513 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1514 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1516 application.GetScene().Add( editor2 );
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 // Create a tap event on the second text editor.
1523 TestGenerateTap( application, 150.0f, 125.0f );
1525 // Render and notify
1526 application.SendNotification();
1527 application.Render();
1529 // The second text editor has the focus. It should handle the key events.
1530 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1531 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Check the text has been added to the second text editor.
1538 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1543 int utcDaliTextEditorEvent02(void)
1545 ToolkitTestApplication application;
1546 tet_infoline(" utcDaliTextEditorEvent02");
1548 // Checks if the right number of actors are created.
1550 TextEditor editor = TextEditor::New();
1551 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1552 DALI_TEST_CHECK( editor );
1554 application.GetScene().Add( editor );
1556 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1557 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1558 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1560 // Avoid a crash when core load gl resources.
1561 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1563 // Render and notify
1564 application.SendNotification();
1565 application.Render();
1567 // Check there are the expected number of children (the stencil).
1568 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1570 Actor stencil = editor.GetChildAt( 0u );
1572 // Create a tap event to touch the text editor.
1573 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1575 // Render and notify
1576 application.SendNotification();
1577 application.Render();
1579 Actor layer = editor.GetChildAt( 1u );
1580 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1581 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1583 // Now the text editor has the focus, so it can handle the key events.
1584 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1585 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1587 // Render and notify
1588 application.SendNotification();
1589 application.Render();
1591 // Checks the cursor and the renderer have been created.
1592 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1593 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1595 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1596 DALI_TEST_CHECK( cursor );
1598 // The stencil actor has a container with all the actors which contain the text renderers.
1599 Actor container = stencil.GetChildAt( 0u );
1600 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1602 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1603 DALI_TEST_CHECK( renderer );
1606 // Move the cursor and check the position changes.
1607 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1609 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1610 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1612 // Render and notify
1613 application.SendNotification();
1614 application.Render();
1616 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1618 DALI_TEST_CHECK( position2.x < position1.x );
1620 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1621 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1623 // Render and notify
1624 application.SendNotification();
1625 application.Render();
1627 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1629 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1631 // Send some taps and check the cursor positions.
1633 // Try to tap at the beginning.
1634 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Cursor position should be the same than position1.
1641 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1643 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1645 // Tap away from the start position.
1646 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1648 // Render and notify
1649 application.SendNotification();
1650 application.Render();
1652 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1654 DALI_TEST_CHECK( position5.x > position4.x );
1656 // Remove all the text.
1657 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1658 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1659 editor.SetProperty( TextEditor::Property::TEXT, "" );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 // Cursor position should be the same than position2.
1666 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1668 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1670 // Should not be a renderer.
1671 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1676 int utcDaliTextEditorEvent03(void)
1678 ToolkitTestApplication application;
1679 tet_infoline(" utcDaliTextEditorEvent03");
1681 // Checks if the highlight actor is created.
1683 TextEditor editor = TextEditor::New();
1684 DALI_TEST_CHECK( editor );
1686 application.GetScene().Add( editor );
1688 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1689 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1690 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1691 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1692 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1694 // Avoid a crash when core load gl resources.
1695 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1697 // Render and notify
1698 application.SendNotification();
1699 application.Render();
1701 // Send some taps and check text controller with clipboard window
1702 Dali::Clipboard clipboard = Clipboard::Get();
1703 clipboard.ShowClipboard();
1704 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1705 clipboard.HideClipboard();
1707 // Render and notify
1708 application.SendNotification();
1709 application.Render();
1711 // Tap first to get the focus.
1712 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1714 // Render and notify
1715 application.SendNotification();
1716 application.Render();
1718 // Double tap to select a word.
1719 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1721 // Render and notify
1722 application.SendNotification();
1723 application.Render();
1725 // The stencil actor should have two actors: the renderer and the highlight actor.
1726 Actor stencil = editor.GetChildAt( 0u );
1728 // Highlight needs to be drawn before text, so should come first in child order
1729 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1730 DALI_TEST_CHECK( highlight );
1732 // The stencil actor has a container with all the actors which contain the text renderers.
1733 Actor container = stencil.GetChildAt( 1u );
1734 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1736 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1737 DALI_TEST_CHECK( renderer );
1740 // Double tap out of bounds
1741 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1742 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1744 // Render and notify
1745 application.SendNotification();
1746 application.Render();
1748 // The stencil actor should have one actors: the renderer actor.
1749 stencil = editor.GetChildAt( 0u );
1751 // The stencil actor has a container with all the actors which contain the text renderers.
1752 container = stencil.GetChildAt( 0u );
1753 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1755 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1756 DALI_TEST_CHECK( renderer );
1760 TestGenerateLongPress(application, 1.0f, 25.0f);
1762 // Render and notify
1763 application.SendNotification();
1764 application.Render();
1767 TestGenerateMiniPan(application);
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1776 int utcDaliTextEditorEvent04(void)
1778 ToolkitTestApplication application;
1779 tet_infoline(" utcDaliTextEditorEvent04");
1781 // Checks if the highlight actor is created.
1783 TextEditor editor = TextEditor::New();
1784 DALI_TEST_CHECK( editor );
1786 application.GetScene().Add( editor );
1788 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1789 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1790 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1791 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1792 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1794 // Avoid a crash when core load gl resources.
1795 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1797 // Render and notify
1798 application.SendNotification();
1799 application.Render();
1801 // Tap on the text editor
1802 TestGenerateTap( application, 3.0f, 25.0f );
1804 // Render and notify
1805 application.SendNotification();
1806 application.Render();
1808 // Move at the end of the text.
1809 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1810 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1816 for( unsigned int index = 0u; index < 10u; ++index )
1818 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1819 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1827 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1829 // Render and notify
1830 application.SendNotification();
1831 application.Render();
1833 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1835 // Add some key events
1836 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1837 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 for( unsigned int index = 0u; index < 10u; ++index )
1845 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1846 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1854 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1865 int utcDaliTextEditorEvent05(void)
1867 ToolkitTestApplication application;
1868 tet_infoline(" utcDaliTextEditorEvent05");
1870 // Checks if the highlight actor is created.
1872 TextEditor editor = TextEditor::New();
1873 DALI_TEST_CHECK( editor );
1875 application.GetScene().Add( editor );
1877 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1878 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1879 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1880 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1881 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1882 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1883 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1884 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1885 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1886 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1888 // Avoid a crash when core load gl resources.
1889 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1891 // Render and notify
1892 application.SendNotification();
1893 application.Render();
1895 // Tap on the text editor
1896 TestGenerateTap( application, 3.0f, 25.0f );
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 // Move at the end of the text.
1903 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1904 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 for( unsigned int index = 0u; index < 10u; ++index )
1913 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 // Modify duration after scroll is enabled
1920 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1922 // Continuous scroll left to increase coverage
1923 for( unsigned int index = 0u; index < 10u; ++index )
1925 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1927 // Render and notify
1928 application.SendNotification();
1929 application.Render();
1931 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1932 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1933 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1934 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1935 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1937 // Press Escape to increase coverage
1938 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1939 application.SendNotification();
1940 application.Render();
1942 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1947 int utcDaliTextEditorEvent06(void)
1949 ToolkitTestApplication application;
1950 tet_infoline(" utcDaliTextEditorEvent06");
1952 // Checks if the highlight actor is created.
1954 TextEditor editor = TextEditor::New();
1955 DALI_TEST_CHECK( editor );
1957 application.GetScene().Add( editor );
1959 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1960 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1961 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1962 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1963 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1965 // Avoid a crash when core load gl resources.
1966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1968 // Render and notify
1969 application.SendNotification();
1970 application.Render();
1972 // Tap on the text editor
1973 TestGenerateTap( application, 3.0f, 25.0f );
1975 // Render and notify
1976 application.SendNotification();
1977 application.Render();
1979 // Move to seconds line of the text.
1980 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1982 // Render and notify
1983 application.SendNotification();
1984 application.Render();
1986 float layoutHeight = editor.GetHeightForWidth( 100.f );
1989 // Add another script characters ( glyph height is defferent )
1990 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1991 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1993 // Delete characters
1994 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1995 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1997 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1999 // Render and notify
2000 application.SendNotification();
2001 application.Render();
2003 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2006 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2007 application.SendNotification();
2008 application.Render();
2010 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2011 application.SendNotification();
2012 application.Render();
2014 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2015 application.SendNotification();
2016 application.Render();
2018 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2019 application.SendNotification();
2020 application.Render();
2022 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2023 application.SendNotification();
2024 application.Render();
2026 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2027 application.SendNotification();
2028 application.Render();
2030 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2031 application.SendNotification();
2032 application.Render();
2037 int utcDaliTextEditorEvent07(void)
2039 ToolkitTestApplication application;
2040 tet_infoline(" utcDaliTextEditorEvent07");
2042 // Checks if the highlight actor is created.
2044 TextEditor editor = TextEditor::New();
2045 DALI_TEST_CHECK( editor );
2047 application.GetScene().Add( editor );
2049 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2050 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2051 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2052 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2053 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2055 // Avoid a crash when core load gl resources.
2056 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2058 // Render and notify
2059 application.SendNotification();
2060 application.Render();
2062 // Tap on the text editor
2063 TestGenerateTap( application, 3.0f, 25.0f );
2065 // Render and notify
2066 application.SendNotification();
2067 application.Render();
2069 // Move to second line of the text.
2070 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2076 // Select some text in the right of the current cursor position
2077 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2079 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082 // Render and notify
2083 application.SendNotification();
2084 application.Render();
2086 // Cut the selected text
2087 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2088 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 ) );
2090 // Render and notify
2091 application.SendNotification();
2092 application.Render();
2094 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2096 // Select some text in the left of the current cursor position
2097 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2098 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2100 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2102 // Render and notify
2103 application.SendNotification();
2104 application.Render();
2106 // Copy the selected text
2107 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2108 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 ) );
2110 // Render and notify
2111 application.SendNotification();
2112 application.Render();
2114 // Move the cursor to the third line
2115 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2116 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2118 // Render and notify
2119 application.SendNotification();
2120 application.Render();
2122 // Paste the selected text at the current cursor position
2123 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2124 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 ) );
2126 // Render and notify
2127 application.SendNotification();
2128 application.Render();
2130 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2133 // Disable Shift Selection
2134 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2136 // Test to select some text in the right of the current cursor position
2137 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2138 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2139 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2140 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 // Cut the selected text
2147 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 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 ) );
2150 // Render and notify
2151 application.SendNotification();
2152 application.Render();
2154 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2155 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2157 // Test to select some text in the left of the current cursor position
2158 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2161 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163 // Render and notify
2164 application.SendNotification();
2165 application.Render();
2167 // Copy the selected text
2168 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169 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 ) );
2171 // Render and notify
2172 application.SendNotification();
2173 application.Render();
2175 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2176 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2179 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2181 // Render and notify
2182 application.SendNotification();
2183 application.Render();
2185 // replace text with "c"
2186 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 // Render and notify
2189 application.SendNotification();
2190 application.Render();
2193 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2196 DevelTextEditor::SelectWholeText(editor);
2198 // Render and notify
2199 application.SendNotification();
2200 application.Render();
2202 // Copy the selected text using logical keys
2203 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2204 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2211 DevelTextEditor::SelectNone(editor);
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 // Paste the selected using logical keys
2218 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2222 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2224 // select all using logical keys
2225 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 // cut text using logical keys
2233 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2234 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2241 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2246 int utcDaliTextEditorEvent08(void)
2248 ToolkitTestApplication application;
2249 tet_infoline(" utcDaliTextEditorEvent08");
2251 // Checks if the highlight actor is released correctly.
2253 TextEditor editor = TextEditor::New();
2254 DALI_TEST_CHECK( editor );
2256 application.GetScene().Add( editor );
2258 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2259 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2260 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2261 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2262 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2264 // Avoid a crash when core load gl resources.
2265 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Tap on the text editor
2272 TestGenerateTap( application, 3.0f, 25.0f );
2274 // Render and notify
2275 application.SendNotification();
2276 application.Render();
2278 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2279 // Test to select some text in the left of the current cursor position
2280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2285 // Render and notify
2286 application.SendNotification();
2287 application.Render();
2289 // Test to the left selection handle position and the right selection handle position
2290 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2295 // Render and notify
2296 application.SendNotification();
2297 application.Render();
2299 // Test to select full text in the left of the current cursor position
2300 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2304 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2305 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2307 // Render and notify
2308 application.SendNotification();
2309 application.Render();
2311 // Test to release the current full text selection
2312 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2319 // Test to move the current cursor position correctly
2320 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2327 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 // Render and notify
2330 application.SendNotification();
2331 application.Render();
2333 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2335 // Test to select some text in the right of the current cursor position
2336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2337 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2338 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2340 // Render and notify
2341 application.SendNotification();
2342 application.Render();
2344 // Test the cursor position with right arrow key
2345 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2352 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2360 // Test to select some text in the left of the current cursor position
2361 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2365 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 // Render and notify
2368 application.SendNotification();
2369 application.Render();
2371 // Test the cursor position with left arrow key
2372 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2379 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 // Render and notify
2382 application.SendNotification();
2383 application.Render();
2385 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2387 // Test to select some text in the right of the current cursor position
2388 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Test the cursor position with left arrow key
2398 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2400 // Render and notify
2401 application.SendNotification();
2402 application.Render();
2405 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2413 // Test to select some text in the left of the current cursor position
2414 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 // Test the cursor position with right arrow key
2424 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2431 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2437 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2442 int utcDaliTextEditorHandles(void)
2444 ToolkitTestApplication application;
2445 tet_infoline(" utcDaliTextEditorHandles");
2447 TextEditor editor = TextEditor::New();
2448 DALI_TEST_CHECK( editor );
2450 application.GetScene().Add( editor );
2452 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2453 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2454 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2455 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2457 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2458 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2459 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2460 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2462 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2463 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2464 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2466 // Avoid a crash when core load gl resources.
2467 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2469 // Render and notify
2470 application.SendNotification();
2471 application.Render();
2473 // Tap first to get the focus.
2474 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2476 // Render and notify
2477 application.SendNotification();
2478 application.Render();
2480 // Tap to create the grab handle.
2481 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2483 // Render and notify
2484 application.SendNotification();
2485 application.Render();
2487 // Get the active layer where the text's decoration is added.
2488 Actor activeLayer = editor.GetChildAt( 1u );
2490 // Get the handle's actor.
2491 Actor handle = activeLayer.GetChildAt( 1u );
2492 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2498 // Touch the grab handle to set it as pressed.
2499 Vector2 touchPos( 10.0f, 50.0f );
2500 Dali::Integration::TouchEvent event;
2501 event = Dali::Integration::TouchEvent();
2502 event.AddPoint( GetPointDownInside( touchPos ) );
2503 application.ProcessEvent( event );
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 // Pan the grab handle
2510 uint32_t time = 100;
2511 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2512 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2513 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2514 application.SendNotification();
2515 application.Render();
2518 // Release the grab handle.
2519 event = Dali::Integration::TouchEvent();
2520 event.AddPoint( GetPointUpInside( touchPos ) );
2521 application.ProcessEvent( event );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Tap first to get the focus.
2528 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Double tap to select a word and create the selection handles.
2535 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2541 touchPos = Vector2( 10.0f, 50.0f );
2543 // Touch the left selection handle to set it as pressed.
2544 event = Dali::Integration::TouchEvent();
2545 event.AddPoint( GetPointDownInside( touchPos ) );
2546 application.ProcessEvent( event );
2548 // Render and notify
2549 application.SendNotification();
2550 application.Render();
2552 // Release the left selection handle.
2553 event = Dali::Integration::TouchEvent();
2554 event.AddPoint( GetPointUpInside( touchPos ) );
2555 application.ProcessEvent( event );
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2564 int utcDaliTextEditorUnderPropertyStringP(void)
2566 ToolkitTestApplication application;
2567 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2568 TextEditor editor = TextEditor::New();
2569 DALI_TEST_CHECK( editor );
2571 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2573 application.GetScene().Add( editor );
2575 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2576 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2578 tet_infoline("Set underline settings with a map");
2579 // Check the input underline property
2580 Property::Map underlineMapSet;
2581 Property::Map underlineMapGet;
2582 underlineMapSet.Insert( "enable", true );
2583 underlineMapSet.Insert( "color", Color::BLUE );
2584 underlineMapSet.Insert( "height", 2 );
2586 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2587 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2588 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2589 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2591 tet_infoline("Set underline settings with a string");
2592 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2593 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2596 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2598 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2599 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2600 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2601 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2603 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2608 int utcDaliTextEditorShadowPropertyStringP(void)
2610 ToolkitTestApplication application;
2611 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2613 TextEditor editor = TextEditor::New();
2615 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2617 application.GetScene().Add( editor );
2619 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2621 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2625 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2630 int utcDaliTextEditorFontStylePropertyStringP(void)
2632 ToolkitTestApplication application;
2633 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2635 TextEditor editor = TextEditor::New();
2637 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2639 application.GetScene().Add( editor );
2641 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2643 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2647 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2652 int utcDaliTextEditorGetPropertyLinecountP(void)
2654 ToolkitTestApplication application;
2656 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2660 TextEditor editor = TextEditor::New();
2661 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2662 editor.SetProperty( TextEditor::Property::TEXT,
2663 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2665 application.GetScene().Add( editor );
2667 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2668 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2669 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2671 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2672 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2673 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2678 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2681 ToolkitTestApplication application;
2682 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2684 TextEditor editor = TextEditor::New();
2685 DALI_TEST_CHECK( editor );
2687 application.GetScene().Add( editor );
2689 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2690 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2691 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2692 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2693 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2694 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2696 bool startedCalled = false;
2697 bool finishedCalled = false;
2699 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2700 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2702 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2704 // Render and notify
2705 application.SendNotification();
2706 application.Render();
2708 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2709 application.SendNotification();
2710 application.Render(6000);
2712 application.SendNotification();
2713 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2714 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2719 int UtcDaliToolkitTextEditorTextWrapMode(void)
2721 ToolkitTestApplication application;
2722 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2726 TextEditor editor = TextEditor::New();
2727 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2728 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2730 application.GetScene().Add( editor );
2732 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2733 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2735 application.SendNotification();
2736 application.Render();
2738 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2739 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2741 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2742 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2744 application.SendNotification();
2745 application.Render();
2747 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2748 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2750 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2751 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2753 application.SendNotification();
2754 application.Render();
2756 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2757 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2759 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2760 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2762 application.SendNotification();
2763 application.Render();
2765 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2766 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2771 int UtcDaliTextEditorSetPaddingProperty(void)
2773 ToolkitTestApplication application;
2774 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2776 TextEditor editor = TextEditor::New();
2777 DALI_TEST_CHECK( editor );
2778 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2779 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2780 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2781 application.GetScene().Add( editor );
2783 application.SendNotification();
2784 application.Render();
2786 Vector3 originalSize = editor.GetNaturalSize();
2788 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2790 application.SendNotification();
2791 application.Render();
2793 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2795 Vector3 paddingAddedSize = editor.GetNaturalSize();
2797 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2799 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2804 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2806 ToolkitTestApplication application;
2807 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2809 TextEditor editor = TextEditor::New();
2810 DALI_TEST_CHECK( editor );
2811 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2812 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2813 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2814 application.GetScene().Add( editor );
2816 application.SendNotification();
2817 application.Render();
2819 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2820 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2822 // Check the enable shift selection property
2823 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2824 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2826 application.SendNotification();
2827 application.Render();
2832 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2834 ToolkitTestApplication application;
2835 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2837 TextEditor editor = TextEditor::New();
2838 DALI_TEST_CHECK( editor );
2839 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2840 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2841 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2842 application.GetScene().Add( editor );
2844 application.SendNotification();
2845 application.Render();
2847 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2848 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2850 // Check the enable grab handle property
2851 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2852 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2854 application.SendNotification();
2855 application.Render();
2860 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2862 ToolkitTestApplication application;
2863 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2865 TextEditor editor = TextEditor::New();
2866 DALI_TEST_CHECK( editor );
2867 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2868 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2869 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2870 application.GetScene().Add( editor );
2872 application.SendNotification();
2873 application.Render();
2875 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2876 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2878 // Check the enable match system language direction property
2879 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2880 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2882 application.SendNotification();
2883 application.Render();
2888 int UtcDaliTextEditorGetInputMethodContext(void)
2890 ToolkitTestApplication application;
2891 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2893 TextEditor editor = TextEditor::New();
2894 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2899 int utcDaliTextEditorMaxCharactersReached(void)
2901 ToolkitTestApplication application;
2902 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2904 TextEditor editor = TextEditor::New();
2905 DALI_TEST_CHECK( editor );
2907 application.GetScene().Add( editor );
2909 const int maxNumberOfCharacters = 1;
2910 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2911 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2913 editor.SetKeyInputFocus();
2915 // connect to the text changed signal.
2916 ConnectionTracker* testTracker = new ConnectionTracker();
2917 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2918 bool maxLengthReachedSignal = false;
2919 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2921 gMaxCharactersCallBackCalled = false;
2923 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2924 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2926 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2927 DALI_TEST_CHECK( maxLengthReachedSignal );
2932 int UtcDaliTextEditorSelectWholeText(void)
2934 ToolkitTestApplication application;
2935 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2937 TextEditor textEditor = TextEditor::New();
2939 application.GetScene().Add( textEditor );
2941 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2942 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2943 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2945 // Avoid a crash when core load gl resources.
2946 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2948 application.SendNotification();
2949 application.Render();
2951 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
2953 DevelTextEditor::SelectWholeText( textEditor );
2955 application.SendNotification();
2956 application.Render();
2958 // Nothing should have been selected. The number of children is still 1
2959 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
2961 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
2963 application.SendNotification();
2964 application.Render();
2966 DevelTextEditor::SelectWholeText( textEditor );
2968 application.SendNotification();
2969 application.Render();
2971 // Should be 2 children, the stencil and the layer
2972 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
2974 // The offscreen root actor should have two actors: the renderer and the highlight actor.
2975 Actor stencil = textEditor.GetChildAt( 0u );
2977 // The highlight actor is drawn first, so is the first actor in the list
2978 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2979 DALI_TEST_CHECK( highlight );
2984 int UtcDaliTextEditorSelectNone(void)
2986 ToolkitTestApplication application;
2987 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2989 TextEditor textEditor = TextEditor::New();
2991 application.GetScene().Add( textEditor );
2993 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2994 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2995 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2997 // Avoid a crash when core load gl resources.
2998 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3000 application.SendNotification();
3001 application.Render();
3003 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3005 application.SendNotification();
3006 application.Render();
3008 // Nothing is selected
3009 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3010 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3012 DevelTextEditor::SelectWholeText( textEditor );
3014 application.SendNotification();
3015 application.Render();
3017 // whole text is selected
3018 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3019 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3021 DevelTextEditor::SelectNone( textEditor );
3023 application.SendNotification();
3024 application.Render();
3026 // Nothing is selected
3027 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3028 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3033 int UtcDaliTextEditorSelectRange(void)
3035 ToolkitTestApplication application;
3036 tet_infoline("utcDaliTextEditorSelectRange");
3038 TextEditor textEditor = TextEditor::New();
3039 DALI_TEST_CHECK( textEditor );
3041 application.GetScene().Add( textEditor );
3043 // Avoid a crash when core load gl resources.
3044 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3046 application.SendNotification();
3047 application.Render();
3049 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3051 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3052 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3054 // Hello is selected
3055 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3056 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3058 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3059 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3064 int UtcDaliTextEditorEnableEditing(void)
3066 ToolkitTestApplication application;
3067 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3069 TextEditor textEditor = TextEditor::New();
3071 application.GetScene().Add( textEditor );
3073 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3074 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3075 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3077 // Avoid a crash when core load gl resources.
3078 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3080 application.SendNotification();
3081 application.Render();
3083 textEditor.SetKeyInputFocus();
3084 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3085 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3087 // Render and notify
3088 application.SendNotification();
3089 application.Render();
3091 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3092 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3094 textEditor.SetKeyInputFocus();
3095 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3096 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3098 // Render and notify
3099 application.SendNotification();
3100 application.Render();
3102 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3103 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3108 int UtcDaliTextEditorScrolling(void)
3110 ToolkitTestApplication application;
3111 tet_infoline(" UtcDaliTextEditorScrolling ");
3113 TextEditor textEditor = TextEditor::New();
3114 DALI_TEST_CHECK( textEditor );
3116 application.GetScene().Add( textEditor );
3118 // Avoid a crash when core load gl resources.
3119 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3121 application.SendNotification();
3122 application.Render();
3124 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3125 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3126 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3127 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3129 application.SendNotification();
3130 application.Render();
3132 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3133 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3136 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3138 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3139 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3141 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3143 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3144 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3146 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3147 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3149 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3150 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3155 int UtcDaliToolkitTextEditorFontSizeScale(void)
3157 ToolkitTestApplication application;
3158 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3160 TextEditor textEditor = TextEditor::New();
3161 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3162 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3163 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3165 TextEditor textEditorScaled = TextEditor::New();
3166 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3167 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3168 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3169 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3171 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3173 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3174 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3175 nonScaledSize = textEditor.GetNaturalSize();
3177 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3178 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3179 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3180 scaledSize = textEditorScaled.GetNaturalSize();
3182 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3187 int UtcDaliTextEditorPrimaryCursorPosition(void)
3189 ToolkitTestApplication application;
3190 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3192 TextEditor textEditor = TextEditor::New();
3194 application.GetScene().Add( textEditor );
3196 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3197 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3198 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3199 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3201 // Avoid a crash when core load gl resources.
3202 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3204 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3205 application.SendNotification();
3206 application.Render();
3208 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3210 // Render and notify
3211 application.SendNotification();
3212 application.Render();
3214 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3215 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );