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";
107 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
108 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const unsigned int DEFAULT_FONT_SIZE = 1152u;
113 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
115 const int KEY_A_CODE = 38;
116 const int KEY_D_CODE = 40;
117 const int KEY_C_CODE = 54;
118 const int KEY_V_CODE = 55;
119 const int KEY_X_CODE = 53;
120 const int KEY_WHITE_SPACE_CODE = 65;
122 const int KEY_SHIFT_MODIFIER = 257;
123 const int KEY_CONTROL_MODIFIER = 258;
125 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
126 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
127 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
131 static bool gTextChangedCallBackCalled;
132 static bool gInputStyleChangedCallbackCalled;
133 static bool gMaxCharactersCallBackCalled;
134 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
136 struct CallbackFunctor
138 CallbackFunctor(bool* callbackFlag)
139 : mCallbackFlag( callbackFlag )
145 *mCallbackFlag = true;
150 static void TestTextChangedCallback( TextEditor control )
152 tet_infoline(" TestTextChangedCallback");
154 gTextChangedCallBackCalled = true;
157 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
159 tet_infoline(" TestInputStyleChangedCallback");
161 gInputStyleChangedCallbackCalled = true;
162 gInputStyleMask = mask;
165 static void TestMaxLengthReachedCallback( TextEditor control )
167 tet_infoline(" TestMaxLengthReachedCallback");
169 gMaxCharactersCallBackCalled = true;
172 // Generate a KeyEvent to send to Core.
173 Integration::KeyEvent GenerateKey( const std::string& keyName,
174 const std::string& logicalKey,
175 const std::string& keyString,
178 unsigned long timeStamp,
179 const Integration::KeyEvent::State& keyState,
180 const std::string& compose = "",
181 const std::string& deviceName = DEFAULT_DEVICE_NAME,
182 const Device::Class::Type& deviceClass = Device::Class::NONE,
183 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
185 return Integration::KeyEvent( keyName,
198 Dali::Integration::Point GetPointDownInside( Vector2& pos )
200 Dali::Integration::Point point;
201 point.SetState( PointState::DOWN );
202 point.SetScreenPosition( pos );
206 Dali::Integration::Point GetPointUpInside( Vector2& pos )
208 Dali::Integration::Point point;
209 point.SetState( PointState::UP );
210 point.SetScreenPosition( pos );
214 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
216 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
218 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
220 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
222 Property::Value* valueSet = NULL;
223 if ( valueGet.first.type == Property::Key::INDEX )
225 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
229 // Get Key is a string so searching Set Map for a string key
230 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
233 if( NULL != valueSet )
235 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
237 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
240 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
242 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
245 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
247 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
250 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
252 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
255 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
257 Vector2 vector2Get = valueGet.second.Get<Vector2>();
258 Vector2 vector2Set = valueSet->Get<Vector2>();
259 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
262 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
264 Vector4 vector4Get = valueGet.second.Get<Vector4>();
265 Vector4 vector4Set = valueSet->Get<Vector4>();
266 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 );
272 if ( valueGet.first.type == Property::Key::INDEX )
274 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
278 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
288 class ScrollStateChangeCallback : public Dali::ConnectionTracker
291 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
292 : mStartedCalled( startedCalled ),
293 mFinishedCalled( finishedCalled )
297 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
299 if( type == TextEditor::Scroll::STARTED )
301 mStartedCalled = true;
303 else if( type == TextEditor::Scroll::FINISHED )
305 mFinishedCalled = true;
309 bool& mStartedCalled;
310 bool& mFinishedCalled;
315 int UtcDaliToolkitTextEditorConstructorP(void)
317 ToolkitTestApplication application;
318 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
319 TextEditor textEditor;
320 DALI_TEST_CHECK( !textEditor );
324 int UtcDaliToolkitTextEditorNewP(void)
326 ToolkitTestApplication application;
327 tet_infoline(" UtcDaliToolkitTextEditorNewP");
328 TextEditor textEditor = TextEditor::New();
329 DALI_TEST_CHECK( textEditor );
333 int UtcDaliToolkitTextEditorDownCastP(void)
335 ToolkitTestApplication application;
336 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
337 TextEditor textEditor1 = TextEditor::New();
338 BaseHandle object( textEditor1 );
340 TextEditor textEditor2 = TextEditor::DownCast( object );
341 DALI_TEST_CHECK( textEditor2 );
343 TextEditor textEditor3 = DownCast< TextEditor >( object );
344 DALI_TEST_CHECK( textEditor3 );
348 int UtcDaliToolkitTextEditorDownCastN(void)
350 ToolkitTestApplication application;
351 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
352 BaseHandle uninitializedObject;
353 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
354 DALI_TEST_CHECK( !textEditor1 );
356 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
357 DALI_TEST_CHECK( !textEditor2 );
361 int UtcDaliToolkitTextEditorCopyConstructorP(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
365 TextEditor textEditor = TextEditor::New();
366 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
368 TextEditor copy( textEditor );
369 DALI_TEST_CHECK( copy );
370 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
374 int UtcDaliTextEditorMoveConstructor(void)
376 ToolkitTestApplication application;
378 TextEditor textEditor = TextEditor::New();
379 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
380 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
382 TextEditor moved = std::move( textEditor );
383 DALI_TEST_CHECK( moved );
384 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
385 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
386 DALI_TEST_CHECK( !textEditor );
391 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
393 ToolkitTestApplication application;
394 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
395 TextEditor textEditor = TextEditor::New();
396 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
398 TextEditor copy = textEditor;
399 DALI_TEST_CHECK( copy );
400 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
404 int UtcDaliTextEditorMoveAssignment(void)
406 ToolkitTestApplication application;
408 TextEditor textEditor = TextEditor::New();
409 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
410 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
413 moved = std::move( textEditor );
414 DALI_TEST_CHECK( moved );
415 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
416 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
417 DALI_TEST_CHECK( !textEditor );
422 int UtcDaliTextEditorNewP(void)
424 ToolkitTestApplication application;
425 tet_infoline(" UtcDaliToolkitTextEditorNewP");
426 TextEditor textEditor = TextEditor::New();
427 DALI_TEST_CHECK( textEditor );
431 // Positive test case for a method
432 int UtcDaliTextEditorGetPropertyP(void)
434 ToolkitTestApplication application;
435 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
436 TextEditor editor = TextEditor::New();
437 DALI_TEST_CHECK( editor );
439 // Check Property Indices are correct
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
450 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
500 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
503 Property::Map imageMap;
504 imageMap[mapKey] =mapValue;
506 editor.SetProperty( property , imageMap );
507 Property::Value propValue = editor.GetProperty( property );
508 Property::Map* resultMap = propValue.GetMap();
510 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
518 // Positive test case for a method
519 int UtcDaliTextEditorSetPropertyP(void)
521 ToolkitTestApplication application;
522 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
523 TextEditor editor = TextEditor::New();
524 DALI_TEST_CHECK( editor );
525 application.GetScene().Add( editor );
527 // Note - we can't check the defaults since the stylesheets are platform-specific
529 // Check the render backend property.
530 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
531 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
533 // Check text property.
534 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
535 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
537 // Check text's color property
538 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
539 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
541 // Check font properties.
542 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
543 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
545 Property::Map fontStyleMapSet;
546 Property::Map fontStyleMapGet;
547 Property::Value* slantValue = NULL;
549 fontStyleMapSet.Insert( "weight", "bold" );
550 fontStyleMapSet.Insert( "width", "condensed" );
551 fontStyleMapSet.Insert( "slant", "italic" );
553 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
554 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
555 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
556 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
558 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
559 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
562 fontStyleMapSet.Clear();
563 fontStyleMapSet.Insert( "weight", "normal" );
564 fontStyleMapSet.Insert( "slant", "oblique" );
565 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
566 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
567 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
568 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
570 fontStyleMapSet.Clear();
571 fontStyleMapSet.Insert( "slant", "roman" );
572 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
575 // Replace 'roman' for 'normal'.
576 slantValue = fontStyleMapGet.Find( "slant" );
577 if( NULL != slantValue )
579 if( "normal" == slantValue->Get<std::string>() )
581 fontStyleMapGet["slant"] = "roman";
584 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
585 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
587 fontStyleMapSet.Clear();
589 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
590 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
591 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
592 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
594 // Check that the Alignment properties can be correctly set
595 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
596 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
598 // Check scroll properties.
599 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
600 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
601 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
602 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
604 // Check cursor properties
605 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
606 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
607 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
608 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
610 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
611 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
612 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
613 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
614 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
615 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
616 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
617 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
619 // Check handle images
620 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
621 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
622 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
623 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
624 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
626 // Check handle images
627 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
628 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
629 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
630 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
631 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
632 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
634 // Check the highlight color
635 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
636 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
638 // Decoration bounding box
639 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
640 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
642 // Check the enable markup property.
643 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
644 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
645 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
647 // Check input color property.
648 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
649 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
651 // Check input font properties.
652 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
653 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
655 fontStyleMapSet.Clear();
656 fontStyleMapSet.Insert( "weight", "bold" );
657 fontStyleMapSet.Insert( "width", "condensed" );
658 fontStyleMapSet.Insert( "slant", "italic" );
660 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
661 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
662 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
663 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
665 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
666 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 // Reset input font style.
669 fontStyleMapSet.Clear();
670 fontStyleMapSet.Insert( "weight", "normal" );
671 fontStyleMapSet.Insert( "slant", "oblique" );
673 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
674 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
675 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
676 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
678 fontStyleMapSet.Clear();
679 fontStyleMapSet.Insert( "slant", "roman" );
681 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
682 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
684 // Replace 'roman' for 'normal'.
685 slantValue = fontStyleMapGet.Find( "slant" );
686 if( NULL != slantValue )
688 if( "normal" == slantValue->Get<std::string>() )
690 fontStyleMapGet["slant"] = "roman";
693 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
694 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
696 fontStyleMapSet.Clear();
698 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
699 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
700 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
701 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
703 // Check the line spacing property
704 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
705 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
706 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
708 // Check the input line spacing property
709 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
710 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
711 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
713 // Check the underline property
715 Property::Map underlineMapSet;
716 Property::Map underlineMapGet;
718 underlineMapSet.Insert( "enable", true );
719 underlineMapSet.Insert( "color", Color::RED );
720 underlineMapSet.Insert( "height", 1 );
722 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
724 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
725 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
726 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
728 // Check the input underline property
729 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
730 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
732 // Check the shadow property
733 Property::Map shadowMapSet;
734 Property::Map shadowMapGet;
736 shadowMapSet.Insert( "color", Color::GREEN );
737 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
738 shadowMapSet.Insert( "blurRadius", 3.0f );
740 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
742 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
743 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
746 // Check the input shadow property
747 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
748 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
750 // Check the emboss property
751 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
752 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
754 // Check the input emboss property
755 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
756 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
758 // Check the outline property
760 // Test string type first
761 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
762 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
763 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
765 // Then test the property map type
766 Property::Map outlineMapSet;
767 Property::Map outlineMapGet;
769 outlineMapSet["color"] = Color::RED;
770 outlineMapSet["width"] = 2.0f;
772 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
774 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
775 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
776 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
778 // Check the input outline property
779 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
780 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
782 // Check the smooth scroll property
783 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
784 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
785 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
787 // Check the smooth scroll duration property
788 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
789 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
791 // Check the scroll bar property
792 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
793 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
794 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
796 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
797 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
798 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
799 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
801 // Check the pixel size of font
802 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
803 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
805 // Check placeholder text properties.
806 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
807 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
809 // Check placeholder text's color property.
810 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
811 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
813 // Check the enable selection property
814 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
815 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
817 // Check the placeholder property with pixel size
818 Property::Map placeholderPixelSizeMapSet;
819 Property::Map placeholderPixelSizeMapGet;
820 Property::Map placeholderFontstyleMap;
821 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
822 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
823 placeholderPixelSizeMapSet["color"] = Color::BLUE;
824 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
825 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
827 placeholderFontstyleMap.Insert( "weight", "bold" );
828 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
829 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
831 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
832 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
834 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
835 Property::Map placeholderConversionMap;
836 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
837 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
838 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
839 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
840 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
841 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
843 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
845 // Check the placeholder property with point size
846 Property::Map placeholderMapSet;
847 Property::Map placeholderMapGet;
848 placeholderMapSet["text"] = "Setting Placeholder Text";
849 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
850 placeholderMapSet["color"] = Color::RED;
851 placeholderMapSet["fontFamily"] = "Arial";
852 placeholderMapSet["pointSize"] = 12.0f;
853 // Check the placeholder font style property
854 placeholderFontstyleMap.Clear();
856 placeholderFontstyleMap.Insert( "weight", "bold" );
857 placeholderFontstyleMap.Insert( "width", "condensed" );
858 placeholderFontstyleMap.Insert( "slant", "italic" );
859 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
860 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
862 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
863 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
865 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
866 placeholderConversionMap.Clear();
867 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
868 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
869 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
870 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
871 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
872 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
873 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
876 placeholderFontstyleMap.Clear();
877 placeholderFontstyleMap.Insert( "weight", "normal" );
878 placeholderFontstyleMap.Insert( "slant", "oblique" );
879 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
880 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
882 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
883 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
884 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
885 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
887 placeholderFontstyleMap.Clear();
888 placeholderFontstyleMap.Insert( "slant", "roman" );
889 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
890 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
892 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
894 placeholderFontstyleMap.Clear();
895 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
897 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
898 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
899 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
900 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
901 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
903 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
904 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
906 application.SendNotification();
907 application.Render();
912 // Positive Atlas Text Renderer test
913 int utcDaliTextEditorAtlasRenderP(void)
915 ToolkitTestApplication application;
916 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
917 StyleManager styleManager = StyleManager::Get();
918 styleManager.ApplyDefaultTheme();
919 TextEditor editor = TextEditor::New();
920 DALI_TEST_CHECK( editor );
922 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
924 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
926 application.GetScene().Add( editor );
930 // Render some text with the shared atlas backend
931 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
932 application.SendNotification();
933 application.Render();
937 tet_result(TET_FAIL);
942 // Positive test for the textChanged signal.
943 int utcDaliTextEditorTextChangedP(void)
945 ToolkitTestApplication application;
946 tet_infoline(" utcDaliTextEditorTextChangedP");
947 TextEditor editor = TextEditor::New();
948 DALI_TEST_CHECK( editor );
950 application.GetScene().Add( editor );
952 // connect to the text changed signal.
953 ConnectionTracker* testTracker = new ConnectionTracker();
954 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
955 bool textChangedSignal = false;
956 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
958 gTextChangedCallBackCalled = false;
959 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
960 DALI_TEST_CHECK( gTextChangedCallBackCalled );
961 DALI_TEST_CHECK( textChangedSignal );
963 application.SendNotification();
964 editor.SetKeyInputFocus();
966 gTextChangedCallBackCalled = false;
967 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
968 DALI_TEST_CHECK( gTextChangedCallBackCalled );
973 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
975 ToolkitTestApplication application;
976 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
977 TextEditor editor = TextEditor::New();
978 DALI_TEST_CHECK( editor );
981 application.GetScene().Add( editor );
983 // connect to the text changed signal.
984 ConnectionTracker* testTracker = new ConnectionTracker();
985 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
986 bool textChangedSignal = false;
987 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
990 // get InputMethodContext
992 InputMethodContext::EventData imfEvent;
993 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
995 editor.SetKeyInputFocus();
996 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
999 gTextChangedCallBackCalled = false;
1000 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1001 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1002 application.SendNotification();
1003 application.Render();
1004 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1005 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1007 gTextChangedCallBackCalled = false;
1008 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1009 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1010 application.SendNotification();
1011 application.Render();
1012 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1013 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1015 gTextChangedCallBackCalled = false;
1016 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1017 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1018 application.SendNotification();
1019 application.Render();
1020 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1021 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1023 gTextChangedCallBackCalled = false;
1024 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1025 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1026 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1028 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1029 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1030 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1032 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1033 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1034 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
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 );
1045 int utcDaliTextEditorInputStyleChanged01(void)
1047 // The text-editor emits signals when the input style changes. These changes of style are
1048 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1049 // can't be emitted during the size negotiation as the callbacks may update the UI.
1050 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1051 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1052 ToolkitTestApplication application;
1053 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1057 char* pathNamePtr = get_current_dir_name();
1058 const std::string pathName( pathNamePtr );
1059 free( pathNamePtr );
1061 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1062 fontClient.SetDpi( 93u, 93u );
1064 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1065 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1067 TextEditor editor = TextEditor::New();
1068 DALI_TEST_CHECK( editor );
1071 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1072 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1073 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1075 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1076 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1078 // connect to the text changed signal.
1079 ConnectionTracker* testTracker = new ConnectionTracker();
1080 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1081 bool inputStyleChangedSignal = false;
1082 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1084 application.GetScene().Add( editor );
1086 // Render and notify
1087 application.SendNotification();
1088 application.Render();
1090 // Executes the idle callbacks added by the text control on the change of input style.
1091 application.RunIdles();
1093 gInputStyleChangedCallbackCalled = false;
1094 gInputStyleMask = TextEditor::InputStyle::NONE;
1095 inputStyleChangedSignal = false;
1097 // Create a tap event to touch the text editor.
1098 TestGenerateTap( application, 18.0f, 25.0f );
1100 // Render and notify
1101 application.SendNotification();
1102 application.Render();
1104 // Executes the idle callbacks added by the text control on the change of input style.
1105 application.RunIdles();
1107 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1108 if( gInputStyleChangedCallbackCalled )
1110 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1112 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1113 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1115 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1116 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1118 DALI_TEST_CHECK( inputStyleChangedSignal );
1120 gInputStyleChangedCallbackCalled = false;
1121 gInputStyleMask = TextEditor::InputStyle::NONE;
1122 inputStyleChangedSignal = false;
1124 // Create a tap event to touch the text editor.
1125 TestGenerateTap( application, 30.0f, 25.0f );
1127 // Render and notify
1128 application.SendNotification();
1129 application.Render();
1131 // Executes the idle callbacks added by the text control on the change of input style.
1132 application.RunIdles();
1134 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1135 DALI_TEST_CHECK( !inputStyleChangedSignal );
1137 gInputStyleChangedCallbackCalled = false;
1138 gInputStyleMask = TextEditor::InputStyle::NONE;
1139 inputStyleChangedSignal = false;
1141 // Create a tap event to touch the text editor.
1142 TestGenerateTap( application, 43.0f, 25.0f );
1144 // Render and notify
1145 application.SendNotification();
1146 application.Render();
1148 // Executes the idle callbacks added by the text control on the change of input style.
1149 application.RunIdles();
1151 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1152 if( gInputStyleChangedCallbackCalled )
1154 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1156 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1157 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1159 DALI_TEST_CHECK( inputStyleChangedSignal );
1161 gInputStyleChangedCallbackCalled = false;
1162 gInputStyleMask = TextEditor::InputStyle::NONE;
1163 inputStyleChangedSignal = false;
1165 // Create a tap event to touch the text editor.
1166 TestGenerateTap( application, 88.0f, 25.0f );
1168 // Render and notify
1169 application.SendNotification();
1170 application.Render();
1172 // Executes the idle callbacks added by the text control on the change of input style.
1173 application.RunIdles();
1175 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1176 if( gInputStyleChangedCallbackCalled )
1178 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1180 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1181 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1183 Property::Map fontStyleMapSet;
1184 Property::Map fontStyleMapGet;
1186 fontStyleMapSet.Insert( "weight", "bold" );
1188 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1189 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1190 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1192 DALI_TEST_CHECK( inputStyleChangedSignal );
1194 gInputStyleChangedCallbackCalled = false;
1195 gInputStyleMask = TextEditor::InputStyle::NONE;
1196 inputStyleChangedSignal = false;
1198 // Create a tap event to touch the text editor.
1199 TestGenerateTap( application, 115.0f, 25.0f );
1201 // Render and notify
1202 application.SendNotification();
1203 application.Render();
1205 // Executes the idle callbacks added by the text control on the change of input style.
1206 application.RunIdles();
1208 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1209 DALI_TEST_CHECK( !inputStyleChangedSignal );
1211 gInputStyleChangedCallbackCalled = false;
1212 gInputStyleMask = TextEditor::InputStyle::NONE;
1213 inputStyleChangedSignal = false;
1215 // Create a tap event to touch the text editor.
1216 TestGenerateTap( application, 164.0f, 25.0f );
1218 // Render and notify
1219 application.SendNotification();
1220 application.Render();
1222 // Executes the idle callbacks added by the text control on the change of input style.
1223 application.RunIdles();
1225 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1226 if( gInputStyleChangedCallbackCalled )
1228 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1230 Property::Map fontStyleMapSet;
1231 Property::Map fontStyleMapGet;
1233 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1234 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1235 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1237 DALI_TEST_CHECK( inputStyleChangedSignal );
1239 gInputStyleChangedCallbackCalled = false;
1240 gInputStyleMask = TextEditor::InputStyle::NONE;
1241 inputStyleChangedSignal = false;
1243 // Create a tap event to touch the text editor.
1244 TestGenerateTap( application, 191.0f, 25.0f );
1246 // Render and notify
1247 application.SendNotification();
1248 application.Render();
1250 // Executes the idle callbacks added by the text control on the change of input style.
1251 application.RunIdles();
1253 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1254 DALI_TEST_CHECK( !inputStyleChangedSignal );
1259 int utcDaliTextEditorInputStyleChanged02(void)
1261 // The text-editor emits signals when the input style changes. These changes of style are
1262 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1263 // can't be emitted during the size negotiation as the callbacks may update the UI.
1264 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1265 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1266 ToolkitTestApplication application;
1267 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1271 char* pathNamePtr = get_current_dir_name();
1272 const std::string pathName( pathNamePtr );
1273 free( pathNamePtr );
1275 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1276 fontClient.SetDpi( 93u, 93u );
1278 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1279 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1281 TextEditor editor = TextEditor::New();
1282 DALI_TEST_CHECK( editor );
1285 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1286 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1287 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1289 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1290 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>" );
1292 // connect to the text changed signal.
1293 ConnectionTracker* testTracker = new ConnectionTracker();
1294 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1295 bool inputStyleChangedSignal = false;
1296 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1298 application.GetScene().Add( editor );
1300 // Render and notify
1301 application.SendNotification();
1302 application.Render();
1304 // Executes the idle callbacks added by the text control on the change of input style.
1305 application.RunIdles();
1307 gInputStyleChangedCallbackCalled = false;
1308 gInputStyleMask = TextEditor::InputStyle::NONE;
1309 inputStyleChangedSignal = false;
1311 // Create a tap event to touch the text editor.
1312 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1313 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1315 // Render and notify
1316 application.SendNotification();
1317 application.Render();
1319 // Executes the idle callbacks added by the text control on the change of input style.
1320 application.RunIdles();
1322 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1323 if( gInputStyleChangedCallbackCalled )
1325 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1326 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1327 TextEditor::InputStyle::POINT_SIZE |
1328 TextEditor::InputStyle::COLOR ),
1331 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1332 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1334 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1335 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1337 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1338 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1340 DALI_TEST_CHECK( inputStyleChangedSignal );
1342 gInputStyleChangedCallbackCalled = false;
1343 gInputStyleMask = TextEditor::InputStyle::NONE;
1344 inputStyleChangedSignal = false;
1346 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1348 // Render and notify
1349 application.SendNotification();
1350 application.Render();
1352 // Executes the idle callbacks added by the text control on the change of input style.
1353 application.RunIdles();
1355 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1356 if( gInputStyleChangedCallbackCalled )
1358 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1359 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1362 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1363 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1365 DALI_TEST_CHECK( inputStyleChangedSignal );
1367 gInputStyleChangedCallbackCalled = false;
1368 gInputStyleMask = TextEditor::InputStyle::NONE;
1369 inputStyleChangedSignal = false;
1371 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1373 // Render and notify
1374 application.SendNotification();
1375 application.Render();
1377 // Executes the idle callbacks added by the text control on the change of input style.
1378 application.RunIdles();
1380 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1381 DALI_TEST_CHECK( !inputStyleChangedSignal );
1383 gInputStyleChangedCallbackCalled = false;
1384 gInputStyleMask = TextEditor::InputStyle::NONE;
1385 inputStyleChangedSignal = false;
1387 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1389 // Render and notify
1390 application.SendNotification();
1391 application.Render();
1393 // Executes the idle callbacks added by the text control on the change of input style.
1394 application.RunIdles();
1396 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1397 if( gInputStyleChangedCallbackCalled )
1399 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1400 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1403 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1404 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1406 DALI_TEST_CHECK( inputStyleChangedSignal );
1408 gInputStyleChangedCallbackCalled = false;
1409 gInputStyleMask = TextEditor::InputStyle::NONE;
1410 inputStyleChangedSignal = false;
1412 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1414 Property::Map fontStyleMapSet;
1415 fontStyleMapSet.Insert( "weight", "thin" );
1416 fontStyleMapSet.Insert( "width", "condensed" );
1417 fontStyleMapSet.Insert( "slant", "italic" );
1419 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1420 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1421 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1423 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1424 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1425 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1426 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1428 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1430 // Render and notify
1431 application.SendNotification();
1432 application.Render();
1434 // Executes the idle callbacks added by the text control on the change of input style.
1435 application.RunIdles();
1437 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1438 DALI_TEST_CHECK( !inputStyleChangedSignal );
1440 // Create a tap event to touch the text editor.
1441 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1443 // Render and notify
1444 application.SendNotification();
1445 application.Render();
1447 // Executes the idle callbacks added by the text control on the change of input style.
1448 application.RunIdles();
1450 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1451 if( gInputStyleChangedCallbackCalled )
1453 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1454 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1455 TextEditor::InputStyle::POINT_SIZE |
1456 TextEditor::InputStyle::FONT_STYLE |
1457 TextEditor::InputStyle::LINE_SPACING |
1458 TextEditor::InputStyle::UNDERLINE |
1459 TextEditor::InputStyle::SHADOW |
1460 TextEditor::InputStyle::EMBOSS |
1461 TextEditor::InputStyle::OUTLINE ),
1464 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1465 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1467 DALI_TEST_CHECK( inputStyleChangedSignal );
1469 gInputStyleChangedCallbackCalled = false;
1470 gInputStyleMask = TextEditor::InputStyle::NONE;
1471 inputStyleChangedSignal = false;
1473 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1475 fontStyleMapSet.Clear();
1476 fontStyleMapSet.Insert( "weight", "black" );
1477 fontStyleMapSet.Insert( "width", "expanded" );
1478 fontStyleMapSet.Insert( "slant", "oblique" );
1480 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1482 // Create a tap event to touch the text editor.
1483 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1485 // Render and notify
1486 application.SendNotification();
1487 application.Render();
1489 // Executes the idle callbacks added by the text control on the change of input style.
1490 application.RunIdles();
1492 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1493 if( gInputStyleChangedCallbackCalled )
1495 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1496 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1497 TextEditor::InputStyle::POINT_SIZE |
1498 TextEditor::InputStyle::FONT_STYLE ),
1501 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1502 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1504 DALI_TEST_CHECK( inputStyleChangedSignal );
1509 int utcDaliTextEditorEvent01(void)
1511 ToolkitTestApplication application;
1512 tet_infoline(" utcDaliTextEditorEvent01");
1514 // Creates a tap event. After creating a tap event the text editor should
1515 // have the focus and add text with key events should be possible.
1517 TextEditor editor = TextEditor::New();
1518 DALI_TEST_CHECK( editor );
1520 application.GetScene().Add( editor );
1522 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1523 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1524 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1526 // Avoid a crash when core load gl resources.
1527 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1529 // Render and notify
1530 application.SendNotification();
1531 application.Render();
1533 // Add a key event but as the text editor has not the focus it should do nothing.
1534 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1536 // Render and notify
1537 application.SendNotification();
1538 application.Render();
1540 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1542 // Create a tap event to touch the text editor.
1543 TestGenerateTap( application, 150.0f, 25.0f );
1545 // Render and notify
1546 application.SendNotification();
1547 application.Render();
1549 // Now the text editor has the focus, so it can handle the key events.
1550 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1551 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1553 // Render and notify
1554 application.SendNotification();
1555 application.Render();
1557 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1559 // Create a second text editor and send key events to it.
1560 TextEditor editor2 = TextEditor::New();
1562 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1563 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1564 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1565 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1567 application.GetScene().Add( editor2 );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // Create a tap event on the second text editor.
1574 TestGenerateTap( application, 150.0f, 125.0f );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // The second text editor has the focus. It should handle the key events.
1581 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1582 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1584 // Render and notify
1585 application.SendNotification();
1586 application.Render();
1588 // Check the text has been added to the second text editor.
1589 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1594 int utcDaliTextEditorEvent02(void)
1596 ToolkitTestApplication application;
1597 tet_infoline(" utcDaliTextEditorEvent02");
1599 // Checks if the right number of actors are created.
1601 TextEditor editor = TextEditor::New();
1602 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1603 DALI_TEST_CHECK( editor );
1605 application.GetScene().Add( editor );
1607 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1608 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1609 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1611 // Avoid a crash when core load gl resources.
1612 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1614 // Render and notify
1615 application.SendNotification();
1616 application.Render();
1618 // Check there are the expected number of children (the stencil).
1619 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1621 Actor stencil = editor.GetChildAt( 0u );
1623 // Create a tap event to touch the text editor.
1624 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1626 // Render and notify
1627 application.SendNotification();
1628 application.Render();
1630 Actor layer = editor.GetChildAt( 1u );
1631 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1632 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1634 // Now the text editor has the focus, so it can handle the key events.
1635 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1636 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1638 // Render and notify
1639 application.SendNotification();
1640 application.Render();
1642 // Checks the cursor and the renderer have been created.
1643 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1644 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1646 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1647 DALI_TEST_CHECK( cursor );
1649 // The stencil actor has a container with all the actors which contain the text renderers.
1650 Actor container = stencil.GetChildAt( 0u );
1651 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1653 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1654 DALI_TEST_CHECK( renderer );
1657 // Move the cursor and check the position changes.
1658 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1660 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1661 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1669 DALI_TEST_CHECK( position2.x < position1.x );
1671 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1672 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1674 // Render and notify
1675 application.SendNotification();
1676 application.Render();
1678 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1680 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1682 // Send some taps and check the cursor positions.
1684 // Try to tap at the beginning.
1685 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1687 // Render and notify
1688 application.SendNotification();
1689 application.Render();
1691 // Cursor position should be the same than position1.
1692 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1694 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1696 // Tap away from the start position.
1697 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1699 // Render and notify
1700 application.SendNotification();
1701 application.Render();
1703 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1705 DALI_TEST_CHECK( position5.x > position4.x );
1707 // Remove all the text.
1708 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1709 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1710 editor.SetProperty( TextEditor::Property::TEXT, "" );
1712 // Render and notify
1713 application.SendNotification();
1714 application.Render();
1716 // Cursor position should be the same than position2.
1717 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1719 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1721 // Should not be a renderer.
1722 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1727 int utcDaliTextEditorEvent03(void)
1729 ToolkitTestApplication application;
1730 tet_infoline(" utcDaliTextEditorEvent03");
1732 // Checks if the highlight actor is created.
1734 TextEditor editor = TextEditor::New();
1735 DALI_TEST_CHECK( editor );
1737 application.GetScene().Add( editor );
1739 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1740 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1741 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1742 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1743 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1745 // Avoid a crash when core load gl resources.
1746 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 // Send some taps and check text controller with clipboard window
1753 Dali::Clipboard clipboard = Clipboard::Get();
1754 clipboard.ShowClipboard();
1755 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1756 clipboard.HideClipboard();
1758 // Render and notify
1759 application.SendNotification();
1760 application.Render();
1762 // Tap first to get the focus.
1763 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 // Double tap to select a word.
1770 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1772 // Render and notify
1773 application.SendNotification();
1774 application.Render();
1776 // The stencil actor should have two actors: the renderer and the highlight actor.
1777 Actor stencil = editor.GetChildAt( 0u );
1779 // Highlight needs to be drawn before text, so should come first in child order
1780 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1781 DALI_TEST_CHECK( highlight );
1783 // The stencil actor has a container with all the actors which contain the text renderers.
1784 Actor container = stencil.GetChildAt( 1u );
1785 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1787 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1788 DALI_TEST_CHECK( renderer );
1791 // Double tap out of bounds
1792 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1793 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1795 // Render and notify
1796 application.SendNotification();
1797 application.Render();
1799 // The stencil actor should have one actors: the renderer actor.
1800 stencil = editor.GetChildAt( 0u );
1802 // The stencil actor has a container with all the actors which contain the text renderers.
1803 container = stencil.GetChildAt( 0u );
1804 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1806 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1807 DALI_TEST_CHECK( renderer );
1811 TestGenerateLongPress(application, 1.0f, 25.0f);
1813 // Render and notify
1814 application.SendNotification();
1815 application.Render();
1818 TestGenerateMiniPan(application);
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1827 int utcDaliTextEditorEvent04(void)
1829 ToolkitTestApplication application;
1830 tet_infoline(" utcDaliTextEditorEvent04");
1832 // Checks if the highlight actor is created.
1834 TextEditor editor = TextEditor::New();
1835 DALI_TEST_CHECK( editor );
1837 application.GetScene().Add( editor );
1839 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1840 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1841 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1842 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1843 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1845 // Avoid a crash when core load gl resources.
1846 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1852 // Tap on the text editor
1853 TestGenerateTap( application, 3.0f, 25.0f );
1855 // Render and notify
1856 application.SendNotification();
1857 application.Render();
1859 // Move at the end of the text.
1860 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1861 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1863 // Render and notify
1864 application.SendNotification();
1865 application.Render();
1867 for( unsigned int index = 0u; index < 10u; ++index )
1869 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1870 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1878 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1880 // Render and notify
1881 application.SendNotification();
1882 application.Render();
1884 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1886 // Add some key events
1887 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1888 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1890 // Render and notify
1891 application.SendNotification();
1892 application.Render();
1894 for( unsigned int index = 0u; index < 10u; ++index )
1896 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1897 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1905 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1911 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1916 int utcDaliTextEditorEvent05(void)
1918 ToolkitTestApplication application;
1919 tet_infoline(" utcDaliTextEditorEvent05");
1921 // Checks if the highlight actor is created.
1923 TextEditor editor = TextEditor::New();
1924 DALI_TEST_CHECK( editor );
1926 application.GetScene().Add( editor );
1928 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1929 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1930 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1931 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1932 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1933 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1934 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1935 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1936 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1937 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1939 // Avoid a crash when core load gl resources.
1940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 // Tap on the text editor
1947 TestGenerateTap( application, 3.0f, 25.0f );
1949 // Render and notify
1950 application.SendNotification();
1951 application.Render();
1953 // Move at the end of the text.
1954 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1955 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1957 // Render and notify
1958 application.SendNotification();
1959 application.Render();
1961 for( unsigned int index = 0u; index < 10u; ++index )
1964 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1966 // Render and notify
1967 application.SendNotification();
1968 application.Render();
1970 // Modify duration after scroll is enabled
1971 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1973 // Continuous scroll left to increase coverage
1974 for( unsigned int index = 0u; index < 10u; ++index )
1976 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1978 // Render and notify
1979 application.SendNotification();
1980 application.Render();
1982 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1983 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1984 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1985 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1986 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1988 // Press Escape to increase coverage
1989 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1990 application.SendNotification();
1991 application.Render();
1993 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1998 int utcDaliTextEditorEvent06(void)
2000 ToolkitTestApplication application;
2001 tet_infoline(" utcDaliTextEditorEvent06");
2003 // Checks if the highlight actor is created.
2005 TextEditor editor = TextEditor::New();
2006 DALI_TEST_CHECK( editor );
2008 application.GetScene().Add( editor );
2010 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2011 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2012 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2013 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2014 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2016 // Avoid a crash when core load gl resources.
2017 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2019 // Render and notify
2020 application.SendNotification();
2021 application.Render();
2023 // Tap on the text editor
2024 TestGenerateTap( application, 3.0f, 25.0f );
2026 // Render and notify
2027 application.SendNotification();
2028 application.Render();
2030 // Move to seconds line of the text.
2031 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2033 // Render and notify
2034 application.SendNotification();
2035 application.Render();
2037 float layoutHeight = editor.GetHeightForWidth( 100.f );
2040 // Add another script characters ( glyph height is defferent )
2041 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2044 // Delete characters
2045 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2048 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2054 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2057 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2058 application.SendNotification();
2059 application.Render();
2061 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062 application.SendNotification();
2063 application.Render();
2065 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066 application.SendNotification();
2067 application.Render();
2069 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 application.SendNotification();
2071 application.Render();
2073 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2074 application.SendNotification();
2075 application.Render();
2077 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078 application.SendNotification();
2079 application.Render();
2081 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082 application.SendNotification();
2083 application.Render();
2088 int utcDaliTextEditorEvent07(void)
2090 ToolkitTestApplication application;
2091 tet_infoline(" utcDaliTextEditorEvent07");
2093 // Checks if the highlight actor is created.
2095 TextEditor editor = TextEditor::New();
2096 DALI_TEST_CHECK( editor );
2098 application.GetScene().Add( editor );
2100 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2101 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2102 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2103 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2104 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2106 // Avoid a crash when core load gl resources.
2107 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2113 // Tap on the text editor
2114 TestGenerateTap( application, 3.0f, 25.0f );
2116 // Render and notify
2117 application.SendNotification();
2118 application.Render();
2120 // Move to second line of the text.
2121 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2123 // Render and notify
2124 application.SendNotification();
2125 application.Render();
2127 // Select some text in the right of the current cursor position
2128 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2130 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2131 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2133 // Render and notify
2134 application.SendNotification();
2135 application.Render();
2137 // Cut the selected text
2138 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2139 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 ) );
2141 // Render and notify
2142 application.SendNotification();
2143 application.Render();
2145 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2147 // Select some text in the left of the current cursor position
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2150 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2153 // Render and notify
2154 application.SendNotification();
2155 application.Render();
2157 // Copy the selected text
2158 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 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 ) );
2161 // Render and notify
2162 application.SendNotification();
2163 application.Render();
2165 // Move the cursor to the third line
2166 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2167 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169 // Render and notify
2170 application.SendNotification();
2171 application.Render();
2173 // Paste the selected text at the current cursor position
2174 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2175 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 ) );
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2184 // Disable Shift Selection
2185 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2187 // Test to select some text in the right of the current cursor position
2188 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 // Render and notify
2194 application.SendNotification();
2195 application.Render();
2197 // Cut the selected text
2198 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2199 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 ) );
2201 // Render and notify
2202 application.SendNotification();
2203 application.Render();
2205 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2206 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2208 // Test to select some text in the left of the current cursor position
2209 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2214 // Render and notify
2215 application.SendNotification();
2216 application.Render();
2218 // Copy the selected text
2219 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 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 ) );
2222 // Render and notify
2223 application.SendNotification();
2224 application.Render();
2226 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2227 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2230 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 ) );
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2236 // replace text with "c"
2237 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 // Render and notify
2240 application.SendNotification();
2241 application.Render();
2244 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2247 DevelTextEditor::SelectWholeText(editor);
2249 // Render and notify
2250 application.SendNotification();
2251 application.Render();
2253 // Copy the selected text using logical keys
2254 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2257 // Render and notify
2258 application.SendNotification();
2259 application.Render();
2262 DevelTextEditor::SelectNone(editor);
2264 // Render and notify
2265 application.SendNotification();
2266 application.Render();
2268 // Paste the selected using logical keys
2269 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2275 // select all using logical keys
2276 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 // cut text using logical keys
2284 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2285 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2287 // Render and notify
2288 application.SendNotification();
2289 application.Render();
2292 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2297 int utcDaliTextEditorEvent08(void)
2299 ToolkitTestApplication application;
2300 tet_infoline(" utcDaliTextEditorEvent08");
2302 // Checks if the highlight actor is released correctly.
2304 TextEditor editor = TextEditor::New();
2305 DALI_TEST_CHECK( editor );
2307 application.GetScene().Add( editor );
2309 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2310 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2311 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2312 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2313 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2315 // Avoid a crash when core load gl resources.
2316 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2322 // Tap on the text editor
2323 TestGenerateTap( application, 3.0f, 25.0f );
2325 // Render and notify
2326 application.SendNotification();
2327 application.Render();
2329 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2330 // Test to select some text in the left of the current cursor position
2331 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2334 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 // Test to the left selection handle position and the right selection handle position
2341 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Test to select full text in the left of the current cursor position
2351 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2355 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2356 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2358 // Render and notify
2359 application.SendNotification();
2360 application.Render();
2362 // Test to release the current full text selection
2363 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2364 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2366 // Render and notify
2367 application.SendNotification();
2368 application.Render();
2370 // Test to move the current cursor position correctly
2371 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2378 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 // Render and notify
2381 application.SendNotification();
2382 application.Render();
2384 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2386 // Test to select some text in the right of the current cursor position
2387 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2388 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2389 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 // Render and notify
2392 application.SendNotification();
2393 application.Render();
2395 // Test the cursor position with right arrow key
2396 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2398 // Render and notify
2399 application.SendNotification();
2400 application.Render();
2403 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2411 // Test to select some text in the left of the current cursor position
2412 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2413 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2415 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 // Test the cursor position with left arrow key
2423 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2425 // Render and notify
2426 application.SendNotification();
2427 application.Render();
2430 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2432 // Render and notify
2433 application.SendNotification();
2434 application.Render();
2436 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2438 // Test to select some text in the right of the current cursor position
2439 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 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( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2458 // Render and notify
2459 application.SendNotification();
2460 application.Render();
2462 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2464 // Test to select some text in the left 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_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2467 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2468 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 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 right arrow key
2475 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 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( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2484 // Render and notify
2485 application.SendNotification();
2486 application.Render();
2488 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2493 int utcDaliTextEditorHandles(void)
2495 ToolkitTestApplication application;
2496 tet_infoline(" utcDaliTextEditorHandles");
2498 TextEditor editor = TextEditor::New();
2499 DALI_TEST_CHECK( editor );
2501 application.GetScene().Add( editor );
2503 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2504 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2505 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2506 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2508 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2509 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2510 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2511 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2513 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2514 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2515 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2517 // Avoid a crash when core load gl resources.
2518 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2520 // Render and notify
2521 application.SendNotification();
2522 application.Render();
2524 // Tap first to get the focus.
2525 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2527 // Render and notify
2528 application.SendNotification();
2529 application.Render();
2531 // Tap to create the grab handle.
2532 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2534 // Render and notify
2535 application.SendNotification();
2536 application.Render();
2538 // Get the active layer where the text's decoration is added.
2539 Actor activeLayer = editor.GetChildAt( 1u );
2541 // Get the handle's actor.
2542 Actor handle = activeLayer.GetChildAt( 1u );
2543 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2545 // Render and notify
2546 application.SendNotification();
2547 application.Render();
2549 // Touch the grab handle to set it as pressed.
2550 Vector2 touchPos( 10.0f, 50.0f );
2551 Dali::Integration::TouchEvent event;
2552 event = Dali::Integration::TouchEvent();
2553 event.AddPoint( GetPointDownInside( touchPos ) );
2554 application.ProcessEvent( event );
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 // Pan the grab handle
2561 uint32_t time = 100;
2562 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2563 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2564 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2565 application.SendNotification();
2566 application.Render();
2569 // Release the grab handle.
2570 event = Dali::Integration::TouchEvent();
2571 event.AddPoint( GetPointUpInside( touchPos ) );
2572 application.ProcessEvent( event );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2578 // Tap first to get the focus.
2579 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2581 // Render and notify
2582 application.SendNotification();
2583 application.Render();
2585 // Double tap to select a word and create the selection handles.
2586 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2588 // Render and notify
2589 application.SendNotification();
2590 application.Render();
2592 touchPos = Vector2( 10.0f, 50.0f );
2594 // Touch the left selection handle to set it as pressed.
2595 event = Dali::Integration::TouchEvent();
2596 event.AddPoint( GetPointDownInside( touchPos ) );
2597 application.ProcessEvent( event );
2599 // Render and notify
2600 application.SendNotification();
2601 application.Render();
2603 // Release the left selection handle.
2604 event = Dali::Integration::TouchEvent();
2605 event.AddPoint( GetPointUpInside( touchPos ) );
2606 application.ProcessEvent( event );
2608 // Render and notify
2609 application.SendNotification();
2610 application.Render();
2615 int utcDaliTextEditorUnderPropertyStringP(void)
2617 ToolkitTestApplication application;
2618 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2619 TextEditor editor = TextEditor::New();
2620 DALI_TEST_CHECK( editor );
2622 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2624 application.GetScene().Add( editor );
2626 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2627 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2629 tet_infoline("Set underline settings with a map");
2630 // Check the input underline property
2631 Property::Map underlineMapSet;
2632 Property::Map underlineMapGet;
2633 underlineMapSet.Insert( "enable", true );
2634 underlineMapSet.Insert( "color", Color::BLUE );
2635 underlineMapSet.Insert( "height", 2 );
2637 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2638 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2639 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2640 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2642 tet_infoline("Set underline settings with a string");
2643 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2644 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2647 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2649 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2650 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2651 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2652 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2654 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2659 int utcDaliTextEditorShadowPropertyStringP(void)
2661 ToolkitTestApplication application;
2662 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2664 TextEditor editor = TextEditor::New();
2666 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2668 application.GetScene().Add( editor );
2670 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2672 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2676 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2681 int utcDaliTextEditorFontStylePropertyStringP(void)
2683 ToolkitTestApplication application;
2684 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2686 TextEditor editor = TextEditor::New();
2688 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2690 application.GetScene().Add( editor );
2692 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2694 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2698 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2703 int utcDaliTextEditorGetPropertyLinecountP(void)
2705 ToolkitTestApplication application;
2707 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2711 TextEditor editor = TextEditor::New();
2712 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2713 editor.SetProperty( TextEditor::Property::TEXT,
2714 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2716 application.GetScene().Add( editor );
2718 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2719 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2720 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2722 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2723 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2724 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2729 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2732 ToolkitTestApplication application;
2733 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2735 TextEditor editor = TextEditor::New();
2736 DALI_TEST_CHECK( editor );
2738 application.GetScene().Add( editor );
2740 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2741 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2742 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2743 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2744 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2745 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2747 bool startedCalled = false;
2748 bool finishedCalled = false;
2750 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2751 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2753 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2755 // Render and notify
2756 application.SendNotification();
2757 application.Render();
2759 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2760 application.SendNotification();
2761 application.Render(6000);
2763 application.SendNotification();
2764 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2765 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2770 int UtcDaliToolkitTextEditorTextWrapMode(void)
2772 ToolkitTestApplication application;
2773 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2777 TextEditor editor = TextEditor::New();
2778 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2779 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2781 application.GetScene().Add( editor );
2783 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2784 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2786 application.SendNotification();
2787 application.Render();
2789 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2790 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2792 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2793 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2795 application.SendNotification();
2796 application.Render();
2798 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2799 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2801 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2802 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2804 application.SendNotification();
2805 application.Render();
2807 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2808 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2810 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2811 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2813 application.SendNotification();
2814 application.Render();
2816 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2817 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2822 int UtcDaliTextEditorSetPaddingProperty(void)
2824 ToolkitTestApplication application;
2825 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2827 TextEditor editor = TextEditor::New();
2828 DALI_TEST_CHECK( editor );
2829 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2830 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2831 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2832 application.GetScene().Add( editor );
2834 application.SendNotification();
2835 application.Render();
2837 Vector3 originalSize = editor.GetNaturalSize();
2839 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2841 application.SendNotification();
2842 application.Render();
2844 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2846 Vector3 paddingAddedSize = editor.GetNaturalSize();
2848 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2850 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2855 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2857 ToolkitTestApplication application;
2858 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2860 TextEditor editor = TextEditor::New();
2861 DALI_TEST_CHECK( editor );
2862 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2863 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2864 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2865 application.GetScene().Add( editor );
2867 application.SendNotification();
2868 application.Render();
2870 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2871 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2873 // Check the enable shift selection property
2874 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2875 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2877 application.SendNotification();
2878 application.Render();
2883 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2885 ToolkitTestApplication application;
2886 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2888 TextEditor editor = TextEditor::New();
2889 DALI_TEST_CHECK( editor );
2890 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2891 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2892 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2893 application.GetScene().Add( editor );
2895 application.SendNotification();
2896 application.Render();
2898 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2899 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2901 // Check the enable grab handle property
2902 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2903 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2905 application.SendNotification();
2906 application.Render();
2911 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2913 ToolkitTestApplication application;
2914 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2916 TextEditor editor = TextEditor::New();
2917 DALI_TEST_CHECK( editor );
2918 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2919 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2920 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2921 application.GetScene().Add( editor );
2923 application.SendNotification();
2924 application.Render();
2926 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2927 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2929 // Check the enable match system language direction property
2930 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2931 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2933 application.SendNotification();
2934 application.Render();
2939 int UtcDaliTextEditorGetInputMethodContext(void)
2941 ToolkitTestApplication application;
2942 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2944 TextEditor editor = TextEditor::New();
2945 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2950 int utcDaliTextEditorMaxCharactersReached(void)
2952 ToolkitTestApplication application;
2953 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2955 TextEditor editor = TextEditor::New();
2956 DALI_TEST_CHECK( editor );
2958 application.GetScene().Add( editor );
2960 const int maxNumberOfCharacters = 1;
2961 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2962 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2964 editor.SetKeyInputFocus();
2966 // connect to the text changed signal.
2967 ConnectionTracker* testTracker = new ConnectionTracker();
2968 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2969 bool maxLengthReachedSignal = false;
2970 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2972 gMaxCharactersCallBackCalled = false;
2974 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2975 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2977 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2978 DALI_TEST_CHECK( maxLengthReachedSignal );
2983 int UtcDaliTextEditorSelectWholeText(void)
2985 ToolkitTestApplication application;
2986 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2988 TextEditor textEditor = TextEditor::New();
2990 application.GetScene().Add( textEditor );
2992 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2993 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2994 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2996 // Avoid a crash when core load gl resources.
2997 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2999 application.SendNotification();
3000 application.Render();
3002 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3004 DevelTextEditor::SelectWholeText( textEditor );
3006 application.SendNotification();
3007 application.Render();
3009 // Nothing should have been selected. The number of children is still 1
3010 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3012 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3014 application.SendNotification();
3015 application.Render();
3017 DevelTextEditor::SelectWholeText( textEditor );
3019 application.SendNotification();
3020 application.Render();
3022 // Should be 2 children, the stencil and the layer
3023 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3025 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3026 Actor stencil = textEditor.GetChildAt( 0u );
3028 // The highlight actor is drawn first, so is the first actor in the list
3029 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3030 DALI_TEST_CHECK( highlight );
3035 int UtcDaliTextEditorSelectNone(void)
3037 ToolkitTestApplication application;
3038 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3040 TextEditor textEditor = TextEditor::New();
3042 application.GetScene().Add( textEditor );
3044 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3045 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3046 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3048 // Avoid a crash when core load gl resources.
3049 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3051 application.SendNotification();
3052 application.Render();
3054 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3056 application.SendNotification();
3057 application.Render();
3059 // Nothing is selected
3060 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3061 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3063 DevelTextEditor::SelectWholeText( textEditor );
3065 application.SendNotification();
3066 application.Render();
3068 // whole text is selected
3069 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3070 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3072 DevelTextEditor::SelectNone( textEditor );
3074 application.SendNotification();
3075 application.Render();
3077 // Nothing is selected
3078 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3079 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3084 int UtcDaliTextEditorSelectRange(void)
3086 ToolkitTestApplication application;
3087 tet_infoline("utcDaliTextEditorSelectRange");
3089 TextEditor textEditor = TextEditor::New();
3090 DALI_TEST_CHECK( textEditor );
3092 application.GetScene().Add( textEditor );
3094 // Avoid a crash when core load gl resources.
3095 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3097 application.SendNotification();
3098 application.Render();
3100 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3102 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3103 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3105 // Hello is selected
3106 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3107 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3109 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3110 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3115 int UtcDaliTextEditorEnableEditing(void)
3117 ToolkitTestApplication application;
3118 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3120 TextEditor textEditor = TextEditor::New();
3122 application.GetScene().Add( textEditor );
3124 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3125 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3126 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3128 // Avoid a crash when core load gl resources.
3129 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3131 application.SendNotification();
3132 application.Render();
3134 textEditor.SetKeyInputFocus();
3135 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3136 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3138 // Render and notify
3139 application.SendNotification();
3140 application.Render();
3142 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3143 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3145 textEditor.SetKeyInputFocus();
3146 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3147 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3149 // Render and notify
3150 application.SendNotification();
3151 application.Render();
3153 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3154 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );