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 application.SendNotification();
961 application.Render();
962 DALI_TEST_CHECK( gTextChangedCallBackCalled );
963 DALI_TEST_CHECK( textChangedSignal );
965 editor.SetKeyInputFocus();
967 gTextChangedCallBackCalled = false;
968 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
969 application.SendNotification();
970 application.Render();
971 DALI_TEST_CHECK( gTextChangedCallBackCalled );
976 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
978 ToolkitTestApplication application;
979 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
980 TextEditor editor = TextEditor::New();
981 DALI_TEST_CHECK( editor );
984 application.GetScene().Add( editor );
986 // connect to the text changed signal.
987 ConnectionTracker* testTracker = new ConnectionTracker();
988 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
989 bool textChangedSignal = false;
990 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
993 // get InputMethodContext
995 InputMethodContext::EventData imfEvent;
996 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
998 editor.SetKeyInputFocus();
999 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1002 gTextChangedCallBackCalled = false;
1003 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1004 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1005 application.SendNotification();
1006 application.Render();
1007 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1008 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1010 gTextChangedCallBackCalled = false;
1011 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1012 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1013 application.SendNotification();
1014 application.Render();
1015 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1016 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1018 gTextChangedCallBackCalled = false;
1019 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1020 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1021 application.SendNotification();
1022 application.Render();
1023 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1024 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1026 gTextChangedCallBackCalled = false;
1027 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1028 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1029 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1031 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1032 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1033 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1035 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1036 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1037 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1039 application.SendNotification();
1040 application.Render();
1041 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1042 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1048 int utcDaliTextEditorInputStyleChanged01(void)
1050 // The text-editor emits signals when the input style changes. These changes of style are
1051 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1052 // can't be emitted during the size negotiation as the callbacks may update the UI.
1053 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1054 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1055 ToolkitTestApplication application;
1056 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1060 char* pathNamePtr = get_current_dir_name();
1061 const std::string pathName( pathNamePtr );
1062 free( pathNamePtr );
1064 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1065 fontClient.SetDpi( 93u, 93u );
1067 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1068 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1070 TextEditor editor = TextEditor::New();
1071 DALI_TEST_CHECK( editor );
1074 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1075 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1076 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1078 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1079 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1081 // connect to the text changed signal.
1082 ConnectionTracker* testTracker = new ConnectionTracker();
1083 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1084 bool inputStyleChangedSignal = false;
1085 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1087 application.GetScene().Add( editor );
1089 // Render and notify
1090 application.SendNotification();
1091 application.Render();
1093 // Executes the idle callbacks added by the text control on the change of input style.
1094 application.RunIdles();
1096 gInputStyleChangedCallbackCalled = false;
1097 gInputStyleMask = TextEditor::InputStyle::NONE;
1098 inputStyleChangedSignal = false;
1100 // Create a tap event to touch the text editor.
1101 TestGenerateTap( application, 18.0f, 25.0f );
1103 // Render and notify
1104 application.SendNotification();
1105 application.Render();
1107 // Executes the idle callbacks added by the text control on the change of input style.
1108 application.RunIdles();
1110 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1111 if( gInputStyleChangedCallbackCalled )
1113 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1115 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1116 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1118 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1119 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1121 DALI_TEST_CHECK( inputStyleChangedSignal );
1123 gInputStyleChangedCallbackCalled = false;
1124 gInputStyleMask = TextEditor::InputStyle::NONE;
1125 inputStyleChangedSignal = false;
1127 // Create a tap event to touch the text editor.
1128 TestGenerateTap( application, 30.0f, 25.0f );
1130 // Render and notify
1131 application.SendNotification();
1132 application.Render();
1134 // Executes the idle callbacks added by the text control on the change of input style.
1135 application.RunIdles();
1137 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1138 DALI_TEST_CHECK( !inputStyleChangedSignal );
1140 gInputStyleChangedCallbackCalled = false;
1141 gInputStyleMask = TextEditor::InputStyle::NONE;
1142 inputStyleChangedSignal = false;
1144 // Create a tap event to touch the text editor.
1145 TestGenerateTap( application, 43.0f, 25.0f );
1147 // Render and notify
1148 application.SendNotification();
1149 application.Render();
1151 // Executes the idle callbacks added by the text control on the change of input style.
1152 application.RunIdles();
1154 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1155 if( gInputStyleChangedCallbackCalled )
1157 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1159 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1160 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1162 DALI_TEST_CHECK( inputStyleChangedSignal );
1164 gInputStyleChangedCallbackCalled = false;
1165 gInputStyleMask = TextEditor::InputStyle::NONE;
1166 inputStyleChangedSignal = false;
1168 // Create a tap event to touch the text editor.
1169 TestGenerateTap( application, 88.0f, 25.0f );
1171 // Render and notify
1172 application.SendNotification();
1173 application.Render();
1175 // Executes the idle callbacks added by the text control on the change of input style.
1176 application.RunIdles();
1178 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1179 if( gInputStyleChangedCallbackCalled )
1181 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1183 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1184 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1186 Property::Map fontStyleMapSet;
1187 Property::Map fontStyleMapGet;
1189 fontStyleMapSet.Insert( "weight", "bold" );
1191 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1192 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1193 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1195 DALI_TEST_CHECK( inputStyleChangedSignal );
1197 gInputStyleChangedCallbackCalled = false;
1198 gInputStyleMask = TextEditor::InputStyle::NONE;
1199 inputStyleChangedSignal = false;
1201 // Create a tap event to touch the text editor.
1202 TestGenerateTap( application, 115.0f, 25.0f );
1204 // Render and notify
1205 application.SendNotification();
1206 application.Render();
1208 // Executes the idle callbacks added by the text control on the change of input style.
1209 application.RunIdles();
1211 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1212 DALI_TEST_CHECK( !inputStyleChangedSignal );
1214 gInputStyleChangedCallbackCalled = false;
1215 gInputStyleMask = TextEditor::InputStyle::NONE;
1216 inputStyleChangedSignal = false;
1218 // Create a tap event to touch the text editor.
1219 TestGenerateTap( application, 164.0f, 25.0f );
1221 // Render and notify
1222 application.SendNotification();
1223 application.Render();
1225 // Executes the idle callbacks added by the text control on the change of input style.
1226 application.RunIdles();
1228 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1229 if( gInputStyleChangedCallbackCalled )
1231 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1233 Property::Map fontStyleMapSet;
1234 Property::Map fontStyleMapGet;
1236 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1237 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1238 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1240 DALI_TEST_CHECK( inputStyleChangedSignal );
1242 gInputStyleChangedCallbackCalled = false;
1243 gInputStyleMask = TextEditor::InputStyle::NONE;
1244 inputStyleChangedSignal = false;
1246 // Create a tap event to touch the text editor.
1247 TestGenerateTap( application, 191.0f, 25.0f );
1249 // Render and notify
1250 application.SendNotification();
1251 application.Render();
1253 // Executes the idle callbacks added by the text control on the change of input style.
1254 application.RunIdles();
1256 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1257 DALI_TEST_CHECK( !inputStyleChangedSignal );
1262 int utcDaliTextEditorInputStyleChanged02(void)
1264 // The text-editor emits signals when the input style changes. These changes of style are
1265 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1266 // can't be emitted during the size negotiation as the callbacks may update the UI.
1267 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1268 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1269 ToolkitTestApplication application;
1270 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1274 char* pathNamePtr = get_current_dir_name();
1275 const std::string pathName( pathNamePtr );
1276 free( pathNamePtr );
1278 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1279 fontClient.SetDpi( 93u, 93u );
1281 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1282 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1284 TextEditor editor = TextEditor::New();
1285 DALI_TEST_CHECK( editor );
1288 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1289 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1290 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1292 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1293 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>" );
1295 // connect to the text changed signal.
1296 ConnectionTracker* testTracker = new ConnectionTracker();
1297 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1298 bool inputStyleChangedSignal = false;
1299 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1301 application.GetScene().Add( editor );
1303 // Render and notify
1304 application.SendNotification();
1305 application.Render();
1307 // Executes the idle callbacks added by the text control on the change of input style.
1308 application.RunIdles();
1310 gInputStyleChangedCallbackCalled = false;
1311 gInputStyleMask = TextEditor::InputStyle::NONE;
1312 inputStyleChangedSignal = false;
1314 // Create a tap event to touch the text editor.
1315 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1316 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1318 // Render and notify
1319 application.SendNotification();
1320 application.Render();
1322 // Executes the idle callbacks added by the text control on the change of input style.
1323 application.RunIdles();
1325 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1326 if( gInputStyleChangedCallbackCalled )
1328 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1329 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1330 TextEditor::InputStyle::POINT_SIZE |
1331 TextEditor::InputStyle::COLOR ),
1334 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1335 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1337 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1338 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1340 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1341 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1343 DALI_TEST_CHECK( inputStyleChangedSignal );
1345 gInputStyleChangedCallbackCalled = false;
1346 gInputStyleMask = TextEditor::InputStyle::NONE;
1347 inputStyleChangedSignal = false;
1349 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1351 // Render and notify
1352 application.SendNotification();
1353 application.Render();
1355 // Executes the idle callbacks added by the text control on the change of input style.
1356 application.RunIdles();
1358 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1359 if( gInputStyleChangedCallbackCalled )
1361 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1362 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1365 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1366 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1368 DALI_TEST_CHECK( inputStyleChangedSignal );
1370 gInputStyleChangedCallbackCalled = false;
1371 gInputStyleMask = TextEditor::InputStyle::NONE;
1372 inputStyleChangedSignal = false;
1374 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1376 // Render and notify
1377 application.SendNotification();
1378 application.Render();
1380 // Executes the idle callbacks added by the text control on the change of input style.
1381 application.RunIdles();
1383 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1384 DALI_TEST_CHECK( !inputStyleChangedSignal );
1386 gInputStyleChangedCallbackCalled = false;
1387 gInputStyleMask = TextEditor::InputStyle::NONE;
1388 inputStyleChangedSignal = false;
1390 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1392 // Render and notify
1393 application.SendNotification();
1394 application.Render();
1396 // Executes the idle callbacks added by the text control on the change of input style.
1397 application.RunIdles();
1399 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1400 if( gInputStyleChangedCallbackCalled )
1402 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1403 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1406 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1407 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1409 DALI_TEST_CHECK( inputStyleChangedSignal );
1411 gInputStyleChangedCallbackCalled = false;
1412 gInputStyleMask = TextEditor::InputStyle::NONE;
1413 inputStyleChangedSignal = false;
1415 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1417 Property::Map fontStyleMapSet;
1418 fontStyleMapSet.Insert( "weight", "thin" );
1419 fontStyleMapSet.Insert( "width", "condensed" );
1420 fontStyleMapSet.Insert( "slant", "italic" );
1422 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1423 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1424 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1426 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1427 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1428 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1429 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1431 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1433 // Render and notify
1434 application.SendNotification();
1435 application.Render();
1437 // Executes the idle callbacks added by the text control on the change of input style.
1438 application.RunIdles();
1440 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1441 DALI_TEST_CHECK( !inputStyleChangedSignal );
1443 // Create a tap event to touch the text editor.
1444 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1446 // Render and notify
1447 application.SendNotification();
1448 application.Render();
1450 // Executes the idle callbacks added by the text control on the change of input style.
1451 application.RunIdles();
1453 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1454 if( gInputStyleChangedCallbackCalled )
1456 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1457 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1458 TextEditor::InputStyle::POINT_SIZE |
1459 TextEditor::InputStyle::FONT_STYLE |
1460 TextEditor::InputStyle::LINE_SPACING |
1461 TextEditor::InputStyle::UNDERLINE |
1462 TextEditor::InputStyle::SHADOW |
1463 TextEditor::InputStyle::EMBOSS |
1464 TextEditor::InputStyle::OUTLINE ),
1467 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1468 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1470 DALI_TEST_CHECK( inputStyleChangedSignal );
1472 gInputStyleChangedCallbackCalled = false;
1473 gInputStyleMask = TextEditor::InputStyle::NONE;
1474 inputStyleChangedSignal = false;
1476 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1478 fontStyleMapSet.Clear();
1479 fontStyleMapSet.Insert( "weight", "black" );
1480 fontStyleMapSet.Insert( "width", "expanded" );
1481 fontStyleMapSet.Insert( "slant", "oblique" );
1483 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1485 // Create a tap event to touch the text editor.
1486 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 // Executes the idle callbacks added by the text control on the change of input style.
1493 application.RunIdles();
1495 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1496 if( gInputStyleChangedCallbackCalled )
1498 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1499 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1500 TextEditor::InputStyle::POINT_SIZE |
1501 TextEditor::InputStyle::FONT_STYLE ),
1504 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1505 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1507 DALI_TEST_CHECK( inputStyleChangedSignal );
1512 int utcDaliTextEditorEvent01(void)
1514 ToolkitTestApplication application;
1515 tet_infoline(" utcDaliTextEditorEvent01");
1517 // Creates a tap event. After creating a tap event the text editor should
1518 // have the focus and add text with key events should be possible.
1520 TextEditor editor = TextEditor::New();
1521 DALI_TEST_CHECK( editor );
1523 application.GetScene().Add( editor );
1525 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1526 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1527 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1529 // Avoid a crash when core load gl resources.
1530 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 // Add a key event but as the text editor has not the focus it should do nothing.
1537 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1539 // Render and notify
1540 application.SendNotification();
1541 application.Render();
1543 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1545 // Create a tap event to touch the text editor.
1546 TestGenerateTap( application, 150.0f, 25.0f );
1548 // Render and notify
1549 application.SendNotification();
1550 application.Render();
1552 // Now the text editor has the focus, so it can handle the key events.
1553 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1554 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1556 // Render and notify
1557 application.SendNotification();
1558 application.Render();
1560 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1562 // Create a second text editor and send key events to it.
1563 TextEditor editor2 = TextEditor::New();
1565 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1566 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1567 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1568 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1570 application.GetScene().Add( editor2 );
1572 // Render and notify
1573 application.SendNotification();
1574 application.Render();
1576 // Create a tap event on the second text editor.
1577 TestGenerateTap( application, 150.0f, 125.0f );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 // The second text editor has the focus. It should handle the key events.
1584 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1585 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1587 // Render and notify
1588 application.SendNotification();
1589 application.Render();
1591 // Check the text has been added to the second text editor.
1592 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1597 int utcDaliTextEditorEvent02(void)
1599 ToolkitTestApplication application;
1600 tet_infoline(" utcDaliTextEditorEvent02");
1602 // Checks if the right number of actors are created.
1604 TextEditor editor = TextEditor::New();
1605 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1606 DALI_TEST_CHECK( editor );
1608 application.GetScene().Add( editor );
1610 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1611 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1612 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1614 // Avoid a crash when core load gl resources.
1615 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1617 // Render and notify
1618 application.SendNotification();
1619 application.Render();
1621 // Check there are the expected number of children (the stencil).
1622 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1624 Actor stencil = editor.GetChildAt( 0u );
1626 // Create a tap event to touch the text editor.
1627 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1629 // Render and notify
1630 application.SendNotification();
1631 application.Render();
1633 Actor layer = editor.GetChildAt( 1u );
1634 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1635 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1637 // Now the text editor has the focus, so it can handle the key events.
1638 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Checks the cursor and the renderer have been created.
1646 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1647 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1649 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1650 DALI_TEST_CHECK( cursor );
1652 // The stencil actor has a container with all the actors which contain the text renderers.
1653 Actor container = stencil.GetChildAt( 0u );
1654 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1656 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1657 DALI_TEST_CHECK( renderer );
1660 // Move the cursor and check the position changes.
1661 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1663 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1664 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1672 DALI_TEST_CHECK( position2.x < position1.x );
1674 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1675 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1683 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1685 // Send some taps and check the cursor positions.
1687 // Try to tap at the beginning.
1688 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1690 // Render and notify
1691 application.SendNotification();
1692 application.Render();
1694 // Cursor position should be the same than position1.
1695 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1697 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1699 // Tap away from the start position.
1700 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1708 DALI_TEST_CHECK( position5.x > position4.x );
1710 // Remove all the text.
1711 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1712 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1713 editor.SetProperty( TextEditor::Property::TEXT, "" );
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Cursor position should be the same than position2.
1720 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1722 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1724 // Should not be a renderer.
1725 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1730 int utcDaliTextEditorEvent03(void)
1732 ToolkitTestApplication application;
1733 tet_infoline(" utcDaliTextEditorEvent03");
1735 // Checks if the highlight actor is created.
1737 TextEditor editor = TextEditor::New();
1738 DALI_TEST_CHECK( editor );
1740 application.GetScene().Add( editor );
1742 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1743 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1744 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1745 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1746 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1748 // Avoid a crash when core load gl resources.
1749 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1755 // Send some taps and check text controller with clipboard window
1756 Dali::Clipboard clipboard = Clipboard::Get();
1757 clipboard.ShowClipboard();
1758 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1759 clipboard.HideClipboard();
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 // Tap first to get the focus.
1766 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1768 // Render and notify
1769 application.SendNotification();
1770 application.Render();
1772 // Double tap to select a word.
1773 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 // The stencil actor should have two actors: the renderer and the highlight actor.
1780 Actor stencil = editor.GetChildAt( 0u );
1782 // Highlight needs to be drawn before text, so should come first in child order
1783 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1784 DALI_TEST_CHECK( highlight );
1786 // The stencil actor has a container with all the actors which contain the text renderers.
1787 Actor container = stencil.GetChildAt( 1u );
1788 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1790 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1791 DALI_TEST_CHECK( renderer );
1794 // Double tap out of bounds
1795 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1796 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1798 // Render and notify
1799 application.SendNotification();
1800 application.Render();
1802 // The stencil actor should have one actors: the renderer actor.
1803 stencil = editor.GetChildAt( 0u );
1805 // The stencil actor has a container with all the actors which contain the text renderers.
1806 container = stencil.GetChildAt( 0u );
1807 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1809 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1810 DALI_TEST_CHECK( renderer );
1814 TestGenerateLongPress(application, 1.0f, 25.0f);
1816 // Render and notify
1817 application.SendNotification();
1818 application.Render();
1821 TestGenerateMiniPan(application);
1823 // Render and notify
1824 application.SendNotification();
1825 application.Render();
1830 int utcDaliTextEditorEvent04(void)
1832 ToolkitTestApplication application;
1833 tet_infoline(" utcDaliTextEditorEvent04");
1835 // Checks if the highlight actor is created.
1837 TextEditor editor = TextEditor::New();
1838 DALI_TEST_CHECK( editor );
1840 application.GetScene().Add( editor );
1842 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1843 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1844 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1845 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1846 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1848 // Avoid a crash when core load gl resources.
1849 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1855 // Tap on the text editor
1856 TestGenerateTap( application, 3.0f, 25.0f );
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1862 // Move at the end of the text.
1863 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1864 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1870 for( unsigned int index = 0u; index < 10u; ++index )
1872 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1873 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1881 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1889 // Add some key events
1890 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1891 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 for( unsigned int index = 0u; index < 10u; ++index )
1899 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1900 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1908 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1919 int utcDaliTextEditorEvent05(void)
1921 ToolkitTestApplication application;
1922 tet_infoline(" utcDaliTextEditorEvent05");
1924 // Checks if the highlight actor is created.
1926 TextEditor editor = TextEditor::New();
1927 DALI_TEST_CHECK( editor );
1929 application.GetScene().Add( editor );
1931 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1932 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1933 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1934 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1935 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1936 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1937 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1938 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1939 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1940 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1942 // Avoid a crash when core load gl resources.
1943 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 // Tap on the text editor
1950 TestGenerateTap( application, 3.0f, 25.0f );
1952 // Render and notify
1953 application.SendNotification();
1954 application.Render();
1956 // Move at the end of the text.
1957 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1958 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1960 // Render and notify
1961 application.SendNotification();
1962 application.Render();
1964 for( unsigned int index = 0u; index < 10u; ++index )
1967 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1969 // Render and notify
1970 application.SendNotification();
1971 application.Render();
1973 // Modify duration after scroll is enabled
1974 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1976 // Continuous scroll left to increase coverage
1977 for( unsigned int index = 0u; index < 10u; ++index )
1979 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1981 // Render and notify
1982 application.SendNotification();
1983 application.Render();
1985 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1986 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1987 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1988 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1989 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1991 // Press Escape to increase coverage
1992 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1993 application.SendNotification();
1994 application.Render();
1996 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2001 int utcDaliTextEditorEvent06(void)
2003 ToolkitTestApplication application;
2004 tet_infoline(" utcDaliTextEditorEvent06");
2006 // Checks if the highlight actor is created.
2008 TextEditor editor = TextEditor::New();
2009 DALI_TEST_CHECK( editor );
2011 application.GetScene().Add( editor );
2013 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2014 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2015 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2016 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2017 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2019 // Avoid a crash when core load gl resources.
2020 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2022 // Render and notify
2023 application.SendNotification();
2024 application.Render();
2026 // Tap on the text editor
2027 TestGenerateTap( application, 3.0f, 25.0f );
2029 // Render and notify
2030 application.SendNotification();
2031 application.Render();
2033 // Move to seconds line of the text.
2034 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2036 // Render and notify
2037 application.SendNotification();
2038 application.Render();
2040 float layoutHeight = editor.GetHeightForWidth( 100.f );
2043 // Add another script characters ( glyph height is defferent )
2044 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2047 // Delete characters
2048 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2049 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2060 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2061 application.SendNotification();
2062 application.Render();
2064 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 application.SendNotification();
2066 application.Render();
2068 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2069 application.SendNotification();
2070 application.Render();
2072 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2073 application.SendNotification();
2074 application.Render();
2076 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2077 application.SendNotification();
2078 application.Render();
2080 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081 application.SendNotification();
2082 application.Render();
2084 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2085 application.SendNotification();
2086 application.Render();
2091 int utcDaliTextEditorEvent07(void)
2093 ToolkitTestApplication application;
2094 tet_infoline(" utcDaliTextEditorEvent07");
2096 // Checks if the highlight actor is created.
2098 TextEditor editor = TextEditor::New();
2099 DALI_TEST_CHECK( editor );
2101 application.GetScene().Add( editor );
2103 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2104 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2105 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2106 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2107 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2109 // Avoid a crash when core load gl resources.
2110 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2116 // Tap on the text editor
2117 TestGenerateTap( application, 3.0f, 25.0f );
2119 // Render and notify
2120 application.SendNotification();
2121 application.Render();
2123 // Move to second line of the text.
2124 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2126 // Render and notify
2127 application.SendNotification();
2128 application.Render();
2130 // Select some text in the right of the current cursor position
2131 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2132 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2133 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // Cut the selected text
2141 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2142 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 ) );
2144 // Render and notify
2145 application.SendNotification();
2146 application.Render();
2148 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2150 // Select some text in the left of the current cursor position
2151 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2152 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2153 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2154 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 // Render and notify
2157 application.SendNotification();
2158 application.Render();
2160 // Copy the selected text
2161 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2162 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 ) );
2164 // Render and notify
2165 application.SendNotification();
2166 application.Render();
2168 // Move the cursor to the third line
2169 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2170 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 // Paste the selected text at the current cursor position
2177 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2178 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 ) );
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2187 // Disable Shift Selection
2188 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2190 // Test to select some text in the right of the current cursor position
2191 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2194 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2196 // Render and notify
2197 application.SendNotification();
2198 application.Render();
2200 // Cut the selected text
2201 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 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 ) );
2204 // Render and notify
2205 application.SendNotification();
2206 application.Render();
2208 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2209 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2211 // Test to select some text in the left of the current cursor position
2212 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2214 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 // Render and notify
2218 application.SendNotification();
2219 application.Render();
2221 // Copy the selected text
2222 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2223 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 ) );
2225 // Render and notify
2226 application.SendNotification();
2227 application.Render();
2229 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2230 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2233 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 ) );
2235 // Render and notify
2236 application.SendNotification();
2237 application.Render();
2239 // replace text with "c"
2240 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242 // Render and notify
2243 application.SendNotification();
2244 application.Render();
2247 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2250 DevelTextEditor::SelectWholeText(editor);
2252 // Render and notify
2253 application.SendNotification();
2254 application.Render();
2256 // Copy the selected text using logical keys
2257 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2258 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2265 DevelTextEditor::SelectNone(editor);
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // Paste the selected using logical keys
2272 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2278 // select all using logical keys
2279 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2286 // cut text using logical keys
2287 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 // Render and notify
2291 application.SendNotification();
2292 application.Render();
2295 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2300 int utcDaliTextEditorEvent08(void)
2302 ToolkitTestApplication application;
2303 tet_infoline(" utcDaliTextEditorEvent08");
2305 // Checks if the highlight actor is released correctly.
2307 TextEditor editor = TextEditor::New();
2308 DALI_TEST_CHECK( editor );
2310 application.GetScene().Add( editor );
2312 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2313 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2314 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2315 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2316 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2318 // Avoid a crash when core load gl resources.
2319 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2321 // Render and notify
2322 application.SendNotification();
2323 application.Render();
2325 // Tap on the text editor
2326 TestGenerateTap( application, 3.0f, 25.0f );
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2333 // Test to select some text in the left of the current cursor position
2334 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2336 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2337 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
2343 // Test to the left selection handle position and the right selection handle position
2344 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2346 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2347 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2349 // Render and notify
2350 application.SendNotification();
2351 application.Render();
2353 // Test to select full text in the left of the current cursor position
2354 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2357 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2358 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2359 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2365 // Test to release the current full text selection
2366 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 // Render and notify
2370 application.SendNotification();
2371 application.Render();
2373 // Test to move the current cursor position correctly
2374 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 // Render and notify
2377 application.SendNotification();
2378 application.Render();
2381 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2383 // Render and notify
2384 application.SendNotification();
2385 application.Render();
2387 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2389 // Test to select some text in the right of the current cursor position
2390 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2394 // Render and notify
2395 application.SendNotification();
2396 application.Render();
2398 // Test the cursor position with right arrow key
2399 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2401 // Render and notify
2402 application.SendNotification();
2403 application.Render();
2406 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 // Render and notify
2409 application.SendNotification();
2410 application.Render();
2412 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2414 // Test to select some text in the left of the current cursor position
2415 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2416 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2418 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 // Test the cursor position with left arrow key
2426 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2428 // Render and notify
2429 application.SendNotification();
2430 application.Render();
2433 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2435 // Render and notify
2436 application.SendNotification();
2437 application.Render();
2439 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2441 // Test to select some text in the right of the current cursor position
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2443 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2445 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2447 // Render and notify
2448 application.SendNotification();
2449 application.Render();
2451 // Test the cursor position with left arrow key
2452 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2454 // Render and notify
2455 application.SendNotification();
2456 application.Render();
2459 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2461 // Render and notify
2462 application.SendNotification();
2463 application.Render();
2465 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2467 // Test to select some text in the left of the current cursor position
2468 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2469 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2470 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2471 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 // Test the cursor position with right arrow key
2478 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2480 // Render and notify
2481 application.SendNotification();
2482 application.Render();
2485 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2487 // Render and notify
2488 application.SendNotification();
2489 application.Render();
2491 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2496 int utcDaliTextEditorHandles(void)
2498 ToolkitTestApplication application;
2499 tet_infoline(" utcDaliTextEditorHandles");
2501 TextEditor editor = TextEditor::New();
2502 DALI_TEST_CHECK( editor );
2504 application.GetScene().Add( editor );
2506 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2507 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2508 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2509 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2511 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2512 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2513 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2514 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2516 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2517 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2518 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2520 // Avoid a crash when core load gl resources.
2521 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Tap first to get the focus.
2528 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Tap to create the grab handle.
2535 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2541 // Get the active layer where the text's decoration is added.
2542 Actor activeLayer = editor.GetChildAt( 1u );
2544 // Get the handle's actor.
2545 Actor handle = activeLayer.GetChildAt( 1u );
2546 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2548 // Render and notify
2549 application.SendNotification();
2550 application.Render();
2552 // Touch the grab handle to set it as pressed.
2553 Vector2 touchPos( 10.0f, 50.0f );
2554 Dali::Integration::TouchEvent event;
2555 event = Dali::Integration::TouchEvent();
2556 event.AddPoint( GetPointDownInside( touchPos ) );
2557 application.ProcessEvent( event );
2559 // Render and notify
2560 application.SendNotification();
2561 application.Render();
2563 // Pan the grab handle
2564 uint32_t time = 100;
2565 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2566 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2567 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2568 application.SendNotification();
2569 application.Render();
2572 // Release the grab handle.
2573 event = Dali::Integration::TouchEvent();
2574 event.AddPoint( GetPointUpInside( touchPos ) );
2575 application.ProcessEvent( event );
2577 // Render and notify
2578 application.SendNotification();
2579 application.Render();
2581 // Tap first to get the focus.
2582 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2584 // Render and notify
2585 application.SendNotification();
2586 application.Render();
2588 // Double tap to select a word and create the selection handles.
2589 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2591 // Render and notify
2592 application.SendNotification();
2593 application.Render();
2595 touchPos = Vector2( 10.0f, 50.0f );
2597 // Touch the left selection handle to set it as pressed.
2598 event = Dali::Integration::TouchEvent();
2599 event.AddPoint( GetPointDownInside( touchPos ) );
2600 application.ProcessEvent( event );
2602 // Render and notify
2603 application.SendNotification();
2604 application.Render();
2606 // Release the left selection handle.
2607 event = Dali::Integration::TouchEvent();
2608 event.AddPoint( GetPointUpInside( touchPos ) );
2609 application.ProcessEvent( event );
2611 // Render and notify
2612 application.SendNotification();
2613 application.Render();
2618 int utcDaliTextEditorUnderPropertyStringP(void)
2620 ToolkitTestApplication application;
2621 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2622 TextEditor editor = TextEditor::New();
2623 DALI_TEST_CHECK( editor );
2625 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2627 application.GetScene().Add( editor );
2629 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2630 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2632 tet_infoline("Set underline settings with a map");
2633 // Check the input underline property
2634 Property::Map underlineMapSet;
2635 Property::Map underlineMapGet;
2636 underlineMapSet.Insert( "enable", true );
2637 underlineMapSet.Insert( "color", Color::BLUE );
2638 underlineMapSet.Insert( "height", 2 );
2640 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2641 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2642 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2643 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2645 tet_infoline("Set underline settings with a string");
2646 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2647 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2650 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2652 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2653 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2654 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2655 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2657 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2662 int utcDaliTextEditorShadowPropertyStringP(void)
2664 ToolkitTestApplication application;
2665 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2667 TextEditor editor = TextEditor::New();
2669 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2671 application.GetScene().Add( editor );
2673 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2675 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2679 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2684 int utcDaliTextEditorFontStylePropertyStringP(void)
2686 ToolkitTestApplication application;
2687 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2689 TextEditor editor = TextEditor::New();
2691 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2693 application.GetScene().Add( editor );
2695 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2697 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2701 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2706 int utcDaliTextEditorGetPropertyLinecountP(void)
2708 ToolkitTestApplication application;
2710 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2714 TextEditor editor = TextEditor::New();
2715 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2716 editor.SetProperty( TextEditor::Property::TEXT,
2717 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2719 application.GetScene().Add( editor );
2721 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2722 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2723 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2725 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2726 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2727 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2732 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2735 ToolkitTestApplication application;
2736 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2738 TextEditor editor = TextEditor::New();
2739 DALI_TEST_CHECK( editor );
2741 application.GetScene().Add( editor );
2743 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2744 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2745 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2746 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2747 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2748 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2750 bool startedCalled = false;
2751 bool finishedCalled = false;
2753 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2754 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2756 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2758 // Render and notify
2759 application.SendNotification();
2760 application.Render();
2762 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2763 application.SendNotification();
2764 application.Render(6000);
2766 application.SendNotification();
2767 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2768 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2773 int UtcDaliToolkitTextEditorTextWrapMode(void)
2775 ToolkitTestApplication application;
2776 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2780 TextEditor editor = TextEditor::New();
2781 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2782 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2784 application.GetScene().Add( editor );
2786 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2787 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2789 application.SendNotification();
2790 application.Render();
2792 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2793 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2795 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2796 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2798 application.SendNotification();
2799 application.Render();
2801 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2802 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2804 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2805 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2807 application.SendNotification();
2808 application.Render();
2810 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2811 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2813 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2814 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2816 application.SendNotification();
2817 application.Render();
2819 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2820 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2825 int UtcDaliTextEditorSetPaddingProperty(void)
2827 ToolkitTestApplication application;
2828 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2830 TextEditor editor = TextEditor::New();
2831 DALI_TEST_CHECK( editor );
2832 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2833 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2834 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2835 application.GetScene().Add( editor );
2837 application.SendNotification();
2838 application.Render();
2840 Vector3 originalSize = editor.GetNaturalSize();
2842 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2844 application.SendNotification();
2845 application.Render();
2847 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2849 Vector3 paddingAddedSize = editor.GetNaturalSize();
2851 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2853 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2858 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2860 ToolkitTestApplication application;
2861 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2863 TextEditor editor = TextEditor::New();
2864 DALI_TEST_CHECK( editor );
2865 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2866 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2867 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2868 application.GetScene().Add( editor );
2870 application.SendNotification();
2871 application.Render();
2873 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2874 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2876 // Check the enable shift selection property
2877 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2878 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2880 application.SendNotification();
2881 application.Render();
2886 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2888 ToolkitTestApplication application;
2889 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2891 TextEditor editor = TextEditor::New();
2892 DALI_TEST_CHECK( editor );
2893 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2894 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2895 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2896 application.GetScene().Add( editor );
2898 application.SendNotification();
2899 application.Render();
2901 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2902 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2904 // Check the enable grab handle property
2905 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2906 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2908 application.SendNotification();
2909 application.Render();
2914 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2916 ToolkitTestApplication application;
2917 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2919 TextEditor editor = TextEditor::New();
2920 DALI_TEST_CHECK( editor );
2921 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2922 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2923 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2924 application.GetScene().Add( editor );
2926 application.SendNotification();
2927 application.Render();
2929 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2930 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2932 // Check the enable match system language direction property
2933 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2934 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2936 application.SendNotification();
2937 application.Render();
2942 int UtcDaliTextEditorGetInputMethodContext(void)
2944 ToolkitTestApplication application;
2945 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2947 TextEditor editor = TextEditor::New();
2948 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
2953 int utcDaliTextEditorMaxCharactersReached(void)
2955 ToolkitTestApplication application;
2956 tet_infoline("utcDaliTextEditorMaxCharactersReached");
2958 TextEditor editor = TextEditor::New();
2959 DALI_TEST_CHECK( editor );
2961 application.GetScene().Add( editor );
2963 const int maxNumberOfCharacters = 1;
2964 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
2965 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
2967 editor.SetKeyInputFocus();
2969 // connect to the text changed signal.
2970 ConnectionTracker* testTracker = new ConnectionTracker();
2971 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
2972 bool maxLengthReachedSignal = false;
2973 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
2975 gMaxCharactersCallBackCalled = false;
2977 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2978 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2980 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
2981 DALI_TEST_CHECK( maxLengthReachedSignal );
2986 int UtcDaliTextEditorSelectWholeText(void)
2988 ToolkitTestApplication application;
2989 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
2991 TextEditor textEditor = TextEditor::New();
2993 application.GetScene().Add( textEditor );
2995 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2996 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2997 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2999 // Avoid a crash when core load gl resources.
3000 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3002 application.SendNotification();
3003 application.Render();
3005 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3007 DevelTextEditor::SelectWholeText( textEditor );
3009 application.SendNotification();
3010 application.Render();
3012 // Nothing should have been selected. The number of children is still 1
3013 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3015 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3017 application.SendNotification();
3018 application.Render();
3020 DevelTextEditor::SelectWholeText( textEditor );
3022 application.SendNotification();
3023 application.Render();
3025 // Should be 2 children, the stencil and the layer
3026 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3028 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3029 Actor stencil = textEditor.GetChildAt( 0u );
3031 // The highlight actor is drawn first, so is the first actor in the list
3032 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3033 DALI_TEST_CHECK( highlight );
3038 int UtcDaliTextEditorSelectNone(void)
3040 ToolkitTestApplication application;
3041 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3043 TextEditor textEditor = TextEditor::New();
3045 application.GetScene().Add( textEditor );
3047 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3048 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3049 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3051 // Avoid a crash when core load gl resources.
3052 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3054 application.SendNotification();
3055 application.Render();
3057 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3059 application.SendNotification();
3060 application.Render();
3062 // Nothing is selected
3063 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3064 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3066 DevelTextEditor::SelectWholeText( textEditor );
3068 application.SendNotification();
3069 application.Render();
3071 // whole text is selected
3072 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3073 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3075 DevelTextEditor::SelectNone( textEditor );
3077 application.SendNotification();
3078 application.Render();
3080 // Nothing is selected
3081 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3082 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3087 int UtcDaliTextEditorSelectRange(void)
3089 ToolkitTestApplication application;
3090 tet_infoline("utcDaliTextEditorSelectRange");
3092 TextEditor textEditor = TextEditor::New();
3093 DALI_TEST_CHECK( textEditor );
3095 application.GetScene().Add( textEditor );
3097 // Avoid a crash when core load gl resources.
3098 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3100 application.SendNotification();
3101 application.Render();
3103 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3105 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3106 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3108 // Hello is selected
3109 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3110 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3112 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3113 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3118 int UtcDaliTextEditorEnableEditing(void)
3120 ToolkitTestApplication application;
3121 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3123 TextEditor textEditor = TextEditor::New();
3125 application.GetScene().Add( textEditor );
3127 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3128 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3129 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3131 // Avoid a crash when core load gl resources.
3132 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3134 application.SendNotification();
3135 application.Render();
3137 textEditor.SetKeyInputFocus();
3138 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3139 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3141 // Render and notify
3142 application.SendNotification();
3143 application.Render();
3145 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3146 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3148 textEditor.SetKeyInputFocus();
3149 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3150 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3152 // Render and notify
3153 application.SendNotification();
3154 application.Render();
3156 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3157 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );