2 * Copyright (c) 2021 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 application.SendNotification();
968 application.Render();
969 DALI_TEST_CHECK( gTextChangedCallBackCalled );
970 DALI_TEST_CHECK( textChangedSignal );
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 application.SendNotification();
977 application.Render();
978 DALI_TEST_CHECK( gTextChangedCallBackCalled );
981 editor.SetProperty( TextField::Property::TEXT, "" );
982 application.SendNotification();
983 application.Render();
985 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
986 gTextChangedCallBackCalled = false;
987 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
988 application.SendNotification();
989 application.Render();
990 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
992 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
993 gTextChangedCallBackCalled = false;
994 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
995 application.SendNotification();
996 application.Render();
997 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1002 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1004 ToolkitTestApplication application;
1005 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1006 TextEditor editor = TextEditor::New();
1007 DALI_TEST_CHECK( editor );
1010 application.GetScene().Add( editor );
1012 // connect to the text changed signal.
1013 ConnectionTracker* testTracker = new ConnectionTracker();
1014 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1015 bool textChangedSignal = false;
1016 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1019 // get InputMethodContext
1021 InputMethodContext::EventData imfEvent;
1022 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1024 editor.SetKeyInputFocus();
1025 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1028 gTextChangedCallBackCalled = false;
1029 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1030 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1031 application.SendNotification();
1032 application.Render();
1033 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1034 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1036 gTextChangedCallBackCalled = false;
1037 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1038 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1039 application.SendNotification();
1040 application.Render();
1041 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1042 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1044 gTextChangedCallBackCalled = false;
1045 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1046 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1047 application.SendNotification();
1048 application.Render();
1049 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1050 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1052 gTextChangedCallBackCalled = false;
1053 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1054 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1055 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1057 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1058 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1059 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1061 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1062 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1063 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1065 application.SendNotification();
1066 application.Render();
1067 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1068 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1074 int utcDaliTextEditorInputStyleChanged01(void)
1076 // The text-editor emits signals when the input style changes. These changes of style are
1077 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1078 // can't be emitted during the size negotiation as the callbacks may update the UI.
1079 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1080 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1081 ToolkitTestApplication application;
1082 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1086 char* pathNamePtr = get_current_dir_name();
1087 const std::string pathName( pathNamePtr );
1088 free( pathNamePtr );
1090 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1091 fontClient.SetDpi( 93u, 93u );
1093 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1094 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1096 TextEditor editor = TextEditor::New();
1097 DALI_TEST_CHECK( editor );
1100 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1101 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1102 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1104 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1105 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1107 // connect to the text changed signal.
1108 ConnectionTracker* testTracker = new ConnectionTracker();
1109 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1110 bool inputStyleChangedSignal = false;
1111 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1113 application.GetScene().Add( editor );
1115 // Render and notify
1116 application.SendNotification();
1117 application.Render();
1119 // Executes the idle callbacks added by the text control on the change of input style.
1120 application.RunIdles();
1122 gInputStyleChangedCallbackCalled = false;
1123 gInputStyleMask = TextEditor::InputStyle::NONE;
1124 inputStyleChangedSignal = false;
1126 // Create a tap event to touch the text editor.
1127 TestGenerateTap( application, 18.0f, 25.0f );
1129 // Render and notify
1130 application.SendNotification();
1131 application.Render();
1133 // Executes the idle callbacks added by the text control on the change of input style.
1134 application.RunIdles();
1136 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1137 if( gInputStyleChangedCallbackCalled )
1139 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1141 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1142 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1144 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1145 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1147 DALI_TEST_CHECK( inputStyleChangedSignal );
1149 gInputStyleChangedCallbackCalled = false;
1150 gInputStyleMask = TextEditor::InputStyle::NONE;
1151 inputStyleChangedSignal = false;
1153 // Create a tap event to touch the text editor.
1154 TestGenerateTap( application, 30.0f, 25.0f );
1156 // Render and notify
1157 application.SendNotification();
1158 application.Render();
1160 // Executes the idle callbacks added by the text control on the change of input style.
1161 application.RunIdles();
1163 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1164 DALI_TEST_CHECK( !inputStyleChangedSignal );
1166 gInputStyleChangedCallbackCalled = false;
1167 gInputStyleMask = TextEditor::InputStyle::NONE;
1168 inputStyleChangedSignal = false;
1170 // Create a tap event to touch the text editor.
1171 TestGenerateTap( application, 43.0f, 25.0f );
1173 // Render and notify
1174 application.SendNotification();
1175 application.Render();
1177 // Executes the idle callbacks added by the text control on the change of input style.
1178 application.RunIdles();
1180 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1181 if( gInputStyleChangedCallbackCalled )
1183 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1185 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1186 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1188 DALI_TEST_CHECK( inputStyleChangedSignal );
1190 gInputStyleChangedCallbackCalled = false;
1191 gInputStyleMask = TextEditor::InputStyle::NONE;
1192 inputStyleChangedSignal = false;
1194 // Create a tap event to touch the text editor.
1195 TestGenerateTap( application, 88.0f, 25.0f );
1197 // Render and notify
1198 application.SendNotification();
1199 application.Render();
1201 // Executes the idle callbacks added by the text control on the change of input style.
1202 application.RunIdles();
1204 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1205 if( gInputStyleChangedCallbackCalled )
1207 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1209 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1210 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1212 Property::Map fontStyleMapSet;
1213 Property::Map fontStyleMapGet;
1215 fontStyleMapSet.Insert( "weight", "bold" );
1217 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1218 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1219 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1221 DALI_TEST_CHECK( inputStyleChangedSignal );
1223 gInputStyleChangedCallbackCalled = false;
1224 gInputStyleMask = TextEditor::InputStyle::NONE;
1225 inputStyleChangedSignal = false;
1227 // Create a tap event to touch the text editor.
1228 TestGenerateTap( application, 115.0f, 25.0f );
1230 // Render and notify
1231 application.SendNotification();
1232 application.Render();
1234 // Executes the idle callbacks added by the text control on the change of input style.
1235 application.RunIdles();
1237 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1238 DALI_TEST_CHECK( !inputStyleChangedSignal );
1240 gInputStyleChangedCallbackCalled = false;
1241 gInputStyleMask = TextEditor::InputStyle::NONE;
1242 inputStyleChangedSignal = false;
1244 // Create a tap event to touch the text editor.
1245 TestGenerateTap( application, 164.0f, 25.0f );
1247 // Render and notify
1248 application.SendNotification();
1249 application.Render();
1251 // Executes the idle callbacks added by the text control on the change of input style.
1252 application.RunIdles();
1254 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1255 if( gInputStyleChangedCallbackCalled )
1257 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1259 Property::Map fontStyleMapSet;
1260 Property::Map fontStyleMapGet;
1262 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1263 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1264 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1266 DALI_TEST_CHECK( inputStyleChangedSignal );
1268 gInputStyleChangedCallbackCalled = false;
1269 gInputStyleMask = TextEditor::InputStyle::NONE;
1270 inputStyleChangedSignal = false;
1272 // Create a tap event to touch the text editor.
1273 TestGenerateTap( application, 191.0f, 25.0f );
1275 // Render and notify
1276 application.SendNotification();
1277 application.Render();
1279 // Executes the idle callbacks added by the text control on the change of input style.
1280 application.RunIdles();
1282 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1283 DALI_TEST_CHECK( !inputStyleChangedSignal );
1288 int utcDaliTextEditorInputStyleChanged02(void)
1290 // The text-editor emits signals when the input style changes. These changes of style are
1291 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1292 // can't be emitted during the size negotiation as the callbacks may update the UI.
1293 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1294 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1295 ToolkitTestApplication application;
1296 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1300 char* pathNamePtr = get_current_dir_name();
1301 const std::string pathName( pathNamePtr );
1302 free( pathNamePtr );
1304 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1305 fontClient.SetDpi( 93u, 93u );
1307 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1308 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1310 TextEditor editor = TextEditor::New();
1311 DALI_TEST_CHECK( editor );
1314 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1315 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1316 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1318 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1319 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>" );
1321 // connect to the text changed signal.
1322 ConnectionTracker* testTracker = new ConnectionTracker();
1323 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1324 bool inputStyleChangedSignal = false;
1325 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1327 application.GetScene().Add( editor );
1329 // Render and notify
1330 application.SendNotification();
1331 application.Render();
1333 // Executes the idle callbacks added by the text control on the change of input style.
1334 application.RunIdles();
1336 gInputStyleChangedCallbackCalled = false;
1337 gInputStyleMask = TextEditor::InputStyle::NONE;
1338 inputStyleChangedSignal = false;
1340 // Create a tap event to touch the text editor.
1341 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1342 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1344 // Render and notify
1345 application.SendNotification();
1346 application.Render();
1348 // Executes the idle callbacks added by the text control on the change of input style.
1349 application.RunIdles();
1351 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1352 if( gInputStyleChangedCallbackCalled )
1354 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1355 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1356 TextEditor::InputStyle::POINT_SIZE |
1357 TextEditor::InputStyle::COLOR ),
1360 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1361 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1363 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1364 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1366 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1367 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1369 DALI_TEST_CHECK( inputStyleChangedSignal );
1371 gInputStyleChangedCallbackCalled = false;
1372 gInputStyleMask = TextEditor::InputStyle::NONE;
1373 inputStyleChangedSignal = false;
1375 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1377 // Render and notify
1378 application.SendNotification();
1379 application.Render();
1381 // Executes the idle callbacks added by the text control on the change of input style.
1382 application.RunIdles();
1384 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1385 if( gInputStyleChangedCallbackCalled )
1387 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1388 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1391 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1392 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1394 DALI_TEST_CHECK( inputStyleChangedSignal );
1396 gInputStyleChangedCallbackCalled = false;
1397 gInputStyleMask = TextEditor::InputStyle::NONE;
1398 inputStyleChangedSignal = false;
1400 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1402 // Render and notify
1403 application.SendNotification();
1404 application.Render();
1406 // Executes the idle callbacks added by the text control on the change of input style.
1407 application.RunIdles();
1409 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1410 DALI_TEST_CHECK( !inputStyleChangedSignal );
1412 gInputStyleChangedCallbackCalled = false;
1413 gInputStyleMask = TextEditor::InputStyle::NONE;
1414 inputStyleChangedSignal = false;
1416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1418 // Render and notify
1419 application.SendNotification();
1420 application.Render();
1422 // Executes the idle callbacks added by the text control on the change of input style.
1423 application.RunIdles();
1425 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1426 if( gInputStyleChangedCallbackCalled )
1428 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1429 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1432 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1433 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1435 DALI_TEST_CHECK( inputStyleChangedSignal );
1437 gInputStyleChangedCallbackCalled = false;
1438 gInputStyleMask = TextEditor::InputStyle::NONE;
1439 inputStyleChangedSignal = false;
1441 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1443 Property::Map fontStyleMapSet;
1444 fontStyleMapSet.Insert( "weight", "thin" );
1445 fontStyleMapSet.Insert( "width", "condensed" );
1446 fontStyleMapSet.Insert( "slant", "italic" );
1448 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1449 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1450 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1452 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1453 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1454 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1455 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1457 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1459 // Render and notify
1460 application.SendNotification();
1461 application.Render();
1463 // Executes the idle callbacks added by the text control on the change of input style.
1464 application.RunIdles();
1466 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1467 DALI_TEST_CHECK( !inputStyleChangedSignal );
1469 // Create a tap event to touch the text editor.
1470 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 // Executes the idle callbacks added by the text control on the change of input style.
1477 application.RunIdles();
1479 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1480 if( gInputStyleChangedCallbackCalled )
1482 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1483 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1484 TextEditor::InputStyle::POINT_SIZE |
1485 TextEditor::InputStyle::FONT_STYLE |
1486 TextEditor::InputStyle::LINE_SPACING |
1487 TextEditor::InputStyle::UNDERLINE |
1488 TextEditor::InputStyle::SHADOW |
1489 TextEditor::InputStyle::EMBOSS |
1490 TextEditor::InputStyle::OUTLINE ),
1493 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1494 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1496 DALI_TEST_CHECK( inputStyleChangedSignal );
1498 gInputStyleChangedCallbackCalled = false;
1499 gInputStyleMask = TextEditor::InputStyle::NONE;
1500 inputStyleChangedSignal = false;
1502 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1504 fontStyleMapSet.Clear();
1505 fontStyleMapSet.Insert( "weight", "black" );
1506 fontStyleMapSet.Insert( "width", "expanded" );
1507 fontStyleMapSet.Insert( "slant", "oblique" );
1509 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1511 // Create a tap event to touch the text editor.
1512 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1514 // Render and notify
1515 application.SendNotification();
1516 application.Render();
1518 // Executes the idle callbacks added by the text control on the change of input style.
1519 application.RunIdles();
1521 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1522 if( gInputStyleChangedCallbackCalled )
1524 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1525 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1526 TextEditor::InputStyle::POINT_SIZE |
1527 TextEditor::InputStyle::FONT_STYLE ),
1530 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1531 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1533 DALI_TEST_CHECK( inputStyleChangedSignal );
1538 int utcDaliTextEditorEvent01(void)
1540 ToolkitTestApplication application;
1541 tet_infoline(" utcDaliTextEditorEvent01");
1543 // Creates a tap event. After creating a tap event the text editor should
1544 // have the focus and add text with key events should be possible.
1546 TextEditor editor = TextEditor::New();
1547 DALI_TEST_CHECK( editor );
1549 application.GetScene().Add( editor );
1551 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1552 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1553 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1555 // Avoid a crash when core load gl resources.
1556 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 // Add a key event but as the text editor has not the focus it should do nothing.
1563 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1565 // Render and notify
1566 application.SendNotification();
1567 application.Render();
1569 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1571 // Create a tap event to touch the text editor.
1572 TestGenerateTap( application, 150.0f, 25.0f );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Now the text editor has the focus, so it can handle the key events.
1579 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1580 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1588 // Create a second text editor and send key events to it.
1589 TextEditor editor2 = TextEditor::New();
1591 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1592 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1593 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1594 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1596 application.GetScene().Add( editor2 );
1598 // Render and notify
1599 application.SendNotification();
1600 application.Render();
1602 // Create a tap event on the second text editor.
1603 TestGenerateTap( application, 150.0f, 125.0f );
1605 // Render and notify
1606 application.SendNotification();
1607 application.Render();
1609 // The second text editor has the focus. It should handle the key events.
1610 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1611 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1613 // Render and notify
1614 application.SendNotification();
1615 application.Render();
1617 // Check the text has been added to the second text editor.
1618 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1623 int utcDaliTextEditorEvent02(void)
1625 ToolkitTestApplication application;
1626 tet_infoline(" utcDaliTextEditorEvent02");
1628 // Checks if the right number of actors are created.
1630 TextEditor editor = TextEditor::New();
1631 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1632 DALI_TEST_CHECK( editor );
1634 application.GetScene().Add( editor );
1636 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1637 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1638 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1640 // Avoid a crash when core load gl resources.
1641 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1643 // Render and notify
1644 application.SendNotification();
1645 application.Render();
1647 // Check there are the expected number of children (the stencil).
1648 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1650 Actor stencil = editor.GetChildAt( 0u );
1652 // Create a tap event to touch the text editor.
1653 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 Actor layer = editor.GetChildAt( 1u );
1660 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1661 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1663 // Now the text editor has the focus, so it can handle the key events.
1664 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1665 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1667 // Render and notify
1668 application.SendNotification();
1669 application.Render();
1671 // Checks the cursor and the renderer have been created.
1672 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1673 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1675 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1676 DALI_TEST_CHECK( cursor );
1678 // The stencil actor has a container with all the actors which contain the text renderers.
1679 Actor container = stencil.GetChildAt( 0u );
1680 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1682 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1683 DALI_TEST_CHECK( renderer );
1686 // Move the cursor and check the position changes.
1687 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1689 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1690 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1692 // Render and notify
1693 application.SendNotification();
1694 application.Render();
1696 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1698 DALI_TEST_CHECK( position2.x < position1.x );
1700 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1701 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1709 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1711 // Send some taps and check the cursor positions.
1713 // Try to tap at the beginning.
1714 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1716 // Render and notify
1717 application.SendNotification();
1718 application.Render();
1720 // Cursor position should be the same than position1.
1721 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1723 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1725 // Tap away from the start position.
1726 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1734 DALI_TEST_CHECK( position5.x > position4.x );
1736 // Remove all the text.
1737 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1739 editor.SetProperty( TextEditor::Property::TEXT, "" );
1741 // Render and notify
1742 application.SendNotification();
1743 application.Render();
1745 // Cursor position should be the same than position2.
1746 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1748 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1750 // Should not be a renderer.
1751 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1756 int utcDaliTextEditorEvent03(void)
1758 ToolkitTestApplication application;
1759 tet_infoline(" utcDaliTextEditorEvent03");
1761 // Checks if the highlight actor is created.
1763 TextEditor editor = TextEditor::New();
1764 DALI_TEST_CHECK( editor );
1766 application.GetScene().Add( editor );
1768 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1769 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1770 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1771 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1772 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1774 // Avoid a crash when core load gl resources.
1775 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1781 // Send some taps and check text controller with clipboard window
1782 Dali::Clipboard clipboard = Clipboard::Get();
1783 clipboard.ShowClipboard();
1784 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1785 clipboard.HideClipboard();
1787 // Render and notify
1788 application.SendNotification();
1789 application.Render();
1791 // Tap first to get the focus.
1792 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1794 // Render and notify
1795 application.SendNotification();
1796 application.Render();
1798 // Double tap to select a word.
1799 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1801 // Render and notify
1802 application.SendNotification();
1803 application.Render();
1805 // The stencil actor should have two actors: the renderer and the highlight actor.
1806 Actor stencil = editor.GetChildAt( 0u );
1808 // Highlight needs to be drawn before text, so should come first in child order
1809 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1810 DALI_TEST_CHECK( highlight );
1812 // The stencil actor has a container with all the actors which contain the text renderers.
1813 Actor container = stencil.GetChildAt( 1u );
1814 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1816 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1817 DALI_TEST_CHECK( renderer );
1820 // Double tap out of bounds
1821 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1822 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1824 // Render and notify
1825 application.SendNotification();
1826 application.Render();
1828 // The stencil actor should have one actors: the renderer actor.
1829 stencil = editor.GetChildAt( 0u );
1831 // The stencil actor has a container with all the actors which contain the text renderers.
1832 container = stencil.GetChildAt( 0u );
1833 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1835 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1836 DALI_TEST_CHECK( renderer );
1840 TestGenerateLongPress(application, 1.0f, 25.0f);
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1847 TestGenerateMiniPan(application);
1849 // Render and notify
1850 application.SendNotification();
1851 application.Render();
1856 int utcDaliTextEditorEvent04(void)
1858 ToolkitTestApplication application;
1859 tet_infoline(" utcDaliTextEditorEvent04");
1861 // Checks if the highlight actor is created.
1863 TextEditor editor = TextEditor::New();
1864 DALI_TEST_CHECK( editor );
1866 application.GetScene().Add( editor );
1868 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1869 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1870 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1871 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1872 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1874 // Avoid a crash when core load gl resources.
1875 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1877 // Render and notify
1878 application.SendNotification();
1879 application.Render();
1881 // Tap on the text editor
1882 TestGenerateTap( application, 3.0f, 25.0f );
1884 // Render and notify
1885 application.SendNotification();
1886 application.Render();
1888 // Move at the end of the text.
1889 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1890 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1892 // Render and notify
1893 application.SendNotification();
1894 application.Render();
1896 for( unsigned int index = 0u; index < 10u; ++index )
1898 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1899 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1901 // Render and notify
1902 application.SendNotification();
1903 application.Render();
1907 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1909 // Render and notify
1910 application.SendNotification();
1911 application.Render();
1913 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1915 // Add some key events
1916 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1917 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1919 // Render and notify
1920 application.SendNotification();
1921 application.Render();
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 ) );
1926 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1928 // Render and notify
1929 application.SendNotification();
1930 application.Render();
1934 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1936 // Render and notify
1937 application.SendNotification();
1938 application.Render();
1940 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1945 int utcDaliTextEditorEvent05(void)
1947 ToolkitTestApplication application;
1948 tet_infoline(" utcDaliTextEditorEvent05");
1950 // Checks if the highlight actor is created.
1952 TextEditor editor = TextEditor::New();
1953 DALI_TEST_CHECK( editor );
1955 application.GetScene().Add( editor );
1957 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1958 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1959 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1960 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1961 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1962 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1963 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1964 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1965 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1966 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1968 // Avoid a crash when core load gl resources.
1969 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 // Tap on the text editor
1976 TestGenerateTap( application, 3.0f, 25.0f );
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1982 // Move at the end of the text.
1983 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1984 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 for( unsigned int index = 0u; index < 10u; ++index )
1993 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1995 // Render and notify
1996 application.SendNotification();
1997 application.Render();
1999 // Modify duration after scroll is enabled
2000 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2002 // Continuous scroll left to increase coverage
2003 for( unsigned int index = 0u; index < 10u; ++index )
2005 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2007 // Render and notify
2008 application.SendNotification();
2009 application.Render();
2011 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2012 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2013 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2014 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2015 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2017 // Press Escape to increase coverage
2018 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2019 application.SendNotification();
2020 application.Render();
2022 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2027 int utcDaliTextEditorEvent06(void)
2029 ToolkitTestApplication application;
2030 tet_infoline(" utcDaliTextEditorEvent06");
2032 // Checks if the highlight actor is created.
2034 TextEditor editor = TextEditor::New();
2035 DALI_TEST_CHECK( editor );
2037 application.GetScene().Add( editor );
2039 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2040 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2041 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2042 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2043 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2045 // Avoid a crash when core load gl resources.
2046 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 // Tap on the text editor
2053 TestGenerateTap( application, 3.0f, 25.0f );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 // Move to seconds line of the text.
2060 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062 // Render and notify
2063 application.SendNotification();
2064 application.Render();
2066 float layoutHeight = editor.GetHeightForWidth( 100.f );
2069 // Add another script characters ( glyph height is defferent )
2070 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2071 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2073 // Delete characters
2074 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2075 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2077 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2079 // Render and notify
2080 application.SendNotification();
2081 application.Render();
2083 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2086 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2087 application.SendNotification();
2088 application.Render();
2090 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 application.SendNotification();
2092 application.Render();
2094 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2095 application.SendNotification();
2096 application.Render();
2098 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 application.SendNotification();
2100 application.Render();
2102 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2103 application.SendNotification();
2104 application.Render();
2106 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107 application.SendNotification();
2108 application.Render();
2110 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2111 application.SendNotification();
2112 application.Render();
2117 int utcDaliTextEditorEvent07(void)
2119 ToolkitTestApplication application;
2120 tet_infoline(" utcDaliTextEditorEvent07");
2122 // Checks if the highlight actor is created.
2124 TextEditor editor = TextEditor::New();
2125 DALI_TEST_CHECK( editor );
2127 application.GetScene().Add( editor );
2129 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2130 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2131 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2132 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2133 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2135 // Avoid a crash when core load gl resources.
2136 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2138 // Render and notify
2139 application.SendNotification();
2140 application.Render();
2142 // Tap on the text editor
2143 TestGenerateTap( application, 3.0f, 25.0f );
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2149 // Move to second line of the text.
2150 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2152 // Render and notify
2153 application.SendNotification();
2154 application.Render();
2156 // Select some text in the right of the current cursor position
2157 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 // Cut the selected text
2167 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 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 ) );
2170 // Render and notify
2171 application.SendNotification();
2172 application.Render();
2174 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2176 // Select some text in the left of the current cursor position
2177 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2178 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2179 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2180 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2182 // Render and notify
2183 application.SendNotification();
2184 application.Render();
2186 // Copy the selected text
2187 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 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 ) );
2190 // Render and notify
2191 application.SendNotification();
2192 application.Render();
2194 // Move the cursor to the third line
2195 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2196 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2198 // Render and notify
2199 application.SendNotification();
2200 application.Render();
2202 // Paste the selected text at the current cursor position
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( "v", "", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2206 // Render and notify
2207 application.SendNotification();
2208 application.Render();
2210 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2213 // Disable Shift Selection
2214 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2216 // Test to select some text in the right of the current cursor position
2217 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2222 // Render and notify
2223 application.SendNotification();
2224 application.Render();
2226 // Cut the selected text
2227 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2228 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 ) );
2230 // Render and notify
2231 application.SendNotification();
2232 application.Render();
2234 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2235 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2237 // Test to select some text in the left of the current cursor position
2238 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2243 // Render and notify
2244 application.SendNotification();
2245 application.Render();
2247 // Copy the selected text
2248 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2249 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 ) );
2251 // Render and notify
2252 application.SendNotification();
2253 application.Render();
2255 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2256 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2259 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 ) );
2261 // Render and notify
2262 application.SendNotification();
2263 application.Render();
2265 // replace text with "c"
2266 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 // Render and notify
2269 application.SendNotification();
2270 application.Render();
2273 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2276 DevelTextEditor::SelectWholeText(editor);
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 // Copy the selected text using logical keys
2283 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2286 // Render and notify
2287 application.SendNotification();
2288 application.Render();
2291 DevelTextEditor::SelectNone(editor);
2293 // Render and notify
2294 application.SendNotification();
2295 application.Render();
2297 // Paste the selected using logical keys
2298 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2302 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2304 // select all using logical keys
2305 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 // Render and notify
2309 application.SendNotification();
2310 application.Render();
2312 // cut text using logical keys
2313 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2316 // Render and notify
2317 application.SendNotification();
2318 application.Render();
2321 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2326 int utcDaliTextEditorEvent08(void)
2328 ToolkitTestApplication application;
2329 tet_infoline(" utcDaliTextEditorEvent08");
2331 // Checks if the highlight actor is released correctly.
2333 TextEditor editor = TextEditor::New();
2334 DALI_TEST_CHECK( editor );
2336 application.GetScene().Add( editor );
2338 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2339 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2340 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2341 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2342 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2344 // Avoid a crash when core load gl resources.
2345 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 // Tap on the text editor
2352 TestGenerateTap( application, 3.0f, 25.0f );
2354 // Render and notify
2355 application.SendNotification();
2356 application.Render();
2358 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2359 // Test to select some text in the left of the current cursor position
2360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2365 // Render and notify
2366 application.SendNotification();
2367 application.Render();
2369 // Test to the left selection handle position and the right selection handle position
2370 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 // Render and notify
2376 application.SendNotification();
2377 application.Render();
2379 // Test to select full text in the left of the current cursor position
2380 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 // Test to release the current full text selection
2392 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 // Test to move the current cursor position correctly
2400 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2402 // Render and notify
2403 application.SendNotification();
2404 application.Render();
2407 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2409 // Render and notify
2410 application.SendNotification();
2411 application.Render();
2413 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2415 // Test to select some text in the right of the current cursor position
2416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2418 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2420 // Render and notify
2421 application.SendNotification();
2422 application.Render();
2424 // Test the cursor position with right arrow key
2425 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2427 // Render and notify
2428 application.SendNotification();
2429 application.Render();
2432 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2434 // Render and notify
2435 application.SendNotification();
2436 application.Render();
2438 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2440 // Test to select some text in the left of the current cursor position
2441 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 // Render and notify
2448 application.SendNotification();
2449 application.Render();
2451 // Test the cursor position with left arrow key
2452 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2454 // Render and notify
2455 application.SendNotification();
2456 application.Render();
2459 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2467 // Test to select some text in the right of the current cursor position
2468 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 // Test the cursor position with left arrow key
2478 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480 // Render and notify
2481 application.SendNotification();
2482 application.Render();
2485 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2487 // Render and notify
2488 application.SendNotification();
2489 application.Render();
2491 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2493 // Test to select some text in the left of the current cursor position
2494 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2495 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2496 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2497 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2499 // Render and notify
2500 application.SendNotification();
2501 application.Render();
2503 // Test the cursor position with right arrow key
2504 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2506 // Render and notify
2507 application.SendNotification();
2508 application.Render();
2511 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2513 // Render and notify
2514 application.SendNotification();
2515 application.Render();
2517 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2522 int utcDaliTextEditorHandles(void)
2524 ToolkitTestApplication application;
2525 tet_infoline(" utcDaliTextEditorHandles");
2527 TextEditor editor = TextEditor::New();
2528 DALI_TEST_CHECK( editor );
2530 application.GetScene().Add( editor );
2532 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2533 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2534 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2535 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2537 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2538 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2539 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2540 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2542 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2543 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2544 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2546 // Avoid a crash when core load gl resources.
2547 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // Tap first to get the focus.
2554 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 // Tap to create the grab handle.
2561 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2563 // Render and notify
2564 application.SendNotification();
2565 application.Render();
2567 // Get the active layer where the text's decoration is added.
2568 Actor activeLayer = editor.GetChildAt( 1u );
2570 // Get the handle's actor.
2571 Actor handle = activeLayer.GetChildAt( 1u );
2572 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 // Touch the grab handle to set it as pressed.
2579 Vector2 touchPos( 10.0f, 50.0f );
2580 Dali::Integration::TouchEvent event;
2581 event = Dali::Integration::TouchEvent();
2582 event.AddPoint( GetPointDownInside( touchPos ) );
2583 application.ProcessEvent( event );
2585 // Render and notify
2586 application.SendNotification();
2587 application.Render();
2589 // Pan the grab handle
2590 uint32_t time = 100;
2591 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2592 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2593 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2594 application.SendNotification();
2595 application.Render();
2598 // Release the grab handle.
2599 event = Dali::Integration::TouchEvent();
2600 event.AddPoint( GetPointUpInside( touchPos ) );
2601 application.ProcessEvent( event );
2603 // Render and notify
2604 application.SendNotification();
2605 application.Render();
2607 // Tap first to get the focus.
2608 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2610 // Render and notify
2611 application.SendNotification();
2612 application.Render();
2614 // Double tap to select a word and create the selection handles.
2615 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2617 // Render and notify
2618 application.SendNotification();
2619 application.Render();
2621 touchPos = Vector2( 10.0f, 50.0f );
2623 // Touch the left selection handle to set it as pressed.
2624 event = Dali::Integration::TouchEvent();
2625 event.AddPoint( GetPointDownInside( touchPos ) );
2626 application.ProcessEvent( event );
2628 // Render and notify
2629 application.SendNotification();
2630 application.Render();
2632 // Release the left selection handle.
2633 event = Dali::Integration::TouchEvent();
2634 event.AddPoint( GetPointUpInside( touchPos ) );
2635 application.ProcessEvent( event );
2637 // Render and notify
2638 application.SendNotification();
2639 application.Render();
2644 int utcDaliTextEditorUnderPropertyStringP(void)
2646 ToolkitTestApplication application;
2647 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2648 TextEditor editor = TextEditor::New();
2649 DALI_TEST_CHECK( editor );
2651 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2653 application.GetScene().Add( editor );
2655 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2656 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2658 tet_infoline("Set underline settings with a map");
2659 // Check the input underline property
2660 Property::Map underlineMapSet;
2661 Property::Map underlineMapGet;
2662 underlineMapSet.Insert( "enable", true );
2663 underlineMapSet.Insert( "color", Color::BLUE );
2664 underlineMapSet.Insert( "height", 2 );
2666 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2667 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2668 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2669 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2671 tet_infoline("Set underline settings with a string");
2672 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2673 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2676 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2678 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2679 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2680 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2681 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2683 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2688 int utcDaliTextEditorShadowPropertyStringP(void)
2690 ToolkitTestApplication application;
2691 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2693 TextEditor editor = TextEditor::New();
2695 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2697 application.GetScene().Add( editor );
2699 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2701 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2705 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2710 int utcDaliTextEditorFontStylePropertyStringP(void)
2712 ToolkitTestApplication application;
2713 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2715 TextEditor editor = TextEditor::New();
2717 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2719 application.GetScene().Add( editor );
2721 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2723 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2727 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2732 int utcDaliTextEditorGetPropertyLinecountP(void)
2734 ToolkitTestApplication application;
2736 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2740 TextEditor editor = TextEditor::New();
2741 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2742 editor.SetProperty( TextEditor::Property::TEXT,
2743 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2745 application.GetScene().Add( editor );
2747 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2748 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2749 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2751 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2752 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2753 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2758 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2761 ToolkitTestApplication application;
2762 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2764 TextEditor editor = TextEditor::New();
2765 DALI_TEST_CHECK( editor );
2767 application.GetScene().Add( editor );
2769 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2770 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2771 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2772 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2773 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2774 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2776 bool startedCalled = false;
2777 bool finishedCalled = false;
2779 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2780 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2782 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2784 // Render and notify
2785 application.SendNotification();
2786 application.Render();
2788 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2789 application.SendNotification();
2790 application.Render(6000);
2792 application.SendNotification();
2793 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2794 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2799 int UtcDaliToolkitTextEditorTextWrapMode(void)
2801 ToolkitTestApplication application;
2802 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2806 TextEditor editor = TextEditor::New();
2807 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2808 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2810 application.GetScene().Add( editor );
2812 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2813 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2815 application.SendNotification();
2816 application.Render();
2818 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2819 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2821 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2822 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2824 application.SendNotification();
2825 application.Render();
2827 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2828 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2830 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2831 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2833 application.SendNotification();
2834 application.Render();
2836 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2837 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2839 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2840 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2842 application.SendNotification();
2843 application.Render();
2845 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2846 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2851 int UtcDaliTextEditorSetPaddingProperty(void)
2853 ToolkitTestApplication application;
2854 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2856 TextEditor editor = TextEditor::New();
2857 DALI_TEST_CHECK( editor );
2858 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2859 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2860 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2861 application.GetScene().Add( editor );
2863 application.SendNotification();
2864 application.Render();
2866 Vector3 originalSize = editor.GetNaturalSize();
2868 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2870 application.SendNotification();
2871 application.Render();
2873 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2875 Vector3 paddingAddedSize = editor.GetNaturalSize();
2877 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2879 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2884 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2886 ToolkitTestApplication application;
2887 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2889 TextEditor editor = TextEditor::New();
2890 DALI_TEST_CHECK( editor );
2891 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2892 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2893 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2894 application.GetScene().Add( editor );
2896 application.SendNotification();
2897 application.Render();
2899 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2900 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2902 // Check the enable shift selection property
2903 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2904 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2906 application.SendNotification();
2907 application.Render();
2912 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2914 ToolkitTestApplication application;
2915 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2917 TextEditor editor = TextEditor::New();
2918 DALI_TEST_CHECK( editor );
2919 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2920 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2921 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2922 application.GetScene().Add( editor );
2924 application.SendNotification();
2925 application.Render();
2927 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2928 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2930 // Check the enable grab handle property
2931 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2932 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2934 application.SendNotification();
2935 application.Render();
2940 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2942 ToolkitTestApplication application;
2943 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2945 TextEditor editor = TextEditor::New();
2946 DALI_TEST_CHECK( editor );
2947 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2948 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2949 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2950 application.GetScene().Add( editor );
2952 application.SendNotification();
2953 application.Render();
2955 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2956 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2958 // Check the enable match system language direction property
2959 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2960 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2962 application.SendNotification();
2963 application.Render();
2968 int UtcDaliTextEditorGetInputMethodContext(void)
2970 ToolkitTestApplication application;
2971 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2973 TextEditor editor = TextEditor::New();
2974 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2979 int utcDaliTextEditorMaxCharactersReached(void)
2981 ToolkitTestApplication application;
2982 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2984 TextEditor editor = TextEditor::New();
2985 DALI_TEST_CHECK( editor );
2987 application.GetScene().Add( editor );
2989 const int maxNumberOfCharacters = 1;
2990 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2991 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2993 editor.SetKeyInputFocus();
2995 // connect to the text changed signal.
2996 ConnectionTracker* testTracker = new ConnectionTracker();
2997 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2998 bool maxLengthReachedSignal = false;
2999 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3001 gMaxCharactersCallBackCalled = false;
3003 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3004 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3006 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3007 DALI_TEST_CHECK( maxLengthReachedSignal );
3012 int UtcDaliTextEditorSelectWholeText(void)
3014 ToolkitTestApplication application;
3015 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3017 TextEditor textEditor = TextEditor::New();
3019 application.GetScene().Add( textEditor );
3021 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3022 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3023 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3025 // Avoid a crash when core load gl resources.
3026 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3028 application.SendNotification();
3029 application.Render();
3031 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3033 DevelTextEditor::SelectWholeText( textEditor );
3035 application.SendNotification();
3036 application.Render();
3038 // Nothing should have been selected. The number of children is still 1
3039 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3041 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3043 application.SendNotification();
3044 application.Render();
3046 DevelTextEditor::SelectWholeText( textEditor );
3048 application.SendNotification();
3049 application.Render();
3051 // Should be 2 children, the stencil and the layer
3052 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3054 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3055 Actor stencil = textEditor.GetChildAt( 0u );
3057 // The highlight actor is drawn first, so is the first actor in the list
3058 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3059 DALI_TEST_CHECK( highlight );
3064 int UtcDaliTextEditorSelectNone(void)
3066 ToolkitTestApplication application;
3067 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
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.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3085 application.SendNotification();
3086 application.Render();
3088 // Nothing is selected
3089 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3090 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3092 DevelTextEditor::SelectWholeText( textEditor );
3094 application.SendNotification();
3095 application.Render();
3097 // whole text is selected
3098 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3099 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3101 DevelTextEditor::SelectNone( textEditor );
3103 application.SendNotification();
3104 application.Render();
3106 // Nothing is selected
3107 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3108 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3113 int UtcDaliTextEditorSelectRange(void)
3115 ToolkitTestApplication application;
3116 tet_infoline("utcDaliTextEditorSelectRange");
3118 TextEditor textEditor = TextEditor::New();
3119 DALI_TEST_CHECK( textEditor );
3121 application.GetScene().Add( textEditor );
3123 // Avoid a crash when core load gl resources.
3124 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3126 application.SendNotification();
3127 application.Render();
3129 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3131 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3132 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3134 // Hello is selected
3135 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3136 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3138 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3139 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3144 int UtcDaliTextEditorEnableEditing(void)
3146 ToolkitTestApplication application;
3147 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3149 TextEditor textEditor = TextEditor::New();
3151 application.GetScene().Add( textEditor );
3153 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3154 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3155 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3157 // Avoid a crash when core load gl resources.
3158 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3160 application.SendNotification();
3161 application.Render();
3163 textEditor.SetKeyInputFocus();
3164 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3165 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3167 // Render and notify
3168 application.SendNotification();
3169 application.Render();
3171 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3172 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3174 textEditor.SetKeyInputFocus();
3175 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3176 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3178 // Render and notify
3179 application.SendNotification();
3180 application.Render();
3182 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3183 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3188 int UtcDaliTextEditorScrolling(void)
3190 ToolkitTestApplication application;
3191 tet_infoline(" UtcDaliTextEditorScrolling ");
3193 TextEditor textEditor = TextEditor::New();
3194 DALI_TEST_CHECK( textEditor );
3196 application.GetScene().Add( textEditor );
3198 // Avoid a crash when core load gl resources.
3199 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3201 application.SendNotification();
3202 application.Render();
3204 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3205 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3206 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3207 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3209 application.SendNotification();
3210 application.Render();
3212 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3213 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3216 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3218 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3219 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3221 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3223 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3224 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3226 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3227 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3229 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3230 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3235 int UtcDaliToolkitTextEditorFontSizeScale(void)
3237 ToolkitTestApplication application;
3238 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3240 TextEditor textEditor = TextEditor::New();
3241 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3242 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3243 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3245 TextEditor textEditorScaled = TextEditor::New();
3246 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3247 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3248 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3249 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3251 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3253 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3254 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3255 nonScaledSize = textEditor.GetNaturalSize();
3257 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3258 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3259 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3260 scaledSize = textEditorScaled.GetNaturalSize();
3262 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3267 int UtcDaliTextEditorPrimaryCursorPosition(void)
3269 ToolkitTestApplication application;
3270 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3272 TextEditor textEditor = TextEditor::New();
3274 application.GetScene().Add( textEditor );
3276 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3277 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3278 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3279 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3281 // Avoid a crash when core load gl resources.
3282 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3284 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3285 application.SendNotification();
3286 application.Render();
3288 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3290 // Render and notify
3291 application.SendNotification();
3292 application.Render();
3294 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3295 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );