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";
106 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
109 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
110 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
112 const float RENDER_FRAME_INTERVAL = 16.66f;
114 const unsigned int DEFAULT_FONT_SIZE = 1152u;
115 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
117 const int KEY_A_CODE = 38;
118 const int KEY_D_CODE = 40;
119 const int KEY_C_CODE = 54;
120 const int KEY_V_CODE = 55;
121 const int KEY_X_CODE = 53;
122 const int KEY_WHITE_SPACE_CODE = 65;
124 const int KEY_SHIFT_MODIFIER = 257;
125 const int KEY_CONTROL_MODIFIER = 258;
127 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
128 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
129 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
131 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
133 static bool gTextChangedCallBackCalled;
134 static bool gInputStyleChangedCallbackCalled;
135 static bool gMaxCharactersCallBackCalled;
136 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
138 struct CallbackFunctor
140 CallbackFunctor(bool* callbackFlag)
141 : mCallbackFlag( callbackFlag )
147 *mCallbackFlag = true;
152 static void TestTextChangedCallback( TextEditor control )
154 tet_infoline(" TestTextChangedCallback");
156 gTextChangedCallBackCalled = true;
159 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
161 tet_infoline(" TestInputStyleChangedCallback");
163 gInputStyleChangedCallbackCalled = true;
164 gInputStyleMask = mask;
167 static void TestMaxLengthReachedCallback( TextEditor control )
169 tet_infoline(" TestMaxLengthReachedCallback");
171 gMaxCharactersCallBackCalled = true;
174 // Generate a KeyEvent to send to Core.
175 Integration::KeyEvent GenerateKey( const std::string& keyName,
176 const std::string& logicalKey,
177 const std::string& keyString,
180 unsigned long timeStamp,
181 const Integration::KeyEvent::State& keyState,
182 const std::string& compose = "",
183 const std::string& deviceName = DEFAULT_DEVICE_NAME,
184 const Device::Class::Type& deviceClass = Device::Class::NONE,
185 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
187 return Integration::KeyEvent( keyName,
200 Dali::Integration::Point GetPointDownInside( Vector2& pos )
202 Dali::Integration::Point point;
203 point.SetState( PointState::DOWN );
204 point.SetScreenPosition( pos );
208 Dali::Integration::Point GetPointUpInside( Vector2& pos )
210 Dali::Integration::Point point;
211 point.SetState( PointState::UP );
212 point.SetScreenPosition( pos );
216 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
218 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
220 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
222 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
224 Property::Value* valueSet = NULL;
225 if ( valueGet.first.type == Property::Key::INDEX )
227 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
231 // Get Key is a string so searching Set Map for a string key
232 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
235 if( NULL != valueSet )
237 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
239 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
242 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
244 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
247 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
249 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
252 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
254 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
257 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
259 Vector2 vector2Get = valueGet.second.Get<Vector2>();
260 Vector2 vector2Set = valueSet->Get<Vector2>();
261 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
264 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
266 Vector4 vector4Get = valueGet.second.Get<Vector4>();
267 Vector4 vector4Set = valueSet->Get<Vector4>();
268 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 );
274 if ( valueGet.first.type == Property::Key::INDEX )
276 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
280 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
290 class ScrollStateChangeCallback : public Dali::ConnectionTracker
293 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
294 : mStartedCalled( startedCalled ),
295 mFinishedCalled( finishedCalled )
299 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
301 if( type == TextEditor::Scroll::STARTED )
303 mStartedCalled = true;
305 else if( type == TextEditor::Scroll::FINISHED )
307 mFinishedCalled = true;
311 bool& mStartedCalled;
312 bool& mFinishedCalled;
317 int UtcDaliToolkitTextEditorConstructorP(void)
319 ToolkitTestApplication application;
320 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
321 TextEditor textEditor;
322 DALI_TEST_CHECK( !textEditor );
326 int UtcDaliToolkitTextEditorNewP(void)
328 ToolkitTestApplication application;
329 tet_infoline(" UtcDaliToolkitTextEditorNewP");
330 TextEditor textEditor = TextEditor::New();
331 DALI_TEST_CHECK( textEditor );
335 int UtcDaliToolkitTextEditorDownCastP(void)
337 ToolkitTestApplication application;
338 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
339 TextEditor textEditor1 = TextEditor::New();
340 BaseHandle object( textEditor1 );
342 TextEditor textEditor2 = TextEditor::DownCast( object );
343 DALI_TEST_CHECK( textEditor2 );
345 TextEditor textEditor3 = DownCast< TextEditor >( object );
346 DALI_TEST_CHECK( textEditor3 );
350 int UtcDaliToolkitTextEditorDownCastN(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
354 BaseHandle uninitializedObject;
355 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
356 DALI_TEST_CHECK( !textEditor1 );
358 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
359 DALI_TEST_CHECK( !textEditor2 );
363 int UtcDaliToolkitTextEditorCopyConstructorP(void)
365 ToolkitTestApplication application;
366 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
367 TextEditor textEditor = TextEditor::New();
368 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
370 TextEditor copy( textEditor );
371 DALI_TEST_CHECK( copy );
372 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
376 int UtcDaliTextEditorMoveConstructor(void)
378 ToolkitTestApplication application;
380 TextEditor textEditor = TextEditor::New();
381 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
382 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
384 TextEditor moved = std::move( textEditor );
385 DALI_TEST_CHECK( moved );
386 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
387 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
388 DALI_TEST_CHECK( !textEditor );
393 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
395 ToolkitTestApplication application;
396 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
397 TextEditor textEditor = TextEditor::New();
398 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
400 TextEditor copy = textEditor;
401 DALI_TEST_CHECK( copy );
402 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
406 int UtcDaliTextEditorMoveAssignment(void)
408 ToolkitTestApplication application;
410 TextEditor textEditor = TextEditor::New();
411 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
412 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
415 moved = std::move( textEditor );
416 DALI_TEST_CHECK( moved );
417 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
418 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
419 DALI_TEST_CHECK( !textEditor );
424 int UtcDaliTextEditorNewP(void)
426 ToolkitTestApplication application;
427 tet_infoline(" UtcDaliToolkitTextEditorNewP");
428 TextEditor textEditor = TextEditor::New();
429 DALI_TEST_CHECK( textEditor );
433 // Positive test case for a method
434 int UtcDaliTextEditorGetPropertyP(void)
436 ToolkitTestApplication application;
437 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
438 TextEditor editor = TextEditor::New();
439 DALI_TEST_CHECK( editor );
441 // Check Property Indices are correct
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
505 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
508 Property::Map imageMap;
509 imageMap[mapKey] =mapValue;
511 editor.SetProperty( property , imageMap );
512 Property::Value propValue = editor.GetProperty( property );
513 Property::Map* resultMap = propValue.GetMap();
515 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
523 // Positive test case for a method
524 int UtcDaliTextEditorSetPropertyP(void)
526 ToolkitTestApplication application;
527 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
528 TextEditor editor = TextEditor::New();
529 DALI_TEST_CHECK( editor );
530 application.GetScene().Add( editor );
532 // Note - we can't check the defaults since the stylesheets are platform-specific
534 // Check the render backend property.
535 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
536 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
538 // Check text property.
539 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
540 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
542 // Check text's color property
543 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
544 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
546 // Check font properties.
547 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
548 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
550 Property::Map fontStyleMapSet;
551 Property::Map fontStyleMapGet;
552 Property::Value* slantValue = NULL;
554 fontStyleMapSet.Insert( "weight", "bold" );
555 fontStyleMapSet.Insert( "width", "condensed" );
556 fontStyleMapSet.Insert( "slant", "italic" );
558 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
559 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
560 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
561 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
563 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
564 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
566 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
567 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
568 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
571 fontStyleMapSet.Clear();
572 fontStyleMapSet.Insert( "weight", "normal" );
573 fontStyleMapSet.Insert( "slant", "oblique" );
574 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
575 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
576 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
577 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
579 fontStyleMapSet.Clear();
580 fontStyleMapSet.Insert( "slant", "roman" );
581 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
582 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
584 // Replace 'roman' for 'normal'.
585 slantValue = fontStyleMapGet.Find( "slant" );
586 if( NULL != slantValue )
588 if( "normal" == slantValue->Get<std::string>() )
590 fontStyleMapGet["slant"] = "roman";
593 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
594 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
596 fontStyleMapSet.Clear();
598 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
599 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
600 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
601 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
603 // Check that the Alignment properties can be correctly set
604 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
605 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
607 // Check scroll properties.
608 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
609 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
610 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
611 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
613 // Check cursor properties
614 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
615 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
616 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
617 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
619 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
620 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
621 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
622 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
623 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
624 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
625 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
626 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
628 // Check handle images
629 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
630 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
631 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
632 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
633 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
635 // Check handle images
636 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
637 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
638 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
639 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
640 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
641 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
643 // Check the highlight color
644 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
645 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
647 // Decoration bounding box
648 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
649 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
651 // Check the enable markup property.
652 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
653 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
654 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
656 // Check input color property.
657 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
658 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
660 // Check input font properties.
661 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
662 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
664 fontStyleMapSet.Clear();
665 fontStyleMapSet.Insert( "weight", "bold" );
666 fontStyleMapSet.Insert( "width", "condensed" );
667 fontStyleMapSet.Insert( "slant", "italic" );
669 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
670 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
671 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
672 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
674 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
675 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
677 // Reset input font style.
678 fontStyleMapSet.Clear();
679 fontStyleMapSet.Insert( "weight", "normal" );
680 fontStyleMapSet.Insert( "slant", "oblique" );
682 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
683 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
684 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
685 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
687 fontStyleMapSet.Clear();
688 fontStyleMapSet.Insert( "slant", "roman" );
690 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
691 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
693 // Replace 'roman' for 'normal'.
694 slantValue = fontStyleMapGet.Find( "slant" );
695 if( NULL != slantValue )
697 if( "normal" == slantValue->Get<std::string>() )
699 fontStyleMapGet["slant"] = "roman";
702 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
703 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
705 fontStyleMapSet.Clear();
707 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
708 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
709 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
710 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
712 // Check the line spacing property
713 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
714 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
715 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 // Check the input line spacing property
718 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
719 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
720 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
722 // Check the underline property
724 Property::Map underlineMapSet;
725 Property::Map underlineMapGet;
727 underlineMapSet.Insert( "enable", true );
728 underlineMapSet.Insert( "color", Color::RED );
729 underlineMapSet.Insert( "height", 1 );
731 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
733 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
734 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
735 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
737 // Check the input underline property
738 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
739 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
741 // Check the shadow property
742 Property::Map shadowMapSet;
743 Property::Map shadowMapGet;
745 shadowMapSet.Insert( "color", Color::GREEN );
746 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
747 shadowMapSet.Insert( "blurRadius", 3.0f );
749 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
751 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
752 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
753 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
755 // Check the input shadow property
756 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
757 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
759 // Check the emboss property
760 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
761 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
763 // Check the input emboss property
764 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
765 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
767 // Check the outline property
769 // Test string type first
770 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
771 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
772 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
774 // Then test the property map type
775 Property::Map outlineMapSet;
776 Property::Map outlineMapGet;
778 outlineMapSet["color"] = Color::RED;
779 outlineMapSet["width"] = 2.0f;
781 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
783 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
784 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
785 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
787 // Check the input outline property
788 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
789 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
791 // Check the smooth scroll property
792 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
793 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
794 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
796 // Check the smooth scroll duration property
797 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
798 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
800 // Check the scroll bar property
801 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
802 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
803 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
805 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
806 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
807 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
808 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
810 // Check the pixel size of font
811 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
812 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
814 // Check placeholder text properties.
815 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
816 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
818 // Check placeholder text's color property.
819 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
820 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
822 // Check the enable selection property
823 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
824 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
826 // Check the placeholder property with pixel size
827 Property::Map placeholderPixelSizeMapSet;
828 Property::Map placeholderPixelSizeMapGet;
829 Property::Map placeholderFontstyleMap;
830 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
831 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
832 placeholderPixelSizeMapSet["color"] = Color::BLUE;
833 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
834 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
836 placeholderFontstyleMap.Insert( "weight", "bold" );
837 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
838 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
840 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
841 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
843 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
844 Property::Map placeholderConversionMap;
845 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
846 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
847 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
848 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
849 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
850 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
852 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
854 // Check the placeholder property with point size
855 Property::Map placeholderMapSet;
856 Property::Map placeholderMapGet;
857 placeholderMapSet["text"] = "Setting Placeholder Text";
858 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
859 placeholderMapSet["color"] = Color::RED;
860 placeholderMapSet["fontFamily"] = "Arial";
861 placeholderMapSet["pointSize"] = 12.0f;
862 // Check the placeholder font style property
863 placeholderFontstyleMap.Clear();
865 placeholderFontstyleMap.Insert( "weight", "bold" );
866 placeholderFontstyleMap.Insert( "width", "condensed" );
867 placeholderFontstyleMap.Insert( "slant", "italic" );
868 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
869 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
871 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
872 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
874 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
875 placeholderConversionMap.Clear();
876 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
877 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
878 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
879 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
880 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
881 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
882 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
885 placeholderFontstyleMap.Clear();
886 placeholderFontstyleMap.Insert( "weight", "normal" );
887 placeholderFontstyleMap.Insert( "slant", "oblique" );
888 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
889 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
891 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
892 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
893 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
894 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
896 placeholderFontstyleMap.Clear();
897 placeholderFontstyleMap.Insert( "slant", "roman" );
898 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
899 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
901 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
903 placeholderFontstyleMap.Clear();
904 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
906 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
907 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
908 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
909 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
910 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
912 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
913 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
915 // Check handle color
916 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
917 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
919 application.SendNotification();
920 application.Render();
925 // Positive Atlas Text Renderer test
926 int utcDaliTextEditorAtlasRenderP(void)
928 ToolkitTestApplication application;
929 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
930 StyleManager styleManager = StyleManager::Get();
931 styleManager.ApplyDefaultTheme();
932 TextEditor editor = TextEditor::New();
933 DALI_TEST_CHECK( editor );
935 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
937 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
939 application.GetScene().Add( editor );
943 // Render some text with the shared atlas backend
944 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
945 application.SendNotification();
946 application.Render();
950 tet_result(TET_FAIL);
955 // Positive test for the textChanged signal.
956 int utcDaliTextEditorTextChangedP(void)
958 ToolkitTestApplication application;
959 tet_infoline(" utcDaliTextEditorTextChangedP");
960 TextEditor editor = TextEditor::New();
961 DALI_TEST_CHECK( editor );
963 application.GetScene().Add( editor );
965 // connect to the text changed signal.
966 ConnectionTracker* testTracker = new ConnectionTracker();
967 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
968 bool textChangedSignal = false;
969 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
971 gTextChangedCallBackCalled = false;
972 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
973 application.SendNotification();
974 application.Render();
975 DALI_TEST_CHECK( gTextChangedCallBackCalled );
976 DALI_TEST_CHECK( textChangedSignal );
978 editor.SetKeyInputFocus();
980 gTextChangedCallBackCalled = false;
981 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
982 application.SendNotification();
983 application.Render();
984 DALI_TEST_CHECK( gTextChangedCallBackCalled );
987 editor.SetProperty( TextField::Property::TEXT, "" );
988 application.SendNotification();
989 application.Render();
991 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
992 gTextChangedCallBackCalled = false;
993 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
994 application.SendNotification();
995 application.Render();
996 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
998 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
999 gTextChangedCallBackCalled = false;
1000 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1001 application.SendNotification();
1002 application.Render();
1003 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1008 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1010 ToolkitTestApplication application;
1011 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1012 TextEditor editor = TextEditor::New();
1013 DALI_TEST_CHECK( editor );
1016 application.GetScene().Add( editor );
1018 // connect to the text changed signal.
1019 ConnectionTracker* testTracker = new ConnectionTracker();
1020 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1021 bool textChangedSignal = false;
1022 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1025 // get InputMethodContext
1027 InputMethodContext::EventData imfEvent;
1028 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1030 editor.SetKeyInputFocus();
1031 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1034 gTextChangedCallBackCalled = false;
1035 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1036 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1037 application.SendNotification();
1038 application.Render();
1039 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1040 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1042 gTextChangedCallBackCalled = false;
1043 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1044 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1045 application.SendNotification();
1046 application.Render();
1047 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1048 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1050 gTextChangedCallBackCalled = false;
1051 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1052 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1053 application.SendNotification();
1054 application.Render();
1055 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1056 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1058 gTextChangedCallBackCalled = false;
1059 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1060 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1061 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1063 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1064 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1065 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1067 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1068 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1069 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1071 application.SendNotification();
1072 application.Render();
1073 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1074 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1080 int utcDaliTextEditorInputStyleChanged01(void)
1082 // The text-editor emits signals when the input style changes. These changes of style are
1083 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1084 // can't be emitted during the size negotiation as the callbacks may update the UI.
1085 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1086 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1087 ToolkitTestApplication application;
1088 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1092 char* pathNamePtr = get_current_dir_name();
1093 const std::string pathName( pathNamePtr );
1094 free( pathNamePtr );
1096 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1097 fontClient.SetDpi( 93u, 93u );
1099 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1100 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1102 TextEditor editor = TextEditor::New();
1103 DALI_TEST_CHECK( editor );
1106 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1107 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1108 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1110 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1111 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1113 // connect to the text changed signal.
1114 ConnectionTracker* testTracker = new ConnectionTracker();
1115 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1116 bool inputStyleChangedSignal = false;
1117 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1119 application.GetScene().Add( editor );
1121 // Render and notify
1122 application.SendNotification();
1123 application.Render();
1125 // Executes the idle callbacks added by the text control on the change of input style.
1126 application.RunIdles();
1128 gInputStyleChangedCallbackCalled = false;
1129 gInputStyleMask = TextEditor::InputStyle::NONE;
1130 inputStyleChangedSignal = false;
1132 // Create a tap event to touch the text editor.
1133 TestGenerateTap( application, 18.0f, 25.0f );
1135 // Render and notify
1136 application.SendNotification();
1137 application.Render();
1139 // Executes the idle callbacks added by the text control on the change of input style.
1140 application.RunIdles();
1142 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1143 if( gInputStyleChangedCallbackCalled )
1145 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1147 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1148 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1150 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1151 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1153 DALI_TEST_CHECK( inputStyleChangedSignal );
1155 gInputStyleChangedCallbackCalled = false;
1156 gInputStyleMask = TextEditor::InputStyle::NONE;
1157 inputStyleChangedSignal = false;
1159 // Create a tap event to touch the text editor.
1160 TestGenerateTap( application, 30.0f, 25.0f );
1162 // Render and notify
1163 application.SendNotification();
1164 application.Render();
1166 // Executes the idle callbacks added by the text control on the change of input style.
1167 application.RunIdles();
1169 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1170 DALI_TEST_CHECK( !inputStyleChangedSignal );
1172 gInputStyleChangedCallbackCalled = false;
1173 gInputStyleMask = TextEditor::InputStyle::NONE;
1174 inputStyleChangedSignal = false;
1176 // Create a tap event to touch the text editor.
1177 TestGenerateTap( application, 43.0f, 25.0f );
1179 // Render and notify
1180 application.SendNotification();
1181 application.Render();
1183 // Executes the idle callbacks added by the text control on the change of input style.
1184 application.RunIdles();
1186 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1187 if( gInputStyleChangedCallbackCalled )
1189 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1191 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1192 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1194 DALI_TEST_CHECK( inputStyleChangedSignal );
1196 gInputStyleChangedCallbackCalled = false;
1197 gInputStyleMask = TextEditor::InputStyle::NONE;
1198 inputStyleChangedSignal = false;
1200 // Create a tap event to touch the text editor.
1201 TestGenerateTap( application, 88.0f, 25.0f );
1203 // Render and notify
1204 application.SendNotification();
1205 application.Render();
1207 // Executes the idle callbacks added by the text control on the change of input style.
1208 application.RunIdles();
1210 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1211 if( gInputStyleChangedCallbackCalled )
1213 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1215 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1216 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1218 Property::Map fontStyleMapSet;
1219 Property::Map fontStyleMapGet;
1221 fontStyleMapSet.Insert( "weight", "bold" );
1223 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1224 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1225 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1227 DALI_TEST_CHECK( inputStyleChangedSignal );
1229 gInputStyleChangedCallbackCalled = false;
1230 gInputStyleMask = TextEditor::InputStyle::NONE;
1231 inputStyleChangedSignal = false;
1233 // Create a tap event to touch the text editor.
1234 TestGenerateTap( application, 115.0f, 25.0f );
1236 // Render and notify
1237 application.SendNotification();
1238 application.Render();
1240 // Executes the idle callbacks added by the text control on the change of input style.
1241 application.RunIdles();
1243 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1244 DALI_TEST_CHECK( !inputStyleChangedSignal );
1246 gInputStyleChangedCallbackCalled = false;
1247 gInputStyleMask = TextEditor::InputStyle::NONE;
1248 inputStyleChangedSignal = false;
1250 // Create a tap event to touch the text editor.
1251 TestGenerateTap( application, 164.0f, 25.0f );
1253 // Render and notify
1254 application.SendNotification();
1255 application.Render();
1257 // Executes the idle callbacks added by the text control on the change of input style.
1258 application.RunIdles();
1260 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1261 if( gInputStyleChangedCallbackCalled )
1263 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1265 Property::Map fontStyleMapSet;
1266 Property::Map fontStyleMapGet;
1268 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1269 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1270 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1272 DALI_TEST_CHECK( inputStyleChangedSignal );
1274 gInputStyleChangedCallbackCalled = false;
1275 gInputStyleMask = TextEditor::InputStyle::NONE;
1276 inputStyleChangedSignal = false;
1278 // Create a tap event to touch the text editor.
1279 TestGenerateTap( application, 191.0f, 25.0f );
1281 // Render and notify
1282 application.SendNotification();
1283 application.Render();
1285 // Executes the idle callbacks added by the text control on the change of input style.
1286 application.RunIdles();
1288 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1289 DALI_TEST_CHECK( !inputStyleChangedSignal );
1294 int utcDaliTextEditorInputStyleChanged02(void)
1296 // The text-editor emits signals when the input style changes. These changes of style are
1297 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1298 // can't be emitted during the size negotiation as the callbacks may update the UI.
1299 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1300 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1301 ToolkitTestApplication application;
1302 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1306 char* pathNamePtr = get_current_dir_name();
1307 const std::string pathName( pathNamePtr );
1308 free( pathNamePtr );
1310 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1311 fontClient.SetDpi( 93u, 93u );
1313 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1314 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1316 TextEditor editor = TextEditor::New();
1317 DALI_TEST_CHECK( editor );
1320 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1321 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1322 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1324 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1325 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>" );
1327 // connect to the text changed signal.
1328 ConnectionTracker* testTracker = new ConnectionTracker();
1329 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1330 bool inputStyleChangedSignal = false;
1331 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1333 application.GetScene().Add( editor );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Executes the idle callbacks added by the text control on the change of input style.
1340 application.RunIdles();
1342 gInputStyleChangedCallbackCalled = false;
1343 gInputStyleMask = TextEditor::InputStyle::NONE;
1344 inputStyleChangedSignal = false;
1346 // Create a tap event to touch the text editor.
1347 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1348 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1350 // Render and notify
1351 application.SendNotification();
1352 application.Render();
1354 // Executes the idle callbacks added by the text control on the change of input style.
1355 application.RunIdles();
1357 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1358 if( gInputStyleChangedCallbackCalled )
1360 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1361 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1362 TextEditor::InputStyle::POINT_SIZE |
1363 TextEditor::InputStyle::COLOR ),
1366 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1367 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1369 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1370 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1372 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1373 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1375 DALI_TEST_CHECK( inputStyleChangedSignal );
1377 gInputStyleChangedCallbackCalled = false;
1378 gInputStyleMask = TextEditor::InputStyle::NONE;
1379 inputStyleChangedSignal = false;
1381 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1383 // Render and notify
1384 application.SendNotification();
1385 application.Render();
1387 // Executes the idle callbacks added by the text control on the change of input style.
1388 application.RunIdles();
1390 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1391 if( gInputStyleChangedCallbackCalled )
1393 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1394 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1397 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1398 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1400 DALI_TEST_CHECK( inputStyleChangedSignal );
1402 gInputStyleChangedCallbackCalled = false;
1403 gInputStyleMask = TextEditor::InputStyle::NONE;
1404 inputStyleChangedSignal = false;
1406 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1408 // Render and notify
1409 application.SendNotification();
1410 application.Render();
1412 // Executes the idle callbacks added by the text control on the change of input style.
1413 application.RunIdles();
1415 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1416 DALI_TEST_CHECK( !inputStyleChangedSignal );
1418 gInputStyleChangedCallbackCalled = false;
1419 gInputStyleMask = TextEditor::InputStyle::NONE;
1420 inputStyleChangedSignal = false;
1422 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1424 // Render and notify
1425 application.SendNotification();
1426 application.Render();
1428 // Executes the idle callbacks added by the text control on the change of input style.
1429 application.RunIdles();
1431 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1432 if( gInputStyleChangedCallbackCalled )
1434 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1435 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1438 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1439 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1441 DALI_TEST_CHECK( inputStyleChangedSignal );
1443 gInputStyleChangedCallbackCalled = false;
1444 gInputStyleMask = TextEditor::InputStyle::NONE;
1445 inputStyleChangedSignal = false;
1447 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1449 Property::Map fontStyleMapSet;
1450 fontStyleMapSet.Insert( "weight", "thin" );
1451 fontStyleMapSet.Insert( "width", "condensed" );
1452 fontStyleMapSet.Insert( "slant", "italic" );
1454 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1455 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1456 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1458 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1459 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1460 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1461 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1463 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1465 // Render and notify
1466 application.SendNotification();
1467 application.Render();
1469 // Executes the idle callbacks added by the text control on the change of input style.
1470 application.RunIdles();
1472 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1473 DALI_TEST_CHECK( !inputStyleChangedSignal );
1475 // Create a tap event to touch the text editor.
1476 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1478 // Render and notify
1479 application.SendNotification();
1480 application.Render();
1482 // Executes the idle callbacks added by the text control on the change of input style.
1483 application.RunIdles();
1485 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1486 if( gInputStyleChangedCallbackCalled )
1488 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1489 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1490 TextEditor::InputStyle::POINT_SIZE |
1491 TextEditor::InputStyle::FONT_STYLE |
1492 TextEditor::InputStyle::LINE_SPACING |
1493 TextEditor::InputStyle::UNDERLINE |
1494 TextEditor::InputStyle::SHADOW |
1495 TextEditor::InputStyle::EMBOSS |
1496 TextEditor::InputStyle::OUTLINE ),
1499 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1500 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1502 DALI_TEST_CHECK( inputStyleChangedSignal );
1504 gInputStyleChangedCallbackCalled = false;
1505 gInputStyleMask = TextEditor::InputStyle::NONE;
1506 inputStyleChangedSignal = false;
1508 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1510 fontStyleMapSet.Clear();
1511 fontStyleMapSet.Insert( "weight", "black" );
1512 fontStyleMapSet.Insert( "width", "expanded" );
1513 fontStyleMapSet.Insert( "slant", "oblique" );
1515 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1517 // Create a tap event to touch the text editor.
1518 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Executes the idle callbacks added by the text control on the change of input style.
1525 application.RunIdles();
1527 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1528 if( gInputStyleChangedCallbackCalled )
1530 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1531 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1532 TextEditor::InputStyle::POINT_SIZE |
1533 TextEditor::InputStyle::FONT_STYLE ),
1536 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1537 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1539 DALI_TEST_CHECK( inputStyleChangedSignal );
1544 int utcDaliTextEditorEvent01(void)
1546 ToolkitTestApplication application;
1547 tet_infoline(" utcDaliTextEditorEvent01");
1549 // Creates a tap event. After creating a tap event the text editor should
1550 // have the focus and add text with key events should be possible.
1552 TextEditor editor = TextEditor::New();
1553 DALI_TEST_CHECK( editor );
1555 application.GetScene().Add( editor );
1557 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1558 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1559 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1561 // Avoid a crash when core load gl resources.
1562 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1564 // Render and notify
1565 application.SendNotification();
1566 application.Render();
1568 // Add a key event but as the text editor has not the focus it should do nothing.
1569 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1577 // Create a tap event to touch the text editor.
1578 TestGenerateTap( application, 150.0f, 25.0f );
1580 // Render and notify
1581 application.SendNotification();
1582 application.Render();
1584 // Now the text editor has the focus, so it can handle the key events.
1585 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1586 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1588 // Render and notify
1589 application.SendNotification();
1590 application.Render();
1592 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1594 // Create a second text editor and send key events to it.
1595 TextEditor editor2 = TextEditor::New();
1597 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1598 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1599 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1600 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1602 application.GetScene().Add( editor2 );
1604 // Render and notify
1605 application.SendNotification();
1606 application.Render();
1608 // Create a tap event on the second text editor.
1609 TestGenerateTap( application, 150.0f, 125.0f );
1611 // Render and notify
1612 application.SendNotification();
1613 application.Render();
1615 // The second text editor has the focus. It should handle the key events.
1616 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1617 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 // Check the text has been added to the second text editor.
1624 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1629 int utcDaliTextEditorEvent02(void)
1631 ToolkitTestApplication application;
1632 tet_infoline(" utcDaliTextEditorEvent02");
1634 // Checks if the right number of actors are created.
1636 TextEditor editor = TextEditor::New();
1637 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1638 DALI_TEST_CHECK( editor );
1640 application.GetScene().Add( editor );
1642 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1643 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1644 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1646 // Avoid a crash when core load gl resources.
1647 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 // Check there are the expected number of children (the stencil).
1654 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1656 Actor stencil = editor.GetChildAt( 0u );
1658 // Create a tap event to touch the text editor.
1659 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 Actor layer = editor.GetChildAt( 1u );
1666 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1667 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1669 // Now the text editor has the focus, so it can handle the key events.
1670 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1671 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1673 // Render and notify
1674 application.SendNotification();
1675 application.Render();
1677 // Checks the cursor and the renderer have been created.
1678 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1679 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1681 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1682 DALI_TEST_CHECK( cursor );
1684 // The stencil actor has a container with all the actors which contain the text renderers.
1685 Actor container = stencil.GetChildAt( 0u );
1686 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1688 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1689 DALI_TEST_CHECK( renderer );
1692 // Move the cursor and check the position changes.
1693 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1695 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1696 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1698 // Render and notify
1699 application.SendNotification();
1700 application.Render();
1702 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1704 DALI_TEST_CHECK( position2.x < position1.x );
1706 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1707 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1715 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1717 // Send some taps and check the cursor positions.
1719 // Try to tap at the beginning.
1720 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1722 // Render and notify
1723 application.SendNotification();
1724 application.Render();
1726 // Cursor position should be the same than position1.
1727 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1729 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1731 // Tap away from the start position.
1732 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1740 DALI_TEST_CHECK( position5.x > position4.x );
1742 // Remove all the text.
1743 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1744 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1745 editor.SetProperty( TextEditor::Property::TEXT, "" );
1747 // Render and notify
1748 application.SendNotification();
1749 application.Render();
1751 // Cursor position should be the same than position2.
1752 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1754 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1756 // Should not be a renderer.
1757 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1762 int utcDaliTextEditorEvent03(void)
1764 ToolkitTestApplication application;
1765 tet_infoline(" utcDaliTextEditorEvent03");
1767 // Checks if the highlight actor is created.
1769 TextEditor editor = TextEditor::New();
1770 DALI_TEST_CHECK( editor );
1772 application.GetScene().Add( editor );
1774 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1775 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1776 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1777 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1778 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1780 // Avoid a crash when core load gl resources.
1781 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1783 // Render and notify
1784 application.SendNotification();
1785 application.Render();
1787 // Send some taps and check text controller with clipboard window
1788 Dali::Clipboard clipboard = Clipboard::Get();
1789 clipboard.ShowClipboard();
1790 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1791 clipboard.HideClipboard();
1793 // Render and notify
1794 application.SendNotification();
1795 application.Render();
1797 // Tap first to get the focus.
1798 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1800 // Render and notify
1801 application.SendNotification();
1802 application.Render();
1804 // Double tap to select a word.
1805 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 // The stencil actor should have two actors: the renderer and the highlight actor.
1812 Actor stencil = editor.GetChildAt( 0u );
1814 // Highlight needs to be drawn before text, so should come first in child order
1815 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1816 DALI_TEST_CHECK( highlight );
1818 // The stencil actor has a container with all the actors which contain the text renderers.
1819 Actor container = stencil.GetChildAt( 1u );
1820 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1822 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1823 DALI_TEST_CHECK( renderer );
1826 // Double tap out of bounds
1827 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1828 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1830 // Render and notify
1831 application.SendNotification();
1832 application.Render();
1834 // The stencil actor should have one actors: the renderer actor.
1835 stencil = editor.GetChildAt( 0u );
1837 // The stencil actor has a container with all the actors which contain the text renderers.
1838 container = stencil.GetChildAt( 0u );
1839 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1841 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1842 DALI_TEST_CHECK( renderer );
1846 TestGenerateLongPress(application, 1.0f, 25.0f);
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1853 TestGenerateMiniPan(application);
1855 // Render and notify
1856 application.SendNotification();
1857 application.Render();
1862 int utcDaliTextEditorEvent04(void)
1864 ToolkitTestApplication application;
1865 tet_infoline(" utcDaliTextEditorEvent04");
1867 // Checks if the highlight actor is created.
1869 TextEditor editor = TextEditor::New();
1870 DALI_TEST_CHECK( editor );
1872 application.GetScene().Add( editor );
1874 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1875 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1876 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1877 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1878 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1880 // Avoid a crash when core load gl resources.
1881 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 // Tap on the text editor
1888 TestGenerateTap( application, 3.0f, 25.0f );
1890 // Render and notify
1891 application.SendNotification();
1892 application.Render();
1894 // Move at the end of the text.
1895 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1896 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 for( unsigned int index = 0u; index < 10u; ++index )
1904 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1905 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1913 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1921 // Add some key events
1922 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1923 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1925 // Render and notify
1926 application.SendNotification();
1927 application.Render();
1929 for( unsigned int index = 0u; index < 10u; ++index )
1931 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1932 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1940 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1951 int utcDaliTextEditorEvent05(void)
1953 ToolkitTestApplication application;
1954 tet_infoline(" utcDaliTextEditorEvent05");
1956 // Checks if the highlight actor is created.
1958 TextEditor editor = TextEditor::New();
1959 DALI_TEST_CHECK( editor );
1961 application.GetScene().Add( editor );
1963 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1964 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1965 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1966 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1967 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1968 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1969 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1970 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1971 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1972 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1974 // Avoid a crash when core load gl resources.
1975 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 // Tap on the text editor
1982 TestGenerateTap( application, 3.0f, 25.0f );
1984 // Render and notify
1985 application.SendNotification();
1986 application.Render();
1988 // Move at the end of the text.
1989 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1990 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 for( unsigned int index = 0u; index < 10u; ++index )
1999 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2005 // Modify duration after scroll is enabled
2006 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2008 // Continuous scroll left to increase coverage
2009 for( unsigned int index = 0u; index < 10u; ++index )
2011 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2013 // Render and notify
2014 application.SendNotification();
2015 application.Render();
2017 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2018 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2019 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2020 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2021 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2023 // Press Escape to increase coverage
2024 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2025 application.SendNotification();
2026 application.Render();
2028 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2033 int utcDaliTextEditorEvent06(void)
2035 ToolkitTestApplication application;
2036 tet_infoline(" utcDaliTextEditorEvent06");
2038 // Checks if the highlight actor is created.
2040 TextEditor editor = TextEditor::New();
2041 DALI_TEST_CHECK( editor );
2043 application.GetScene().Add( editor );
2045 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2046 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2047 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2048 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2049 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2051 // Avoid a crash when core load gl resources.
2052 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2054 // Render and notify
2055 application.SendNotification();
2056 application.Render();
2058 // Tap on the text editor
2059 TestGenerateTap( application, 3.0f, 25.0f );
2061 // Render and notify
2062 application.SendNotification();
2063 application.Render();
2065 // Move to seconds line of the text.
2066 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2068 // Render and notify
2069 application.SendNotification();
2070 application.Render();
2072 float layoutHeight = editor.GetHeightForWidth( 100.f );
2075 // Add another script characters ( glyph height is defferent )
2076 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2077 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2079 // Delete characters
2080 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2083 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2085 // Render and notify
2086 application.SendNotification();
2087 application.Render();
2089 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2092 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2093 application.SendNotification();
2094 application.Render();
2096 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2097 application.SendNotification();
2098 application.Render();
2100 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 application.SendNotification();
2102 application.Render();
2104 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2105 application.SendNotification();
2106 application.Render();
2108 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2109 application.SendNotification();
2110 application.Render();
2112 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2113 application.SendNotification();
2114 application.Render();
2116 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2117 application.SendNotification();
2118 application.Render();
2123 int utcDaliTextEditorEvent07(void)
2125 ToolkitTestApplication application;
2126 tet_infoline(" utcDaliTextEditorEvent07");
2128 // Checks if the highlight actor is created.
2130 TextEditor editor = TextEditor::New();
2131 DALI_TEST_CHECK( editor );
2133 application.GetScene().Add( editor );
2135 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2136 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2137 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2138 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2139 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2141 // Avoid a crash when core load gl resources.
2142 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 // Tap on the text editor
2149 TestGenerateTap( application, 3.0f, 25.0f );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 // Move to second line of the text.
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 // Select some text in the right of the current cursor position
2163 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2166 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 // Cut the selected text
2173 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2174 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 ) );
2176 // Render and notify
2177 application.SendNotification();
2178 application.Render();
2180 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2182 // Select some text in the left of the current cursor position
2183 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2184 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2185 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2186 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 // Render and notify
2189 application.SendNotification();
2190 application.Render();
2192 // Copy the selected text
2193 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2194 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 ) );
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2200 // Move the cursor to the third line
2201 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 // Paste the selected text at the current cursor position
2209 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 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 ) );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2219 // Disable Shift Selection
2220 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2222 // Test to select some text in the right of the current cursor position
2223 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2224 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2225 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 // Cut the selected text
2233 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2234 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2240 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2241 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2243 // Test to select some text in the left of the current cursor position
2244 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2245 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2247 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2249 // Render and notify
2250 application.SendNotification();
2251 application.Render();
2253 // Copy the selected text
2254 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 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 ) );
2257 // Render and notify
2258 application.SendNotification();
2259 application.Render();
2261 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2262 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2265 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 ) );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // replace text with "c"
2272 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2274 // Render and notify
2275 application.SendNotification();
2276 application.Render();
2279 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2282 DevelTextEditor::SelectWholeText(editor);
2284 // Render and notify
2285 application.SendNotification();
2286 application.Render();
2288 // Copy the selected text using logical keys
2289 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2297 DevelTextEditor::SelectNone(editor);
2299 // Render and notify
2300 application.SendNotification();
2301 application.Render();
2303 // Paste the selected using logical keys
2304 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2305 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2310 // select all using logical keys
2311 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2312 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2318 // cut text using logical keys
2319 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2320 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2327 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2332 int utcDaliTextEditorEvent08(void)
2334 ToolkitTestApplication application;
2335 tet_infoline(" utcDaliTextEditorEvent08");
2337 // Checks if the highlight actor is released correctly.
2339 TextEditor editor = TextEditor::New();
2340 DALI_TEST_CHECK( editor );
2342 application.GetScene().Add( editor );
2344 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2345 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2346 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2347 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2348 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2350 // Avoid a crash when core load gl resources.
2351 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2353 // Render and notify
2354 application.SendNotification();
2355 application.Render();
2357 // Tap on the text editor
2358 TestGenerateTap( application, 3.0f, 25.0f );
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2364 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2365 // Test to select some text in the left of the current cursor position
2366 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371 // Render and notify
2372 application.SendNotification();
2373 application.Render();
2375 // Test to the left selection handle position and the right selection handle position
2376 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2379 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 // Render and notify
2382 application.SendNotification();
2383 application.Render();
2385 // Test to select full text in the left of the current cursor position
2386 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2387 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2388 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 // Test to release the current full text selection
2398 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2399 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2401 // Render and notify
2402 application.SendNotification();
2403 application.Render();
2405 // Test to move the current cursor position correctly
2406 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2413 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2419 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2421 // Test to select some text in the right of the current cursor position
2422 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2423 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 // Test the cursor position with right arrow key
2431 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2433 // Render and notify
2434 application.SendNotification();
2435 application.Render();
2438 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 // Render and notify
2441 application.SendNotification();
2442 application.Render();
2444 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2446 // Test to select some text in the left of the current cursor position
2447 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2448 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2449 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2450 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2453 // Render and notify
2454 application.SendNotification();
2455 application.Render();
2457 // Test the cursor position with left arrow key
2458 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2460 // Render and notify
2461 application.SendNotification();
2462 application.Render();
2465 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 // Render and notify
2468 application.SendNotification();
2469 application.Render();
2471 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2473 // Test to select some text in the right of the current cursor position
2474 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2475 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2476 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2477 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2479 // Render and notify
2480 application.SendNotification();
2481 application.Render();
2483 // Test the cursor position with left arrow key
2484 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2486 // Render and notify
2487 application.SendNotification();
2488 application.Render();
2491 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2493 // Render and notify
2494 application.SendNotification();
2495 application.Render();
2497 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2499 // Test to select some text in the left of the current cursor position
2500 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2501 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2502 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2503 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 // Test the cursor position with right arrow key
2510 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2512 // Render and notify
2513 application.SendNotification();
2514 application.Render();
2517 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2519 // Render and notify
2520 application.SendNotification();
2521 application.Render();
2523 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2528 int utcDaliTextEditorHandles(void)
2530 ToolkitTestApplication application;
2531 tet_infoline(" utcDaliTextEditorHandles");
2533 TextEditor editor = TextEditor::New();
2534 DALI_TEST_CHECK( editor );
2536 application.GetScene().Add( editor );
2538 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2539 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2540 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2541 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2543 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2544 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2545 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2546 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2548 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2549 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2550 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2552 // Avoid a crash when core load gl resources.
2553 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2555 // Render and notify
2556 application.SendNotification();
2557 application.Render();
2559 // Tap first to get the focus.
2560 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 // Tap to create the grab handle.
2567 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2569 // Render and notify
2570 application.SendNotification();
2571 application.Render();
2573 // Get the active layer where the text's decoration is added.
2574 Actor activeLayer = editor.GetChildAt( 1u );
2576 // Get the handle's actor.
2577 Actor handle = activeLayer.GetChildAt( 1u );
2578 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2580 // Render and notify
2581 application.SendNotification();
2582 application.Render();
2584 // Touch the grab handle to set it as pressed.
2585 Vector2 touchPos( 10.0f, 50.0f );
2586 Dali::Integration::TouchEvent event;
2587 event = Dali::Integration::TouchEvent();
2588 event.AddPoint( GetPointDownInside( touchPos ) );
2589 application.ProcessEvent( event );
2591 // Render and notify
2592 application.SendNotification();
2593 application.Render();
2595 // Pan the grab handle
2596 uint32_t time = 100;
2597 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2598 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2599 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2600 application.SendNotification();
2601 application.Render();
2604 // Release the grab handle.
2605 event = Dali::Integration::TouchEvent();
2606 event.AddPoint( GetPointUpInside( touchPos ) );
2607 application.ProcessEvent( event );
2609 // Render and notify
2610 application.SendNotification();
2611 application.Render();
2613 // Tap first to get the focus.
2614 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2616 // Render and notify
2617 application.SendNotification();
2618 application.Render();
2620 // Double tap to select a word and create the selection handles.
2621 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2623 // Render and notify
2624 application.SendNotification();
2625 application.Render();
2627 touchPos = Vector2( 10.0f, 50.0f );
2629 // Touch the left selection handle to set it as pressed.
2630 event = Dali::Integration::TouchEvent();
2631 event.AddPoint( GetPointDownInside( touchPos ) );
2632 application.ProcessEvent( event );
2634 // Render and notify
2635 application.SendNotification();
2636 application.Render();
2638 // Release the left selection handle.
2639 event = Dali::Integration::TouchEvent();
2640 event.AddPoint( GetPointUpInside( touchPos ) );
2641 application.ProcessEvent( event );
2643 // Render and notify
2644 application.SendNotification();
2645 application.Render();
2650 int utcDaliTextEditorUnderPropertyStringP(void)
2652 ToolkitTestApplication application;
2653 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2654 TextEditor editor = TextEditor::New();
2655 DALI_TEST_CHECK( editor );
2657 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2659 application.GetScene().Add( editor );
2661 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2662 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2664 tet_infoline("Set underline settings with a map");
2665 // Check the input underline property
2666 Property::Map underlineMapSet;
2667 Property::Map underlineMapGet;
2668 underlineMapSet.Insert( "enable", true );
2669 underlineMapSet.Insert( "color", Color::BLUE );
2670 underlineMapSet.Insert( "height", 2 );
2672 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2673 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2674 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2675 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2677 tet_infoline("Set underline settings with a string");
2678 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2679 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2682 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2684 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2685 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2686 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2687 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2689 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2694 int utcDaliTextEditorShadowPropertyStringP(void)
2696 ToolkitTestApplication application;
2697 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2699 TextEditor editor = TextEditor::New();
2701 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2703 application.GetScene().Add( editor );
2705 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2707 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2711 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2716 int utcDaliTextEditorFontStylePropertyStringP(void)
2718 ToolkitTestApplication application;
2719 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2721 TextEditor editor = TextEditor::New();
2723 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2725 application.GetScene().Add( editor );
2727 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2729 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2733 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2738 int utcDaliTextEditorGetPropertyLinecountP(void)
2740 ToolkitTestApplication application;
2742 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2746 TextEditor editor = TextEditor::New();
2747 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2748 editor.SetProperty( TextEditor::Property::TEXT,
2749 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2751 application.GetScene().Add( editor );
2753 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2754 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2755 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2757 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2758 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2759 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2764 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2767 ToolkitTestApplication application;
2768 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2770 TextEditor editor = TextEditor::New();
2771 DALI_TEST_CHECK( editor );
2773 application.GetScene().Add( editor );
2775 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2776 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2777 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2778 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2779 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2780 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2782 bool startedCalled = false;
2783 bool finishedCalled = false;
2785 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2786 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2788 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2790 // Render and notify
2791 application.SendNotification();
2792 application.Render();
2794 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2795 application.SendNotification();
2796 application.Render(6000);
2798 application.SendNotification();
2799 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2800 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2805 int UtcDaliToolkitTextEditorTextWrapMode(void)
2807 ToolkitTestApplication application;
2808 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2812 TextEditor editor = TextEditor::New();
2813 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2814 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2816 application.GetScene().Add( editor );
2818 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2819 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2821 application.SendNotification();
2822 application.Render();
2824 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2825 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2827 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2828 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2830 application.SendNotification();
2831 application.Render();
2833 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2834 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2836 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2837 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2839 application.SendNotification();
2840 application.Render();
2842 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2843 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2845 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2846 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2848 application.SendNotification();
2849 application.Render();
2851 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2852 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2857 int UtcDaliTextEditorSetPaddingProperty(void)
2859 ToolkitTestApplication application;
2860 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2862 TextEditor editor = TextEditor::New();
2863 DALI_TEST_CHECK( editor );
2864 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2865 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2866 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2867 application.GetScene().Add( editor );
2869 application.SendNotification();
2870 application.Render();
2872 Vector3 originalSize = editor.GetNaturalSize();
2874 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2876 application.SendNotification();
2877 application.Render();
2879 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2881 Vector3 paddingAddedSize = editor.GetNaturalSize();
2883 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2885 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2890 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2892 ToolkitTestApplication application;
2893 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2895 TextEditor editor = TextEditor::New();
2896 DALI_TEST_CHECK( editor );
2897 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2898 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2899 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2900 application.GetScene().Add( editor );
2902 application.SendNotification();
2903 application.Render();
2905 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2906 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2908 // Check the enable shift selection property
2909 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2910 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2912 application.SendNotification();
2913 application.Render();
2918 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2920 ToolkitTestApplication application;
2921 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2923 TextEditor editor = TextEditor::New();
2924 DALI_TEST_CHECK( editor );
2925 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2926 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2927 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2928 application.GetScene().Add( editor );
2930 application.SendNotification();
2931 application.Render();
2933 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2934 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2936 // Check the enable grab handle property
2937 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2938 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2940 application.SendNotification();
2941 application.Render();
2946 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2948 ToolkitTestApplication application;
2949 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2951 TextEditor editor = TextEditor::New();
2952 DALI_TEST_CHECK( editor );
2953 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2954 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2955 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2956 application.GetScene().Add( editor );
2958 application.SendNotification();
2959 application.Render();
2961 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2962 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2964 // Check the enable match system language direction property
2965 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2966 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2968 application.SendNotification();
2969 application.Render();
2974 int UtcDaliTextEditorGetInputMethodContext(void)
2976 ToolkitTestApplication application;
2977 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2979 TextEditor editor = TextEditor::New();
2980 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2985 int utcDaliTextEditorMaxCharactersReached(void)
2987 ToolkitTestApplication application;
2988 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2990 TextEditor editor = TextEditor::New();
2991 DALI_TEST_CHECK( editor );
2993 application.GetScene().Add( editor );
2995 const int maxNumberOfCharacters = 1;
2996 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2997 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2999 editor.SetKeyInputFocus();
3001 // connect to the text changed signal.
3002 ConnectionTracker* testTracker = new ConnectionTracker();
3003 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3004 bool maxLengthReachedSignal = false;
3005 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3007 gMaxCharactersCallBackCalled = false;
3009 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3010 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3012 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3013 DALI_TEST_CHECK( maxLengthReachedSignal );
3018 int UtcDaliTextEditorSelectWholeText(void)
3020 ToolkitTestApplication application;
3021 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3023 TextEditor textEditor = TextEditor::New();
3025 application.GetScene().Add( textEditor );
3027 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3028 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3029 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3031 // Avoid a crash when core load gl resources.
3032 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3034 application.SendNotification();
3035 application.Render();
3037 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3039 DevelTextEditor::SelectWholeText( textEditor );
3041 application.SendNotification();
3042 application.Render();
3044 // Nothing should have been selected. The number of children is still 1
3045 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3047 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3049 application.SendNotification();
3050 application.Render();
3052 DevelTextEditor::SelectWholeText( textEditor );
3054 application.SendNotification();
3055 application.Render();
3057 // Should be 2 children, the stencil and the layer
3058 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3060 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3061 Actor stencil = textEditor.GetChildAt( 0u );
3063 // The highlight actor is drawn first, so is the first actor in the list
3064 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3065 DALI_TEST_CHECK( highlight );
3070 int UtcDaliTextEditorSelectNone(void)
3072 ToolkitTestApplication application;
3073 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3075 TextEditor textEditor = TextEditor::New();
3077 application.GetScene().Add( textEditor );
3079 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3080 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3081 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3083 // Avoid a crash when core load gl resources.
3084 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3086 application.SendNotification();
3087 application.Render();
3089 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3091 application.SendNotification();
3092 application.Render();
3094 // Nothing is selected
3095 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3096 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3098 DevelTextEditor::SelectWholeText( textEditor );
3100 application.SendNotification();
3101 application.Render();
3103 // whole text is selected
3104 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3105 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3107 DevelTextEditor::SelectNone( textEditor );
3109 application.SendNotification();
3110 application.Render();
3112 // Nothing is selected
3113 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3114 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3119 int UtcDaliTextEditorSelectRange(void)
3121 ToolkitTestApplication application;
3122 tet_infoline("utcDaliTextEditorSelectRange");
3124 TextEditor textEditor = TextEditor::New();
3125 DALI_TEST_CHECK( textEditor );
3127 application.GetScene().Add( textEditor );
3129 // Avoid a crash when core load gl resources.
3130 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3132 application.SendNotification();
3133 application.Render();
3135 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3137 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3138 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3140 // Hello is selected
3141 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3142 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3144 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3145 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3150 int UtcDaliTextEditorEnableEditing(void)
3152 ToolkitTestApplication application;
3153 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3155 TextEditor textEditor = TextEditor::New();
3157 application.GetScene().Add( textEditor );
3159 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3160 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3161 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3163 // Avoid a crash when core load gl resources.
3164 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3166 application.SendNotification();
3167 application.Render();
3169 textEditor.SetKeyInputFocus();
3170 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3171 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3173 // Render and notify
3174 application.SendNotification();
3175 application.Render();
3177 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3178 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3180 textEditor.SetKeyInputFocus();
3181 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3182 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3184 // Render and notify
3185 application.SendNotification();
3186 application.Render();
3188 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3189 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3194 int UtcDaliTextEditorScrolling(void)
3196 ToolkitTestApplication application;
3197 tet_infoline(" UtcDaliTextEditorScrolling ");
3199 TextEditor textEditor = TextEditor::New();
3200 DALI_TEST_CHECK( textEditor );
3202 application.GetScene().Add( textEditor );
3204 // Avoid a crash when core load gl resources.
3205 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3207 application.SendNotification();
3208 application.Render();
3210 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3211 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3212 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3213 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3215 application.SendNotification();
3216 application.Render();
3218 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3219 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3222 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3224 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3225 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3227 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3229 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3230 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3232 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3233 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3235 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3236 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3241 int UtcDaliToolkitTextEditorFontSizeScale(void)
3243 ToolkitTestApplication application;
3244 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3246 TextEditor textEditor = TextEditor::New();
3247 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3248 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3249 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3251 TextEditor textEditorScaled = TextEditor::New();
3252 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3253 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3254 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3255 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3257 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3259 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3260 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3261 nonScaledSize = textEditor.GetNaturalSize();
3263 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3264 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3265 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3266 scaledSize = textEditorScaled.GetNaturalSize();
3268 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3273 int UtcDaliTextEditorPrimaryCursorPosition(void)
3275 ToolkitTestApplication application;
3276 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3278 TextEditor textEditor = TextEditor::New();
3280 application.GetScene().Add( textEditor );
3282 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3283 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3284 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3285 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3287 // Avoid a crash when core load gl resources.
3288 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3290 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3291 application.SendNotification();
3292 application.Render();
3294 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3296 // Render and notify
3297 application.SendNotification();
3298 application.Render();
3300 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3301 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );