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 DALI_TEST_CHECK( gTextChangedCallBackCalled );
974 DALI_TEST_CHECK( textChangedSignal );
976 application.SendNotification();
977 editor.SetKeyInputFocus();
979 gTextChangedCallBackCalled = false;
980 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
981 DALI_TEST_CHECK( gTextChangedCallBackCalled );
984 editor.SetProperty( TextField::Property::TEXT, "" );
986 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
987 gTextChangedCallBackCalled = false;
988 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
989 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
991 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
992 gTextChangedCallBackCalled = false;
993 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
994 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
999 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1001 ToolkitTestApplication application;
1002 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1003 TextEditor editor = TextEditor::New();
1004 DALI_TEST_CHECK( editor );
1007 application.GetScene().Add( editor );
1009 // connect to the text changed signal.
1010 ConnectionTracker* testTracker = new ConnectionTracker();
1011 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1012 bool textChangedSignal = false;
1013 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1016 // get InputMethodContext
1018 InputMethodContext::EventData imfEvent;
1019 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1021 editor.SetKeyInputFocus();
1022 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1025 gTextChangedCallBackCalled = false;
1026 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1027 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1028 application.SendNotification();
1029 application.Render();
1030 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1031 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1033 gTextChangedCallBackCalled = false;
1034 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1035 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1036 application.SendNotification();
1037 application.Render();
1038 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1039 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1041 gTextChangedCallBackCalled = false;
1042 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1043 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1044 application.SendNotification();
1045 application.Render();
1046 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1047 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1049 gTextChangedCallBackCalled = false;
1050 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1051 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1052 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1054 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1055 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1056 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1058 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1059 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1060 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1062 application.SendNotification();
1063 application.Render();
1064 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1065 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1071 int utcDaliTextEditorInputStyleChanged01(void)
1073 // The text-editor emits signals when the input style changes. These changes of style are
1074 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1075 // can't be emitted during the size negotiation as the callbacks may update the UI.
1076 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1077 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1078 ToolkitTestApplication application;
1079 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1083 char* pathNamePtr = get_current_dir_name();
1084 const std::string pathName( pathNamePtr );
1085 free( pathNamePtr );
1087 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1088 fontClient.SetDpi( 93u, 93u );
1090 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1091 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1093 TextEditor editor = TextEditor::New();
1094 DALI_TEST_CHECK( editor );
1097 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1098 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1099 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1101 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1102 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1104 // connect to the text changed signal.
1105 ConnectionTracker* testTracker = new ConnectionTracker();
1106 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1107 bool inputStyleChangedSignal = false;
1108 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1110 application.GetScene().Add( editor );
1112 // Render and notify
1113 application.SendNotification();
1114 application.Render();
1116 // Executes the idle callbacks added by the text control on the change of input style.
1117 application.RunIdles();
1119 gInputStyleChangedCallbackCalled = false;
1120 gInputStyleMask = TextEditor::InputStyle::NONE;
1121 inputStyleChangedSignal = false;
1123 // Create a tap event to touch the text editor.
1124 TestGenerateTap( application, 18.0f, 25.0f );
1126 // Render and notify
1127 application.SendNotification();
1128 application.Render();
1130 // Executes the idle callbacks added by the text control on the change of input style.
1131 application.RunIdles();
1133 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1134 if( gInputStyleChangedCallbackCalled )
1136 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1138 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1139 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1141 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1142 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1144 DALI_TEST_CHECK( inputStyleChangedSignal );
1146 gInputStyleChangedCallbackCalled = false;
1147 gInputStyleMask = TextEditor::InputStyle::NONE;
1148 inputStyleChangedSignal = false;
1150 // Create a tap event to touch the text editor.
1151 TestGenerateTap( application, 30.0f, 25.0f );
1153 // Render and notify
1154 application.SendNotification();
1155 application.Render();
1157 // Executes the idle callbacks added by the text control on the change of input style.
1158 application.RunIdles();
1160 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1161 DALI_TEST_CHECK( !inputStyleChangedSignal );
1163 gInputStyleChangedCallbackCalled = false;
1164 gInputStyleMask = TextEditor::InputStyle::NONE;
1165 inputStyleChangedSignal = false;
1167 // Create a tap event to touch the text editor.
1168 TestGenerateTap( application, 43.0f, 25.0f );
1170 // Render and notify
1171 application.SendNotification();
1172 application.Render();
1174 // Executes the idle callbacks added by the text control on the change of input style.
1175 application.RunIdles();
1177 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1178 if( gInputStyleChangedCallbackCalled )
1180 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1182 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1183 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1185 DALI_TEST_CHECK( inputStyleChangedSignal );
1187 gInputStyleChangedCallbackCalled = false;
1188 gInputStyleMask = TextEditor::InputStyle::NONE;
1189 inputStyleChangedSignal = false;
1191 // Create a tap event to touch the text editor.
1192 TestGenerateTap( application, 88.0f, 25.0f );
1194 // Render and notify
1195 application.SendNotification();
1196 application.Render();
1198 // Executes the idle callbacks added by the text control on the change of input style.
1199 application.RunIdles();
1201 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1202 if( gInputStyleChangedCallbackCalled )
1204 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1206 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1207 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1209 Property::Map fontStyleMapSet;
1210 Property::Map fontStyleMapGet;
1212 fontStyleMapSet.Insert( "weight", "bold" );
1214 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1215 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1216 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1218 DALI_TEST_CHECK( inputStyleChangedSignal );
1220 gInputStyleChangedCallbackCalled = false;
1221 gInputStyleMask = TextEditor::InputStyle::NONE;
1222 inputStyleChangedSignal = false;
1224 // Create a tap event to touch the text editor.
1225 TestGenerateTap( application, 115.0f, 25.0f );
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Executes the idle callbacks added by the text control on the change of input style.
1232 application.RunIdles();
1234 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1235 DALI_TEST_CHECK( !inputStyleChangedSignal );
1237 gInputStyleChangedCallbackCalled = false;
1238 gInputStyleMask = TextEditor::InputStyle::NONE;
1239 inputStyleChangedSignal = false;
1241 // Create a tap event to touch the text editor.
1242 TestGenerateTap( application, 164.0f, 25.0f );
1244 // Render and notify
1245 application.SendNotification();
1246 application.Render();
1248 // Executes the idle callbacks added by the text control on the change of input style.
1249 application.RunIdles();
1251 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1252 if( gInputStyleChangedCallbackCalled )
1254 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1256 Property::Map fontStyleMapSet;
1257 Property::Map fontStyleMapGet;
1259 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1260 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1261 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1263 DALI_TEST_CHECK( inputStyleChangedSignal );
1265 gInputStyleChangedCallbackCalled = false;
1266 gInputStyleMask = TextEditor::InputStyle::NONE;
1267 inputStyleChangedSignal = false;
1269 // Create a tap event to touch the text editor.
1270 TestGenerateTap( application, 191.0f, 25.0f );
1272 // Render and notify
1273 application.SendNotification();
1274 application.Render();
1276 // Executes the idle callbacks added by the text control on the change of input style.
1277 application.RunIdles();
1279 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1280 DALI_TEST_CHECK( !inputStyleChangedSignal );
1285 int utcDaliTextEditorInputStyleChanged02(void)
1287 // The text-editor emits signals when the input style changes. These changes of style are
1288 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1289 // can't be emitted during the size negotiation as the callbacks may update the UI.
1290 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1291 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1292 ToolkitTestApplication application;
1293 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1297 char* pathNamePtr = get_current_dir_name();
1298 const std::string pathName( pathNamePtr );
1299 free( pathNamePtr );
1301 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1302 fontClient.SetDpi( 93u, 93u );
1304 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1305 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1307 TextEditor editor = TextEditor::New();
1308 DALI_TEST_CHECK( editor );
1311 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1312 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1313 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1315 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1316 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>" );
1318 // connect to the text changed signal.
1319 ConnectionTracker* testTracker = new ConnectionTracker();
1320 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1321 bool inputStyleChangedSignal = false;
1322 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1324 application.GetScene().Add( editor );
1326 // Render and notify
1327 application.SendNotification();
1328 application.Render();
1330 // Executes the idle callbacks added by the text control on the change of input style.
1331 application.RunIdles();
1333 gInputStyleChangedCallbackCalled = false;
1334 gInputStyleMask = TextEditor::InputStyle::NONE;
1335 inputStyleChangedSignal = false;
1337 // Create a tap event to touch the text editor.
1338 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1339 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1341 // Render and notify
1342 application.SendNotification();
1343 application.Render();
1345 // Executes the idle callbacks added by the text control on the change of input style.
1346 application.RunIdles();
1348 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1349 if( gInputStyleChangedCallbackCalled )
1351 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1352 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1353 TextEditor::InputStyle::POINT_SIZE |
1354 TextEditor::InputStyle::COLOR ),
1357 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1358 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1360 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1361 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1363 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1364 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1366 DALI_TEST_CHECK( inputStyleChangedSignal );
1368 gInputStyleChangedCallbackCalled = false;
1369 gInputStyleMask = TextEditor::InputStyle::NONE;
1370 inputStyleChangedSignal = false;
1372 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Executes the idle callbacks added by the text control on the change of input style.
1379 application.RunIdles();
1381 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1382 if( gInputStyleChangedCallbackCalled )
1384 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1385 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1388 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1389 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1391 DALI_TEST_CHECK( inputStyleChangedSignal );
1393 gInputStyleChangedCallbackCalled = false;
1394 gInputStyleMask = TextEditor::InputStyle::NONE;
1395 inputStyleChangedSignal = false;
1397 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1399 // Render and notify
1400 application.SendNotification();
1401 application.Render();
1403 // Executes the idle callbacks added by the text control on the change of input style.
1404 application.RunIdles();
1406 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1407 DALI_TEST_CHECK( !inputStyleChangedSignal );
1409 gInputStyleChangedCallbackCalled = false;
1410 gInputStyleMask = TextEditor::InputStyle::NONE;
1411 inputStyleChangedSignal = false;
1413 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1415 // Render and notify
1416 application.SendNotification();
1417 application.Render();
1419 // Executes the idle callbacks added by the text control on the change of input style.
1420 application.RunIdles();
1422 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1423 if( gInputStyleChangedCallbackCalled )
1425 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1426 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1429 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1430 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1432 DALI_TEST_CHECK( inputStyleChangedSignal );
1434 gInputStyleChangedCallbackCalled = false;
1435 gInputStyleMask = TextEditor::InputStyle::NONE;
1436 inputStyleChangedSignal = false;
1438 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1440 Property::Map fontStyleMapSet;
1441 fontStyleMapSet.Insert( "weight", "thin" );
1442 fontStyleMapSet.Insert( "width", "condensed" );
1443 fontStyleMapSet.Insert( "slant", "italic" );
1445 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1446 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1447 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1449 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1450 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1451 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1452 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1454 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1456 // Render and notify
1457 application.SendNotification();
1458 application.Render();
1460 // Executes the idle callbacks added by the text control on the change of input style.
1461 application.RunIdles();
1463 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1464 DALI_TEST_CHECK( !inputStyleChangedSignal );
1466 // Create a tap event to touch the text editor.
1467 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1469 // Render and notify
1470 application.SendNotification();
1471 application.Render();
1473 // Executes the idle callbacks added by the text control on the change of input style.
1474 application.RunIdles();
1476 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1477 if( gInputStyleChangedCallbackCalled )
1479 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1480 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1481 TextEditor::InputStyle::POINT_SIZE |
1482 TextEditor::InputStyle::FONT_STYLE |
1483 TextEditor::InputStyle::LINE_SPACING |
1484 TextEditor::InputStyle::UNDERLINE |
1485 TextEditor::InputStyle::SHADOW |
1486 TextEditor::InputStyle::EMBOSS |
1487 TextEditor::InputStyle::OUTLINE ),
1490 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1491 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1493 DALI_TEST_CHECK( inputStyleChangedSignal );
1495 gInputStyleChangedCallbackCalled = false;
1496 gInputStyleMask = TextEditor::InputStyle::NONE;
1497 inputStyleChangedSignal = false;
1499 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1501 fontStyleMapSet.Clear();
1502 fontStyleMapSet.Insert( "weight", "black" );
1503 fontStyleMapSet.Insert( "width", "expanded" );
1504 fontStyleMapSet.Insert( "slant", "oblique" );
1506 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1508 // Create a tap event to touch the text editor.
1509 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1511 // Render and notify
1512 application.SendNotification();
1513 application.Render();
1515 // Executes the idle callbacks added by the text control on the change of input style.
1516 application.RunIdles();
1518 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1519 if( gInputStyleChangedCallbackCalled )
1521 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1522 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1523 TextEditor::InputStyle::POINT_SIZE |
1524 TextEditor::InputStyle::FONT_STYLE ),
1527 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1528 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1530 DALI_TEST_CHECK( inputStyleChangedSignal );
1535 int utcDaliTextEditorEvent01(void)
1537 ToolkitTestApplication application;
1538 tet_infoline(" utcDaliTextEditorEvent01");
1540 // Creates a tap event. After creating a tap event the text editor should
1541 // have the focus and add text with key events should be possible.
1543 TextEditor editor = TextEditor::New();
1544 DALI_TEST_CHECK( editor );
1546 application.GetScene().Add( editor );
1548 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1549 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1550 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1552 // Avoid a crash when core load gl resources.
1553 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1555 // Render and notify
1556 application.SendNotification();
1557 application.Render();
1559 // Add a key event but as the text editor has not the focus it should do nothing.
1560 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1562 // Render and notify
1563 application.SendNotification();
1564 application.Render();
1566 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1568 // Create a tap event to touch the text editor.
1569 TestGenerateTap( application, 150.0f, 25.0f );
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 // Now the text editor has the focus, so it can handle the key events.
1576 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1577 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1585 // Create a second text editor and send key events to it.
1586 TextEditor editor2 = TextEditor::New();
1588 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1589 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1590 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1591 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1593 application.GetScene().Add( editor2 );
1595 // Render and notify
1596 application.SendNotification();
1597 application.Render();
1599 // Create a tap event on the second text editor.
1600 TestGenerateTap( application, 150.0f, 125.0f );
1602 // Render and notify
1603 application.SendNotification();
1604 application.Render();
1606 // The second text editor has the focus. It should handle the key events.
1607 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1608 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1610 // Render and notify
1611 application.SendNotification();
1612 application.Render();
1614 // Check the text has been added to the second text editor.
1615 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1620 int utcDaliTextEditorEvent02(void)
1622 ToolkitTestApplication application;
1623 tet_infoline(" utcDaliTextEditorEvent02");
1625 // Checks if the right number of actors are created.
1627 TextEditor editor = TextEditor::New();
1628 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1629 DALI_TEST_CHECK( editor );
1631 application.GetScene().Add( editor );
1633 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1634 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1635 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1637 // Avoid a crash when core load gl resources.
1638 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1640 // Render and notify
1641 application.SendNotification();
1642 application.Render();
1644 // Check there are the expected number of children (the stencil).
1645 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1647 Actor stencil = editor.GetChildAt( 0u );
1649 // Create a tap event to touch the text editor.
1650 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1652 // Render and notify
1653 application.SendNotification();
1654 application.Render();
1656 Actor layer = editor.GetChildAt( 1u );
1657 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1658 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1660 // Now the text editor has the focus, so it can handle the key events.
1661 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1662 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1664 // Render and notify
1665 application.SendNotification();
1666 application.Render();
1668 // Checks the cursor and the renderer have been created.
1669 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1670 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1672 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1673 DALI_TEST_CHECK( cursor );
1675 // The stencil actor has a container with all the actors which contain the text renderers.
1676 Actor container = stencil.GetChildAt( 0u );
1677 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1679 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1680 DALI_TEST_CHECK( renderer );
1683 // Move the cursor and check the position changes.
1684 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1686 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1687 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1693 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1695 DALI_TEST_CHECK( position2.x < position1.x );
1697 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1698 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1700 // Render and notify
1701 application.SendNotification();
1702 application.Render();
1704 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1706 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1708 // Send some taps and check the cursor positions.
1710 // Try to tap at the beginning.
1711 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1713 // Render and notify
1714 application.SendNotification();
1715 application.Render();
1717 // Cursor position should be the same than position1.
1718 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1720 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1722 // Tap away from the start position.
1723 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1725 // Render and notify
1726 application.SendNotification();
1727 application.Render();
1729 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1731 DALI_TEST_CHECK( position5.x > position4.x );
1733 // Remove all the text.
1734 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1735 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1736 editor.SetProperty( TextEditor::Property::TEXT, "" );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 // Cursor position should be the same than position2.
1743 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1745 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1747 // Should not be a renderer.
1748 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1753 int utcDaliTextEditorEvent03(void)
1755 ToolkitTestApplication application;
1756 tet_infoline(" utcDaliTextEditorEvent03");
1758 // Checks if the highlight actor is created.
1760 TextEditor editor = TextEditor::New();
1761 DALI_TEST_CHECK( editor );
1763 application.GetScene().Add( editor );
1765 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1766 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1767 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1768 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1769 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1771 // Avoid a crash when core load gl resources.
1772 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1774 // Render and notify
1775 application.SendNotification();
1776 application.Render();
1778 // Send some taps and check text controller with clipboard window
1779 Dali::Clipboard clipboard = Clipboard::Get();
1780 clipboard.ShowClipboard();
1781 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1782 clipboard.HideClipboard();
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1788 // Tap first to get the focus.
1789 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1791 // Render and notify
1792 application.SendNotification();
1793 application.Render();
1795 // Double tap to select a word.
1796 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1798 // Render and notify
1799 application.SendNotification();
1800 application.Render();
1802 // The stencil actor should have two actors: the renderer and the highlight actor.
1803 Actor stencil = editor.GetChildAt( 0u );
1805 // Highlight needs to be drawn before text, so should come first in child order
1806 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1807 DALI_TEST_CHECK( highlight );
1809 // The stencil actor has a container with all the actors which contain the text renderers.
1810 Actor container = stencil.GetChildAt( 1u );
1811 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1813 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1814 DALI_TEST_CHECK( renderer );
1817 // Double tap out of bounds
1818 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1819 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 // The stencil actor should have one actors: the renderer actor.
1826 stencil = editor.GetChildAt( 0u );
1828 // The stencil actor has a container with all the actors which contain the text renderers.
1829 container = stencil.GetChildAt( 0u );
1830 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1832 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1833 DALI_TEST_CHECK( renderer );
1837 TestGenerateLongPress(application, 1.0f, 25.0f);
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1844 TestGenerateMiniPan(application);
1846 // Render and notify
1847 application.SendNotification();
1848 application.Render();
1853 int utcDaliTextEditorEvent04(void)
1855 ToolkitTestApplication application;
1856 tet_infoline(" utcDaliTextEditorEvent04");
1858 // Checks if the highlight actor is created.
1860 TextEditor editor = TextEditor::New();
1861 DALI_TEST_CHECK( editor );
1863 application.GetScene().Add( editor );
1865 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1866 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1867 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1868 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1869 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1871 // Avoid a crash when core load gl resources.
1872 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1874 // Render and notify
1875 application.SendNotification();
1876 application.Render();
1878 // Tap on the text editor
1879 TestGenerateTap( application, 3.0f, 25.0f );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 // Move at the end of the text.
1886 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1887 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1889 // Render and notify
1890 application.SendNotification();
1891 application.Render();
1893 for( unsigned int index = 0u; index < 10u; ++index )
1895 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1896 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1904 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1912 // Add some key events
1913 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1914 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1916 // Render and notify
1917 application.SendNotification();
1918 application.Render();
1920 for( unsigned int index = 0u; index < 10u; ++index )
1922 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1923 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1925 // Render and notify
1926 application.SendNotification();
1927 application.Render();
1931 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1933 // Render and notify
1934 application.SendNotification();
1935 application.Render();
1937 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1942 int utcDaliTextEditorEvent05(void)
1944 ToolkitTestApplication application;
1945 tet_infoline(" utcDaliTextEditorEvent05");
1947 // Checks if the highlight actor is created.
1949 TextEditor editor = TextEditor::New();
1950 DALI_TEST_CHECK( editor );
1952 application.GetScene().Add( editor );
1954 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1955 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1956 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1957 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1958 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1959 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1960 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1961 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1962 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1963 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1965 // Avoid a crash when core load gl resources.
1966 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1968 // Render and notify
1969 application.SendNotification();
1970 application.Render();
1972 // Tap on the text editor
1973 TestGenerateTap( application, 3.0f, 25.0f );
1975 // Render and notify
1976 application.SendNotification();
1977 application.Render();
1979 // Move at the end of the text.
1980 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1981 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1983 // Render and notify
1984 application.SendNotification();
1985 application.Render();
1987 for( unsigned int index = 0u; index < 10u; ++index )
1990 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Modify duration after scroll is enabled
1997 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1999 // Continuous scroll left to increase coverage
2000 for( unsigned int index = 0u; index < 10u; ++index )
2002 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2004 // Render and notify
2005 application.SendNotification();
2006 application.Render();
2008 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2009 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2010 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2011 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2012 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2014 // Press Escape to increase coverage
2015 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2016 application.SendNotification();
2017 application.Render();
2019 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2024 int utcDaliTextEditorEvent06(void)
2026 ToolkitTestApplication application;
2027 tet_infoline(" utcDaliTextEditorEvent06");
2029 // Checks if the highlight actor is created.
2031 TextEditor editor = TextEditor::New();
2032 DALI_TEST_CHECK( editor );
2034 application.GetScene().Add( editor );
2036 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2037 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2038 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2039 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2040 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2042 // Avoid a crash when core load gl resources.
2043 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Tap on the text editor
2050 TestGenerateTap( application, 3.0f, 25.0f );
2052 // Render and notify
2053 application.SendNotification();
2054 application.Render();
2056 // Move to seconds line of the text.
2057 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2059 // Render and notify
2060 application.SendNotification();
2061 application.Render();
2063 float layoutHeight = editor.GetHeightForWidth( 100.f );
2066 // Add another script characters ( glyph height is defferent )
2067 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2068 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 // Delete characters
2071 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2074 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2076 // Render and notify
2077 application.SendNotification();
2078 application.Render();
2080 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2083 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2084 application.SendNotification();
2085 application.Render();
2087 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2088 application.SendNotification();
2089 application.Render();
2091 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2092 application.SendNotification();
2093 application.Render();
2095 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2096 application.SendNotification();
2097 application.Render();
2099 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2100 application.SendNotification();
2101 application.Render();
2103 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2104 application.SendNotification();
2105 application.Render();
2107 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2108 application.SendNotification();
2109 application.Render();
2114 int utcDaliTextEditorEvent07(void)
2116 ToolkitTestApplication application;
2117 tet_infoline(" utcDaliTextEditorEvent07");
2119 // Checks if the highlight actor is created.
2121 TextEditor editor = TextEditor::New();
2122 DALI_TEST_CHECK( editor );
2124 application.GetScene().Add( editor );
2126 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2127 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2128 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2129 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2130 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2132 // Avoid a crash when core load gl resources.
2133 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2135 // Render and notify
2136 application.SendNotification();
2137 application.Render();
2139 // Tap on the text editor
2140 TestGenerateTap( application, 3.0f, 25.0f );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 // Move to second line of the text.
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 // Render and notify
2150 application.SendNotification();
2151 application.Render();
2153 // Select some text in the right of the current cursor position
2154 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2155 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 // Render and notify
2160 application.SendNotification();
2161 application.Render();
2163 // Cut the selected text
2164 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 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 ) );
2167 // Render and notify
2168 application.SendNotification();
2169 application.Render();
2171 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2173 // Select some text in the left of the current cursor position
2174 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2175 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2176 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2177 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2179 // Render and notify
2180 application.SendNotification();
2181 application.Render();
2183 // Copy the selected text
2184 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2185 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 ) );
2187 // Render and notify
2188 application.SendNotification();
2189 application.Render();
2191 // Move the cursor to the third line
2192 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2195 // Render and notify
2196 application.SendNotification();
2197 application.Render();
2199 // Paste the selected text at the current cursor position
2200 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2201 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 ) );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2210 // Disable Shift Selection
2211 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2213 // Test to select some text in the right of the current cursor position
2214 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2216 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 // Cut the selected text
2224 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2225 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 ) );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2232 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2234 // Test to select some text in the left of the current cursor position
2235 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2238 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240 // Render and notify
2241 application.SendNotification();
2242 application.Render();
2244 // Copy the selected text
2245 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 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 ) );
2248 // Render and notify
2249 application.SendNotification();
2250 application.Render();
2252 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2253 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2256 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 ) );
2258 // Render and notify
2259 application.SendNotification();
2260 application.Render();
2262 // replace text with "c"
2263 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265 // Render and notify
2266 application.SendNotification();
2267 application.Render();
2270 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2273 DevelTextEditor::SelectWholeText(editor);
2275 // Render and notify
2276 application.SendNotification();
2277 application.Render();
2279 // Copy the selected text using logical keys
2280 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283 // Render and notify
2284 application.SendNotification();
2285 application.Render();
2288 DevelTextEditor::SelectNone(editor);
2290 // Render and notify
2291 application.SendNotification();
2292 application.Render();
2294 // Paste the selected using logical keys
2295 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2296 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2301 // select all using logical keys
2302 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2305 // Render and notify
2306 application.SendNotification();
2307 application.Render();
2309 // cut text using logical keys
2310 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2311 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2318 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2323 int utcDaliTextEditorEvent08(void)
2325 ToolkitTestApplication application;
2326 tet_infoline(" utcDaliTextEditorEvent08");
2328 // Checks if the highlight actor is released correctly.
2330 TextEditor editor = TextEditor::New();
2331 DALI_TEST_CHECK( editor );
2333 application.GetScene().Add( editor );
2335 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2336 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2337 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2338 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2339 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2341 // Avoid a crash when core load gl resources.
2342 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Tap on the text editor
2349 TestGenerateTap( application, 3.0f, 25.0f );
2351 // Render and notify
2352 application.SendNotification();
2353 application.Render();
2355 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2356 // Test to select some text in the left of the current cursor position
2357 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2358 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2359 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2366 // Test to the left selection handle position and the right selection handle position
2367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2368 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2370 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 // Test to select full text in the left of the current cursor position
2377 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2379 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 // Render and notify
2385 application.SendNotification();
2386 application.Render();
2388 // Test to release the current full text selection
2389 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2390 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392 // Render and notify
2393 application.SendNotification();
2394 application.Render();
2396 // Test to move the current cursor position correctly
2397 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2399 // Render and notify
2400 application.SendNotification();
2401 application.Render();
2404 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2412 // Test to select some text in the right of the current cursor position
2413 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2421 // Test the cursor position with right arrow key
2422 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2429 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2431 // Render and notify
2432 application.SendNotification();
2433 application.Render();
2435 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2437 // Test to select some text in the left of the current cursor position
2438 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2439 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 // Render and notify
2445 application.SendNotification();
2446 application.Render();
2448 // Test the cursor position with left arrow key
2449 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2451 // Render and notify
2452 application.SendNotification();
2453 application.Render();
2456 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2464 // Test to select some text in the right of the current cursor position
2465 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2466 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2468 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2474 // Test the cursor position with left arrow key
2475 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2477 // Render and notify
2478 application.SendNotification();
2479 application.Render();
2482 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2484 // Render and notify
2485 application.SendNotification();
2486 application.Render();
2488 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2490 // Test to select some text in the left of the current cursor position
2491 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2492 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2493 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2494 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2496 // Render and notify
2497 application.SendNotification();
2498 application.Render();
2500 // Test the cursor position with right arrow key
2501 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2503 // Render and notify
2504 application.SendNotification();
2505 application.Render();
2508 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2510 // Render and notify
2511 application.SendNotification();
2512 application.Render();
2514 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2519 int utcDaliTextEditorHandles(void)
2521 ToolkitTestApplication application;
2522 tet_infoline(" utcDaliTextEditorHandles");
2524 TextEditor editor = TextEditor::New();
2525 DALI_TEST_CHECK( editor );
2527 application.GetScene().Add( editor );
2529 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2530 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2531 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2532 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2534 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2535 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2536 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2537 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2539 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2540 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2541 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2543 // Avoid a crash when core load gl resources.
2544 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2546 // Render and notify
2547 application.SendNotification();
2548 application.Render();
2550 // Tap first to get the focus.
2551 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2553 // Render and notify
2554 application.SendNotification();
2555 application.Render();
2557 // Tap to create the grab handle.
2558 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2560 // Render and notify
2561 application.SendNotification();
2562 application.Render();
2564 // Get the active layer where the text's decoration is added.
2565 Actor activeLayer = editor.GetChildAt( 1u );
2567 // Get the handle's actor.
2568 Actor handle = activeLayer.GetChildAt( 1u );
2569 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2571 // Render and notify
2572 application.SendNotification();
2573 application.Render();
2575 // Touch the grab handle to set it as pressed.
2576 Vector2 touchPos( 10.0f, 50.0f );
2577 Dali::Integration::TouchEvent event;
2578 event = Dali::Integration::TouchEvent();
2579 event.AddPoint( GetPointDownInside( touchPos ) );
2580 application.ProcessEvent( event );
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2586 // Pan the grab handle
2587 uint32_t time = 100;
2588 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2589 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2590 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2591 application.SendNotification();
2592 application.Render();
2595 // Release the grab handle.
2596 event = Dali::Integration::TouchEvent();
2597 event.AddPoint( GetPointUpInside( touchPos ) );
2598 application.ProcessEvent( event );
2600 // Render and notify
2601 application.SendNotification();
2602 application.Render();
2604 // Tap first to get the focus.
2605 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2607 // Render and notify
2608 application.SendNotification();
2609 application.Render();
2611 // Double tap to select a word and create the selection handles.
2612 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2614 // Render and notify
2615 application.SendNotification();
2616 application.Render();
2618 touchPos = Vector2( 10.0f, 50.0f );
2620 // Touch the left selection handle to set it as pressed.
2621 event = Dali::Integration::TouchEvent();
2622 event.AddPoint( GetPointDownInside( touchPos ) );
2623 application.ProcessEvent( event );
2625 // Render and notify
2626 application.SendNotification();
2627 application.Render();
2629 // Release the left selection handle.
2630 event = Dali::Integration::TouchEvent();
2631 event.AddPoint( GetPointUpInside( touchPos ) );
2632 application.ProcessEvent( event );
2634 // Render and notify
2635 application.SendNotification();
2636 application.Render();
2641 int utcDaliTextEditorUnderPropertyStringP(void)
2643 ToolkitTestApplication application;
2644 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2645 TextEditor editor = TextEditor::New();
2646 DALI_TEST_CHECK( editor );
2648 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2650 application.GetScene().Add( editor );
2652 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2653 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2655 tet_infoline("Set underline settings with a map");
2656 // Check the input underline property
2657 Property::Map underlineMapSet;
2658 Property::Map underlineMapGet;
2659 underlineMapSet.Insert( "enable", true );
2660 underlineMapSet.Insert( "color", Color::BLUE );
2661 underlineMapSet.Insert( "height", 2 );
2663 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2664 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2665 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2666 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2668 tet_infoline("Set underline settings with a string");
2669 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2670 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2673 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2675 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2676 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2677 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2678 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2680 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2685 int utcDaliTextEditorShadowPropertyStringP(void)
2687 ToolkitTestApplication application;
2688 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2690 TextEditor editor = TextEditor::New();
2692 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2694 application.GetScene().Add( editor );
2696 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2698 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2702 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2707 int utcDaliTextEditorFontStylePropertyStringP(void)
2709 ToolkitTestApplication application;
2710 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2712 TextEditor editor = TextEditor::New();
2714 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2716 application.GetScene().Add( editor );
2718 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2720 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2724 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2729 int utcDaliTextEditorGetPropertyLinecountP(void)
2731 ToolkitTestApplication application;
2733 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2737 TextEditor editor = TextEditor::New();
2738 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2739 editor.SetProperty( TextEditor::Property::TEXT,
2740 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2742 application.GetScene().Add( editor );
2744 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2745 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2746 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2748 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2749 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2750 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2755 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2758 ToolkitTestApplication application;
2759 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2761 TextEditor editor = TextEditor::New();
2762 DALI_TEST_CHECK( editor );
2764 application.GetScene().Add( editor );
2766 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2767 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2768 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2769 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2770 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2771 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2773 bool startedCalled = false;
2774 bool finishedCalled = false;
2776 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2777 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2779 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2781 // Render and notify
2782 application.SendNotification();
2783 application.Render();
2785 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2786 application.SendNotification();
2787 application.Render(6000);
2789 application.SendNotification();
2790 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2791 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2796 int UtcDaliToolkitTextEditorTextWrapMode(void)
2798 ToolkitTestApplication application;
2799 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2803 TextEditor editor = TextEditor::New();
2804 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2805 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2807 application.GetScene().Add( editor );
2809 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2810 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2812 application.SendNotification();
2813 application.Render();
2815 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2816 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2818 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2819 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2821 application.SendNotification();
2822 application.Render();
2824 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2825 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2827 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2828 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2830 application.SendNotification();
2831 application.Render();
2833 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2834 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2836 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2837 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2839 application.SendNotification();
2840 application.Render();
2842 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2843 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2848 int UtcDaliTextEditorSetPaddingProperty(void)
2850 ToolkitTestApplication application;
2851 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2853 TextEditor editor = TextEditor::New();
2854 DALI_TEST_CHECK( editor );
2855 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2856 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2857 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2858 application.GetScene().Add( editor );
2860 application.SendNotification();
2861 application.Render();
2863 Vector3 originalSize = editor.GetNaturalSize();
2865 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2867 application.SendNotification();
2868 application.Render();
2870 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2872 Vector3 paddingAddedSize = editor.GetNaturalSize();
2874 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2876 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2881 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2883 ToolkitTestApplication application;
2884 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2886 TextEditor editor = TextEditor::New();
2887 DALI_TEST_CHECK( editor );
2888 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2889 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2890 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2891 application.GetScene().Add( editor );
2893 application.SendNotification();
2894 application.Render();
2896 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2897 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2899 // Check the enable shift selection property
2900 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2901 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2903 application.SendNotification();
2904 application.Render();
2909 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2911 ToolkitTestApplication application;
2912 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2914 TextEditor editor = TextEditor::New();
2915 DALI_TEST_CHECK( editor );
2916 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2917 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2918 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2919 application.GetScene().Add( editor );
2921 application.SendNotification();
2922 application.Render();
2924 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2925 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2927 // Check the enable grab handle property
2928 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2929 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2931 application.SendNotification();
2932 application.Render();
2937 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2939 ToolkitTestApplication application;
2940 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2942 TextEditor editor = TextEditor::New();
2943 DALI_TEST_CHECK( editor );
2944 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2945 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2946 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2947 application.GetScene().Add( editor );
2949 application.SendNotification();
2950 application.Render();
2952 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2953 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2955 // Check the enable match system language direction property
2956 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2957 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2959 application.SendNotification();
2960 application.Render();
2965 int UtcDaliTextEditorGetInputMethodContext(void)
2967 ToolkitTestApplication application;
2968 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2970 TextEditor editor = TextEditor::New();
2971 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2976 int utcDaliTextEditorMaxCharactersReached(void)
2978 ToolkitTestApplication application;
2979 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2981 TextEditor editor = TextEditor::New();
2982 DALI_TEST_CHECK( editor );
2984 application.GetScene().Add( editor );
2986 const int maxNumberOfCharacters = 1;
2987 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2988 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2990 editor.SetKeyInputFocus();
2992 // connect to the text changed signal.
2993 ConnectionTracker* testTracker = new ConnectionTracker();
2994 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2995 bool maxLengthReachedSignal = false;
2996 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2998 gMaxCharactersCallBackCalled = false;
3000 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3001 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3003 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3004 DALI_TEST_CHECK( maxLengthReachedSignal );
3009 int UtcDaliTextEditorSelectWholeText(void)
3011 ToolkitTestApplication application;
3012 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3014 TextEditor textEditor = TextEditor::New();
3016 application.GetScene().Add( textEditor );
3018 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3019 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3020 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3022 // Avoid a crash when core load gl resources.
3023 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3025 application.SendNotification();
3026 application.Render();
3028 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3030 DevelTextEditor::SelectWholeText( textEditor );
3032 application.SendNotification();
3033 application.Render();
3035 // Nothing should have been selected. The number of children is still 1
3036 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3038 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3040 application.SendNotification();
3041 application.Render();
3043 DevelTextEditor::SelectWholeText( textEditor );
3045 application.SendNotification();
3046 application.Render();
3048 // Should be 2 children, the stencil and the layer
3049 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3051 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3052 Actor stencil = textEditor.GetChildAt( 0u );
3054 // The highlight actor is drawn first, so is the first actor in the list
3055 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3056 DALI_TEST_CHECK( highlight );
3061 int UtcDaliTextEditorSelectNone(void)
3063 ToolkitTestApplication application;
3064 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3066 TextEditor textEditor = TextEditor::New();
3068 application.GetScene().Add( textEditor );
3070 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3071 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3072 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3074 // Avoid a crash when core load gl resources.
3075 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3077 application.SendNotification();
3078 application.Render();
3080 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3082 application.SendNotification();
3083 application.Render();
3085 // Nothing is selected
3086 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3087 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3089 DevelTextEditor::SelectWholeText( textEditor );
3091 application.SendNotification();
3092 application.Render();
3094 // whole text is selected
3095 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3096 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3098 DevelTextEditor::SelectNone( textEditor );
3100 application.SendNotification();
3101 application.Render();
3103 // Nothing is selected
3104 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3105 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3110 int UtcDaliTextEditorSelectRange(void)
3112 ToolkitTestApplication application;
3113 tet_infoline("utcDaliTextEditorSelectRange");
3115 TextEditor textEditor = TextEditor::New();
3116 DALI_TEST_CHECK( textEditor );
3118 application.GetScene().Add( textEditor );
3120 // Avoid a crash when core load gl resources.
3121 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3123 application.SendNotification();
3124 application.Render();
3126 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3128 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3129 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3131 // Hello is selected
3132 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3133 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3135 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3136 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3141 int UtcDaliTextEditorEnableEditing(void)
3143 ToolkitTestApplication application;
3144 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3146 TextEditor textEditor = TextEditor::New();
3148 application.GetScene().Add( textEditor );
3150 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3151 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3152 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3154 // Avoid a crash when core load gl resources.
3155 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3157 application.SendNotification();
3158 application.Render();
3160 textEditor.SetKeyInputFocus();
3161 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3162 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3164 // Render and notify
3165 application.SendNotification();
3166 application.Render();
3168 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3169 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3171 textEditor.SetKeyInputFocus();
3172 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3173 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3175 // Render and notify
3176 application.SendNotification();
3177 application.Render();
3179 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3180 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3185 int UtcDaliTextEditorScrolling(void)
3187 ToolkitTestApplication application;
3188 tet_infoline(" UtcDaliTextEditorScrolling ");
3190 TextEditor textEditor = TextEditor::New();
3191 DALI_TEST_CHECK( textEditor );
3193 application.GetScene().Add( textEditor );
3195 // Avoid a crash when core load gl resources.
3196 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3198 application.SendNotification();
3199 application.Render();
3201 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3202 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3203 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3204 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3206 application.SendNotification();
3207 application.Render();
3209 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3210 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3213 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3215 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3216 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3218 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3220 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3221 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3223 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3224 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3226 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3227 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3232 int UtcDaliToolkitTextEditorFontSizeScale(void)
3234 ToolkitTestApplication application;
3235 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3237 TextEditor textEditor = TextEditor::New();
3238 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3239 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3240 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3242 TextEditor textEditorScaled = TextEditor::New();
3243 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3244 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3245 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3246 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3248 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3250 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3251 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3252 nonScaledSize = textEditor.GetNaturalSize();
3254 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3255 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3256 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3257 scaledSize = textEditorScaled.GetNaturalSize();
3259 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3264 int UtcDaliTextEditorPrimaryCursorPosition(void)
3266 ToolkitTestApplication application;
3267 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3269 TextEditor textEditor = TextEditor::New();
3271 application.GetScene().Add( textEditor );
3273 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3274 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3275 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3276 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3278 // Avoid a crash when core load gl resources.
3279 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3281 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3282 application.SendNotification();
3283 application.Render();
3285 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3287 // Render and notify
3288 application.SendNotification();
3289 application.Render();
3291 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3292 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );