2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
102 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
103 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
104 const char* const PROPERTY_NAME_MAX_LENGTH = "maxLength";
105 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
106 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR = "grabHandleColor";
109 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
110 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
112 const float RENDER_FRAME_INTERVAL = 16.66f;
114 const unsigned int DEFAULT_FONT_SIZE = 1152u;
115 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
117 const int KEY_A_CODE = 38;
118 const int KEY_D_CODE = 40;
119 const int KEY_C_CODE = 54;
120 const int KEY_V_CODE = 55;
121 const int KEY_X_CODE = 53;
122 const int KEY_WHITE_SPACE_CODE = 65;
124 const int KEY_SHIFT_MODIFIER = 257;
125 const int KEY_CONTROL_MODIFIER = 258;
127 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
128 const char* HANDLE_LEFT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_left.png";
129 const char* HANDLE_RIGHT_SELECTION_FILE_NAME = TEST_RESOURCE_DIR "/selection_handle_drop_right.png";
131 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
133 static bool gAnchorClickedCallBackCalled;
134 static bool gAnchorClickedCallBackNotCalled;
135 static bool gTextChangedCallBackCalled;
136 static bool gInputStyleChangedCallbackCalled;
137 static bool gMaxCharactersCallBackCalled;
138 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
140 struct CallbackFunctor
142 CallbackFunctor(bool* callbackFlag)
143 : mCallbackFlag( callbackFlag )
149 *mCallbackFlag = true;
154 static void TestAnchorClickedCallback(TextEditor control, const char* href, unsigned int hrefLength)
156 tet_infoline(" TestAnchorClickedCallback");
158 gAnchorClickedCallBackNotCalled = false;
160 if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
162 gAnchorClickedCallBackCalled = true;
166 static void TestTextChangedCallback( TextEditor control )
168 tet_infoline(" TestTextChangedCallback");
170 gTextChangedCallBackCalled = true;
173 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
175 tet_infoline(" TestInputStyleChangedCallback");
177 gInputStyleChangedCallbackCalled = true;
178 gInputStyleMask = mask;
181 static void TestMaxLengthReachedCallback( TextEditor control )
183 tet_infoline(" TestMaxLengthReachedCallback");
185 gMaxCharactersCallBackCalled = true;
188 // Generate a KeyEvent to send to Core.
189 Integration::KeyEvent GenerateKey( const std::string& keyName,
190 const std::string& logicalKey,
191 const std::string& keyString,
194 unsigned long timeStamp,
195 const Integration::KeyEvent::State& keyState,
196 const std::string& compose = "",
197 const std::string& deviceName = DEFAULT_DEVICE_NAME,
198 const Device::Class::Type& deviceClass = Device::Class::NONE,
199 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
201 return Integration::KeyEvent( keyName,
214 Dali::Integration::Point GetPointDownInside( Vector2& pos )
216 Dali::Integration::Point point;
217 point.SetState( PointState::DOWN );
218 point.SetScreenPosition( pos );
222 Dali::Integration::Point GetPointUpInside( Vector2& pos )
224 Dali::Integration::Point point;
225 point.SetState( PointState::UP );
226 point.SetScreenPosition( pos );
230 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
232 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
234 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
236 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
238 Property::Value* valueSet = NULL;
239 if ( valueGet.first.type == Property::Key::INDEX )
241 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
245 // Get Key is a string so searching Set Map for a string key
246 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
249 if( NULL != valueSet )
251 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
253 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
256 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
258 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
261 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
263 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
266 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
268 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
271 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
273 Vector2 vector2Get = valueGet.second.Get<Vector2>();
274 Vector2 vector2Set = valueSet->Get<Vector2>();
275 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
278 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
280 Vector4 vector4Get = valueGet.second.Get<Vector4>();
281 Vector4 vector4Set = valueSet->Get<Vector4>();
282 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 );
288 if ( valueGet.first.type == Property::Key::INDEX )
290 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
294 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
304 class ScrollStateChangeCallback : public Dali::ConnectionTracker
307 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
308 : mStartedCalled( startedCalled ),
309 mFinishedCalled( finishedCalled )
313 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
315 if( type == TextEditor::Scroll::STARTED )
317 mStartedCalled = true;
319 else if( type == TextEditor::Scroll::FINISHED )
321 mFinishedCalled = true;
325 bool& mStartedCalled;
326 bool& mFinishedCalled;
331 int UtcDaliToolkitTextEditorConstructorP(void)
333 ToolkitTestApplication application;
334 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
335 TextEditor textEditor;
336 DALI_TEST_CHECK( !textEditor );
340 int UtcDaliToolkitTextEditorNewP(void)
342 ToolkitTestApplication application;
343 tet_infoline(" UtcDaliToolkitTextEditorNewP");
344 TextEditor textEditor = TextEditor::New();
345 DALI_TEST_CHECK( textEditor );
349 int UtcDaliToolkitTextEditorDownCastP(void)
351 ToolkitTestApplication application;
352 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
353 TextEditor textEditor1 = TextEditor::New();
354 BaseHandle object( textEditor1 );
356 TextEditor textEditor2 = TextEditor::DownCast( object );
357 DALI_TEST_CHECK( textEditor2 );
359 TextEditor textEditor3 = DownCast< TextEditor >( object );
360 DALI_TEST_CHECK( textEditor3 );
364 int UtcDaliToolkitTextEditorDownCastN(void)
366 ToolkitTestApplication application;
367 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
368 BaseHandle uninitializedObject;
369 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
370 DALI_TEST_CHECK( !textEditor1 );
372 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
373 DALI_TEST_CHECK( !textEditor2 );
377 int UtcDaliToolkitTextEditorCopyConstructorP(void)
379 ToolkitTestApplication application;
380 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
381 TextEditor textEditor = TextEditor::New();
382 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
384 TextEditor copy( textEditor );
385 DALI_TEST_CHECK( copy );
386 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
390 int UtcDaliTextEditorMoveConstructor(void)
392 ToolkitTestApplication application;
394 TextEditor textEditor = TextEditor::New();
395 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
396 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
398 TextEditor moved = std::move( textEditor );
399 DALI_TEST_CHECK( moved );
400 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
401 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
402 DALI_TEST_CHECK( !textEditor );
407 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
409 ToolkitTestApplication application;
410 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
411 TextEditor textEditor = TextEditor::New();
412 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
414 TextEditor copy = textEditor;
415 DALI_TEST_CHECK( copy );
416 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
420 int UtcDaliTextEditorMoveAssignment(void)
422 ToolkitTestApplication application;
424 TextEditor textEditor = TextEditor::New();
425 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
426 DALI_TEST_CHECK( textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
429 moved = std::move( textEditor );
430 DALI_TEST_CHECK( moved );
431 DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
432 DALI_TEST_CHECK( moved.GetProperty<std::string>( TextEditor::Property::TEXT ) == "Test" );
433 DALI_TEST_CHECK( !textEditor );
438 int UtcDaliTextEditorNewP(void)
440 ToolkitTestApplication application;
441 tet_infoline(" UtcDaliToolkitTextEditorNewP");
442 TextEditor textEditor = TextEditor::New();
443 DALI_TEST_CHECK( textEditor );
447 // Positive test case for a method
448 int UtcDaliTextEditorGetPropertyP(void)
450 ToolkitTestApplication application;
451 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
452 TextEditor editor = TextEditor::New();
453 DALI_TEST_CHECK( editor );
455 // Check Property Indices are correct
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextEditor::Property::FONT_SIZE_SCALE );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == DevelTextEditor::Property::MAX_LENGTH );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextEditor::Property::GRAB_HANDLE_COLOR );
519 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
522 Property::Map imageMap;
523 imageMap[mapKey] =mapValue;
525 editor.SetProperty( property , imageMap );
526 Property::Value propValue = editor.GetProperty( property );
527 Property::Map* resultMap = propValue.GetMap();
529 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
537 // Positive test case for a method
538 int UtcDaliTextEditorSetPropertyP(void)
540 ToolkitTestApplication application;
541 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
542 TextEditor editor = TextEditor::New();
543 DALI_TEST_CHECK( editor );
544 application.GetScene().Add( editor );
546 // Note - we can't check the defaults since the stylesheets are platform-specific
548 // Check the render backend property.
549 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
550 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
552 // Check text property.
553 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
554 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
556 // Check text's color property
557 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
558 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
560 // Check font properties.
561 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
562 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
564 Property::Map fontStyleMapSet;
565 Property::Map fontStyleMapGet;
566 Property::Value* slantValue = NULL;
568 fontStyleMapSet.Insert( "weight", "bold" );
569 fontStyleMapSet.Insert( "width", "condensed" );
570 fontStyleMapSet.Insert( "slant", "italic" );
572 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
573 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
574 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
575 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
577 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
578 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
580 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 2.5f );
581 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
582 editor.SetProperty( DevelTextEditor::Property::FONT_SIZE_SCALE, 1.0f );
585 fontStyleMapSet.Clear();
586 fontStyleMapSet.Insert( "weight", "normal" );
587 fontStyleMapSet.Insert( "slant", "oblique" );
588 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
589 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
590 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
591 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
593 fontStyleMapSet.Clear();
594 fontStyleMapSet.Insert( "slant", "roman" );
595 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
596 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
598 // Replace 'roman' for 'normal'.
599 slantValue = fontStyleMapGet.Find( "slant" );
600 if( NULL != slantValue )
602 if( "normal" == slantValue->Get<std::string>() )
604 fontStyleMapGet["slant"] = "roman";
607 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
608 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
610 fontStyleMapSet.Clear();
612 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
613 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
614 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
615 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
617 // Check that the Alignment properties can be correctly set
618 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
619 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
621 // Check scroll properties.
622 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
623 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
624 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
625 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
627 // Check cursor properties
628 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
629 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
630 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
631 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
633 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
634 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
635 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
636 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
637 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
638 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
639 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
640 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
642 // Check handle images
643 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
644 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
645 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
646 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
647 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
649 // Check handle images
650 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
651 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
652 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
653 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
654 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
655 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
657 // Check the highlight color
658 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
659 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
661 // Decoration bounding box
662 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
663 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
665 // Check the enable markup property.
666 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
667 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
668 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
670 // Check input color property.
671 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
672 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
674 // Check input font properties.
675 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
676 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
678 fontStyleMapSet.Clear();
679 fontStyleMapSet.Insert( "weight", "bold" );
680 fontStyleMapSet.Insert( "width", "condensed" );
681 fontStyleMapSet.Insert( "slant", "italic" );
683 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
684 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
685 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
686 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
688 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
689 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
691 // Reset input font style.
692 fontStyleMapSet.Clear();
693 fontStyleMapSet.Insert( "weight", "normal" );
694 fontStyleMapSet.Insert( "slant", "oblique" );
696 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
697 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
698 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
699 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
701 fontStyleMapSet.Clear();
702 fontStyleMapSet.Insert( "slant", "roman" );
704 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
705 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
707 // Replace 'roman' for 'normal'.
708 slantValue = fontStyleMapGet.Find( "slant" );
709 if( NULL != slantValue )
711 if( "normal" == slantValue->Get<std::string>() )
713 fontStyleMapGet["slant"] = "roman";
716 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
717 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
719 fontStyleMapSet.Clear();
721 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
722 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
723 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
724 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
726 // Check the line spacing property
727 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
728 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
729 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
731 // Check the input line spacing property
732 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
733 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
734 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736 // Check the underline property
738 Property::Map underlineMapSet;
739 Property::Map underlineMapGet;
741 underlineMapSet.Insert( "enable", true );
742 underlineMapSet.Insert( "color", Color::RED );
743 underlineMapSet.Insert( "height", 1 );
745 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
747 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
748 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
749 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
751 // Check the input underline property
752 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
753 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
755 // Check the shadow property
756 Property::Map shadowMapSet;
757 Property::Map shadowMapGet;
759 shadowMapSet.Insert( "color", Color::GREEN );
760 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
761 shadowMapSet.Insert( "blurRadius", 3.0f );
763 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
765 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
766 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
767 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
769 // Check the input shadow property
770 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
771 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
773 // Check the emboss property
774 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
775 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
777 // Check the input emboss property
778 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
779 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
781 // Check the outline property
783 // Test string type first
784 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
785 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
786 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
788 // Then test the property map type
789 Property::Map outlineMapSet;
790 Property::Map outlineMapGet;
792 outlineMapSet["color"] = Color::RED;
793 outlineMapSet["width"] = 2.0f;
795 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
797 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
798 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
799 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
801 // Check the input outline property
802 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
803 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
805 // Check the smooth scroll property
806 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
807 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
808 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
810 // Check the smooth scroll duration property
811 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
812 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
814 // Check the scroll bar property
815 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
816 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
817 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
819 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
820 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
821 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
822 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
824 // Check the pixel size of font
825 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
826 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
828 // Check placeholder text properties.
829 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
830 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
832 // Check placeholder text's color property.
833 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
834 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
836 // Check the enable selection property
837 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
838 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
840 // Check the placeholder property with pixel size
841 Property::Map placeholderPixelSizeMapSet;
842 Property::Map placeholderPixelSizeMapGet;
843 Property::Map placeholderFontstyleMap;
844 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
845 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
846 placeholderPixelSizeMapSet["color"] = Color::BLUE;
847 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
848 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
850 placeholderFontstyleMap.Insert( "weight", "bold" );
851 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
852 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
854 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
855 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
857 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
858 Property::Map placeholderConversionMap;
859 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
860 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
861 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
862 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
863 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
864 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
866 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
868 // Check the placeholder property with point size
869 Property::Map placeholderMapSet;
870 Property::Map placeholderMapGet;
871 placeholderMapSet["text"] = "Setting Placeholder Text";
872 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
873 placeholderMapSet["color"] = Color::RED;
874 placeholderMapSet["fontFamily"] = "Arial";
875 placeholderMapSet["pointSize"] = 12.0f;
876 // Check the placeholder font style property
877 placeholderFontstyleMap.Clear();
879 placeholderFontstyleMap.Insert( "weight", "bold" );
880 placeholderFontstyleMap.Insert( "width", "condensed" );
881 placeholderFontstyleMap.Insert( "slant", "italic" );
882 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
883 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
885 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
886 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
888 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
889 placeholderConversionMap.Clear();
890 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
891 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
892 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
893 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
894 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
895 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
896 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
899 placeholderFontstyleMap.Clear();
900 placeholderFontstyleMap.Insert( "weight", "normal" );
901 placeholderFontstyleMap.Insert( "slant", "oblique" );
902 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
903 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
905 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
906 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
907 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
908 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
910 placeholderFontstyleMap.Clear();
911 placeholderFontstyleMap.Insert( "slant", "roman" );
912 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
913 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
915 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
917 placeholderFontstyleMap.Clear();
918 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
920 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
921 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
922 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
923 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
924 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
926 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
927 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
929 // Check handle color
930 editor.SetProperty( DevelTextEditor::Property::GRAB_HANDLE_COLOR, Color::GREEN );
931 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
933 application.SendNotification();
934 application.Render();
939 // Positive Atlas Text Renderer test
940 int utcDaliTextEditorAtlasRenderP(void)
942 ToolkitTestApplication application;
943 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
944 StyleManager styleManager = StyleManager::Get();
945 styleManager.ApplyDefaultTheme();
946 TextEditor editor = TextEditor::New();
947 DALI_TEST_CHECK( editor );
949 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
951 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
953 application.GetScene().Add( editor );
957 // Render some text with the shared atlas backend
958 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
959 application.SendNotification();
960 application.Render();
964 tet_result(TET_FAIL);
969 // Positive test for the anchorClicked signal.
970 int utcDaliTextEditorAnchorClickedP(void)
972 ToolkitTestApplication application;
973 tet_infoline(" utcDaliTextEditorAnchorClickedP");
974 TextEditor editor = TextEditor::New();
975 DALI_TEST_CHECK(editor);
977 application.GetScene().Add(editor);
979 // connect to the anchor clicked signal.
980 ConnectionTracker* testTracker = new ConnectionTracker();
981 DevelTextEditor::AnchorClickedSignal(editor).Connect(&TestAnchorClickedCallback);
982 bool anchorClickedSignal = false;
983 editor.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
985 gAnchorClickedCallBackCalled = false;
986 editor.SetProperty(TextEditor::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
987 editor.SetProperty(TextEditor::Property::ENABLE_MARKUP, true);
988 editor.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
989 editor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
990 editor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
992 application.SendNotification();
993 application.Render();
994 editor.SetKeyInputFocus();
996 // Create a tap event to touch the text editor.
997 TestGenerateTap(application, 5.0f, 5.0f);
998 application.SendNotification();
999 application.Render();
1001 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1002 DALI_TEST_CHECK(anchorClickedSignal);
1004 gAnchorClickedCallBackNotCalled = true;
1005 // Tap the outside of anchor, callback should not be called.
1006 TestGenerateTap(application, 150.f, 100.f);
1007 application.SendNotification();
1008 application.Render();
1010 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1015 // Positive test for the textChanged signal.
1016 int utcDaliTextEditorTextChangedP(void)
1018 ToolkitTestApplication application;
1019 tet_infoline(" utcDaliTextEditorTextChangedP");
1020 TextEditor editor = TextEditor::New();
1021 DALI_TEST_CHECK( editor );
1023 application.GetScene().Add( editor );
1025 // connect to the text changed signal.
1026 ConnectionTracker* testTracker = new ConnectionTracker();
1027 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1028 bool textChangedSignal = false;
1029 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1031 gTextChangedCallBackCalled = false;
1032 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1033 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1034 DALI_TEST_CHECK( textChangedSignal );
1036 application.SendNotification();
1037 editor.SetKeyInputFocus();
1039 gTextChangedCallBackCalled = false;
1040 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1041 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1044 editor.SetProperty( TextField::Property::TEXT, "" );
1046 // Pressing backspace key: TextChangedCallback should not be called when there is no text in texteditor.
1047 gTextChangedCallBackCalled = false;
1048 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1049 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1051 // Pressing delete key: TextChangedCallback should not be called when there is no text in texteditor.
1052 gTextChangedCallBackCalled = false;
1053 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1054 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1059 int utcDaliTextEditorTextChangedWithInputMethodContext(void)
1061 ToolkitTestApplication application;
1062 tet_infoline(" utcDaliTextEditorTextChangedWithInputMethodContext");
1063 TextEditor editor = TextEditor::New();
1064 DALI_TEST_CHECK( editor );
1067 application.GetScene().Add( editor );
1069 // connect to the text changed signal.
1070 ConnectionTracker* testTracker = new ConnectionTracker();
1071 editor.TextChangedSignal().Connect(&TestTextChangedCallback);
1072 bool textChangedSignal = false;
1073 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1076 // get InputMethodContext
1078 InputMethodContext::EventData imfEvent;
1079 InputMethodContext inputMethodContext = DevelTextEditor::GetInputMethodContext( editor );
1081 editor.SetKeyInputFocus();
1082 editor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
1085 gTextChangedCallBackCalled = false;
1086 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1087 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1088 application.SendNotification();
1089 application.Render();
1090 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1091 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1093 gTextChangedCallBackCalled = false;
1094 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1095 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1096 application.SendNotification();
1097 application.Render();
1098 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1099 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호"), TEST_LOCATION );
1101 gTextChangedCallBackCalled = false;
1102 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1103 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1104 application.SendNotification();
1105 application.Render();
1106 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1107 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1109 gTextChangedCallBackCalled = false;
1110 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1111 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1112 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1114 imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1115 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1116 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1118 imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1119 inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1120 DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1122 application.SendNotification();
1123 application.Render();
1124 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1125 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1131 int utcDaliTextEditorInputStyleChanged01(void)
1133 // The text-editor emits signals when the input style changes. These changes of style are
1134 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1135 // can't be emitted during the size negotiation as the callbacks may update the UI.
1136 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1137 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1138 ToolkitTestApplication application;
1139 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1143 char* pathNamePtr = get_current_dir_name();
1144 const std::string pathName( pathNamePtr );
1145 free( pathNamePtr );
1147 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1148 fontClient.SetDpi( 93u, 93u );
1150 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1151 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1153 TextEditor editor = TextEditor::New();
1154 DALI_TEST_CHECK( editor );
1157 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1158 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1159 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1161 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1162 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1164 // connect to the text changed signal.
1165 ConnectionTracker* testTracker = new ConnectionTracker();
1166 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1167 bool inputStyleChangedSignal = false;
1168 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1170 application.GetScene().Add( editor );
1172 // Render and notify
1173 application.SendNotification();
1174 application.Render();
1176 // Executes the idle callbacks added by the text control on the change of input style.
1177 application.RunIdles();
1179 gInputStyleChangedCallbackCalled = false;
1180 gInputStyleMask = TextEditor::InputStyle::NONE;
1181 inputStyleChangedSignal = false;
1183 // Create a tap event to touch the text editor.
1184 TestGenerateTap( application, 18.0f, 25.0f );
1186 // Render and notify
1187 application.SendNotification();
1188 application.Render();
1190 // Executes the idle callbacks added by the text control on the change of input style.
1191 application.RunIdles();
1193 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1194 if( gInputStyleChangedCallbackCalled )
1196 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1198 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1199 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1201 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1202 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1204 DALI_TEST_CHECK( inputStyleChangedSignal );
1206 gInputStyleChangedCallbackCalled = false;
1207 gInputStyleMask = TextEditor::InputStyle::NONE;
1208 inputStyleChangedSignal = false;
1210 // Create a tap event to touch the text editor.
1211 TestGenerateTap( application, 30.0f, 25.0f );
1213 // Render and notify
1214 application.SendNotification();
1215 application.Render();
1217 // Executes the idle callbacks added by the text control on the change of input style.
1218 application.RunIdles();
1220 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1221 DALI_TEST_CHECK( !inputStyleChangedSignal );
1223 gInputStyleChangedCallbackCalled = false;
1224 gInputStyleMask = TextEditor::InputStyle::NONE;
1225 inputStyleChangedSignal = false;
1227 // Create a tap event to touch the text editor.
1228 TestGenerateTap( application, 43.0f, 25.0f );
1230 // Render and notify
1231 application.SendNotification();
1232 application.Render();
1234 // Executes the idle callbacks added by the text control on the change of input style.
1235 application.RunIdles();
1237 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1238 if( gInputStyleChangedCallbackCalled )
1240 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1242 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1243 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1245 DALI_TEST_CHECK( inputStyleChangedSignal );
1247 gInputStyleChangedCallbackCalled = false;
1248 gInputStyleMask = TextEditor::InputStyle::NONE;
1249 inputStyleChangedSignal = false;
1251 // Create a tap event to touch the text editor.
1252 TestGenerateTap( application, 88.0f, 25.0f );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Executes the idle callbacks added by the text control on the change of input style.
1259 application.RunIdles();
1261 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1262 if( gInputStyleChangedCallbackCalled )
1264 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1266 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1267 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1269 Property::Map fontStyleMapSet;
1270 Property::Map fontStyleMapGet;
1272 fontStyleMapSet.Insert( "weight", "bold" );
1274 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1275 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1276 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1278 DALI_TEST_CHECK( inputStyleChangedSignal );
1280 gInputStyleChangedCallbackCalled = false;
1281 gInputStyleMask = TextEditor::InputStyle::NONE;
1282 inputStyleChangedSignal = false;
1284 // Create a tap event to touch the text editor.
1285 TestGenerateTap( application, 115.0f, 25.0f );
1287 // Render and notify
1288 application.SendNotification();
1289 application.Render();
1291 // Executes the idle callbacks added by the text control on the change of input style.
1292 application.RunIdles();
1294 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1295 DALI_TEST_CHECK( !inputStyleChangedSignal );
1297 gInputStyleChangedCallbackCalled = false;
1298 gInputStyleMask = TextEditor::InputStyle::NONE;
1299 inputStyleChangedSignal = false;
1301 // Create a tap event to touch the text editor.
1302 TestGenerateTap( application, 164.0f, 25.0f );
1304 // Render and notify
1305 application.SendNotification();
1306 application.Render();
1308 // Executes the idle callbacks added by the text control on the change of input style.
1309 application.RunIdles();
1311 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1312 if( gInputStyleChangedCallbackCalled )
1314 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1316 Property::Map fontStyleMapSet;
1317 Property::Map fontStyleMapGet;
1319 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1320 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1321 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1323 DALI_TEST_CHECK( inputStyleChangedSignal );
1325 gInputStyleChangedCallbackCalled = false;
1326 gInputStyleMask = TextEditor::InputStyle::NONE;
1327 inputStyleChangedSignal = false;
1329 // Create a tap event to touch the text editor.
1330 TestGenerateTap( application, 191.0f, 25.0f );
1332 // Render and notify
1333 application.SendNotification();
1334 application.Render();
1336 // Executes the idle callbacks added by the text control on the change of input style.
1337 application.RunIdles();
1339 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1340 DALI_TEST_CHECK( !inputStyleChangedSignal );
1345 int utcDaliTextEditorInputStyleChanged02(void)
1347 // The text-editor emits signals when the input style changes. These changes of style are
1348 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1349 // can't be emitted during the size negotiation as the callbacks may update the UI.
1350 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1351 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1352 ToolkitTestApplication application;
1353 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1357 char* pathNamePtr = get_current_dir_name();
1358 const std::string pathName( pathNamePtr );
1359 free( pathNamePtr );
1361 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1362 fontClient.SetDpi( 93u, 93u );
1364 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1365 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1367 TextEditor editor = TextEditor::New();
1368 DALI_TEST_CHECK( editor );
1371 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1372 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1373 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1375 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1376 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>" );
1378 // connect to the text changed signal.
1379 ConnectionTracker* testTracker = new ConnectionTracker();
1380 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1381 bool inputStyleChangedSignal = false;
1382 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1384 application.GetScene().Add( editor );
1386 // Render and notify
1387 application.SendNotification();
1388 application.Render();
1390 // Executes the idle callbacks added by the text control on the change of input style.
1391 application.RunIdles();
1393 gInputStyleChangedCallbackCalled = false;
1394 gInputStyleMask = TextEditor::InputStyle::NONE;
1395 inputStyleChangedSignal = false;
1397 // Create a tap event to touch the text editor.
1398 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1399 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1401 // Render and notify
1402 application.SendNotification();
1403 application.Render();
1405 // Executes the idle callbacks added by the text control on the change of input style.
1406 application.RunIdles();
1408 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1409 if( gInputStyleChangedCallbackCalled )
1411 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1412 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1413 TextEditor::InputStyle::POINT_SIZE |
1414 TextEditor::InputStyle::COLOR ),
1417 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1418 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1420 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1421 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1423 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1424 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1426 DALI_TEST_CHECK( inputStyleChangedSignal );
1428 gInputStyleChangedCallbackCalled = false;
1429 gInputStyleMask = TextEditor::InputStyle::NONE;
1430 inputStyleChangedSignal = false;
1432 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1434 // Render and notify
1435 application.SendNotification();
1436 application.Render();
1438 // Executes the idle callbacks added by the text control on the change of input style.
1439 application.RunIdles();
1441 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1442 if( gInputStyleChangedCallbackCalled )
1444 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1445 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1448 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1449 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1451 DALI_TEST_CHECK( inputStyleChangedSignal );
1453 gInputStyleChangedCallbackCalled = false;
1454 gInputStyleMask = TextEditor::InputStyle::NONE;
1455 inputStyleChangedSignal = false;
1457 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1459 // Render and notify
1460 application.SendNotification();
1461 application.Render();
1463 // Executes the idle callbacks added by the text control on the change of input style.
1464 application.RunIdles();
1466 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1467 DALI_TEST_CHECK( !inputStyleChangedSignal );
1469 gInputStyleChangedCallbackCalled = false;
1470 gInputStyleMask = TextEditor::InputStyle::NONE;
1471 inputStyleChangedSignal = false;
1473 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1475 // Render and notify
1476 application.SendNotification();
1477 application.Render();
1479 // Executes the idle callbacks added by the text control on the change of input style.
1480 application.RunIdles();
1482 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1483 if( gInputStyleChangedCallbackCalled )
1485 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1486 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1489 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1490 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1492 DALI_TEST_CHECK( inputStyleChangedSignal );
1494 gInputStyleChangedCallbackCalled = false;
1495 gInputStyleMask = TextEditor::InputStyle::NONE;
1496 inputStyleChangedSignal = false;
1498 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1500 Property::Map fontStyleMapSet;
1501 fontStyleMapSet.Insert( "weight", "thin" );
1502 fontStyleMapSet.Insert( "width", "condensed" );
1503 fontStyleMapSet.Insert( "slant", "italic" );
1505 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1506 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1507 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1509 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1510 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1511 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1512 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1514 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 // Executes the idle callbacks added by the text control on the change of input style.
1521 application.RunIdles();
1523 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1524 DALI_TEST_CHECK( !inputStyleChangedSignal );
1526 // Create a tap event to touch the text editor.
1527 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1529 // Render and notify
1530 application.SendNotification();
1531 application.Render();
1533 // Executes the idle callbacks added by the text control on the change of input style.
1534 application.RunIdles();
1536 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1537 if( gInputStyleChangedCallbackCalled )
1539 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1540 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1541 TextEditor::InputStyle::POINT_SIZE |
1542 TextEditor::InputStyle::FONT_STYLE |
1543 TextEditor::InputStyle::LINE_SPACING |
1544 TextEditor::InputStyle::UNDERLINE |
1545 TextEditor::InputStyle::SHADOW |
1546 TextEditor::InputStyle::EMBOSS |
1547 TextEditor::InputStyle::OUTLINE ),
1550 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1551 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1553 DALI_TEST_CHECK( inputStyleChangedSignal );
1555 gInputStyleChangedCallbackCalled = false;
1556 gInputStyleMask = TextEditor::InputStyle::NONE;
1557 inputStyleChangedSignal = false;
1559 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1561 fontStyleMapSet.Clear();
1562 fontStyleMapSet.Insert( "weight", "black" );
1563 fontStyleMapSet.Insert( "width", "expanded" );
1564 fontStyleMapSet.Insert( "slant", "oblique" );
1566 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1568 // Create a tap event to touch the text editor.
1569 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 // Executes the idle callbacks added by the text control on the change of input style.
1576 application.RunIdles();
1578 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1579 if( gInputStyleChangedCallbackCalled )
1581 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1582 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1583 TextEditor::InputStyle::POINT_SIZE |
1584 TextEditor::InputStyle::FONT_STYLE ),
1587 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1588 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1590 DALI_TEST_CHECK( inputStyleChangedSignal );
1595 int utcDaliTextEditorEvent01(void)
1597 ToolkitTestApplication application;
1598 tet_infoline(" utcDaliTextEditorEvent01");
1600 // Creates a tap event. After creating a tap event the text editor should
1601 // have the focus and add text with key events should be possible.
1603 TextEditor editor = TextEditor::New();
1604 DALI_TEST_CHECK( editor );
1606 application.GetScene().Add( editor );
1608 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1609 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1610 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1612 // Avoid a crash when core load gl resources.
1613 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1615 // Render and notify
1616 application.SendNotification();
1617 application.Render();
1619 // Add a key event but as the text editor has not the focus it should do nothing.
1620 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1622 // Render and notify
1623 application.SendNotification();
1624 application.Render();
1626 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1628 // Create a tap event to touch the text editor.
1629 TestGenerateTap( application, 150.0f, 25.0f );
1631 // Render and notify
1632 application.SendNotification();
1633 application.Render();
1635 // Now the text editor has the focus, so it can handle the key events.
1636 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1637 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1645 // Create a second text editor and send key events to it.
1646 TextEditor editor2 = TextEditor::New();
1648 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1649 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1650 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1651 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1653 application.GetScene().Add( editor2 );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 // Create a tap event on the second text editor.
1660 TestGenerateTap( application, 150.0f, 125.0f );
1662 // Render and notify
1663 application.SendNotification();
1664 application.Render();
1666 // The second text editor has the focus. It should handle the key events.
1667 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1668 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 // Check the text has been added to the second text editor.
1675 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1680 int utcDaliTextEditorEvent02(void)
1682 ToolkitTestApplication application;
1683 tet_infoline(" utcDaliTextEditorEvent02");
1685 // Checks if the right number of actors are created.
1687 TextEditor editor = TextEditor::New();
1688 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1689 DALI_TEST_CHECK( editor );
1691 application.GetScene().Add( editor );
1693 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1694 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1695 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1697 // Avoid a crash when core load gl resources.
1698 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1700 // Render and notify
1701 application.SendNotification();
1702 application.Render();
1704 // Check there are the expected number of children (the stencil).
1705 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1707 Actor stencil = editor.GetChildAt( 0u );
1709 // Create a tap event to touch the text editor.
1710 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1712 // Render and notify
1713 application.SendNotification();
1714 application.Render();
1716 Actor layer = editor.GetChildAt( 1u );
1717 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1718 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1720 // Now the text editor has the focus, so it can handle the key events.
1721 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1722 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1724 // Render and notify
1725 application.SendNotification();
1726 application.Render();
1728 // Checks the cursor and the renderer have been created.
1729 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1730 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1732 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1733 DALI_TEST_CHECK( cursor );
1735 // The stencil actor has a container with all the actors which contain the text renderers.
1736 Actor container = stencil.GetChildAt( 0u );
1737 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1739 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1740 DALI_TEST_CHECK( renderer );
1743 // Move the cursor and check the position changes.
1744 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1746 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1747 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1749 // Render and notify
1750 application.SendNotification();
1751 application.Render();
1753 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1755 DALI_TEST_CHECK( position2.x < position1.x );
1757 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1758 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1760 // Render and notify
1761 application.SendNotification();
1762 application.Render();
1764 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1766 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1768 // Send some taps and check the cursor positions.
1770 // Try to tap at the beginning.
1771 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1773 // Render and notify
1774 application.SendNotification();
1775 application.Render();
1777 // Cursor position should be the same than position1.
1778 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1780 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1782 // Tap away from the start position.
1783 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1789 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1791 DALI_TEST_CHECK( position5.x > position4.x );
1793 // Remove all the text.
1794 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1795 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1796 editor.SetProperty( TextEditor::Property::TEXT, "" );
1798 // Render and notify
1799 application.SendNotification();
1800 application.Render();
1802 // Cursor position should be the same than position2.
1803 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1805 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1807 // Should not be a renderer.
1808 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1813 int utcDaliTextEditorEvent03(void)
1815 ToolkitTestApplication application;
1816 tet_infoline(" utcDaliTextEditorEvent03");
1818 // Checks if the highlight actor is created.
1820 TextEditor editor = TextEditor::New();
1821 DALI_TEST_CHECK( editor );
1823 application.GetScene().Add( editor );
1825 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1826 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1827 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1828 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1829 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1831 // Avoid a crash when core load gl resources.
1832 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1834 // Render and notify
1835 application.SendNotification();
1836 application.Render();
1838 // Send some taps and check text controller with clipboard window
1839 Dali::Clipboard clipboard = Clipboard::Get();
1840 clipboard.ShowClipboard();
1841 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1842 clipboard.HideClipboard();
1844 // Render and notify
1845 application.SendNotification();
1846 application.Render();
1848 // Tap first to get the focus.
1849 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1855 // Double tap to select a word.
1856 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1862 // The stencil actor should have two actors: the renderer and the highlight actor.
1863 Actor stencil = editor.GetChildAt( 0u );
1865 // Highlight needs to be drawn before text, so should come first in child order
1866 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1867 DALI_TEST_CHECK( highlight );
1869 // The stencil actor has a container with all the actors which contain the text renderers.
1870 Actor container = stencil.GetChildAt( 1u );
1871 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1873 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1874 DALI_TEST_CHECK( renderer );
1877 // Double tap out of bounds
1878 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1879 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 // The stencil actor should have one actors: the renderer actor.
1886 stencil = editor.GetChildAt( 0u );
1888 // The stencil actor has a container with all the actors which contain the text renderers.
1889 container = stencil.GetChildAt( 0u );
1890 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1892 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1893 DALI_TEST_CHECK( renderer );
1897 TestGenerateLongPress(application, 1.0f, 25.0f);
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1904 TestGenerateMiniPan(application);
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1913 int utcDaliTextEditorEvent04(void)
1915 ToolkitTestApplication application;
1916 tet_infoline(" utcDaliTextEditorEvent04");
1918 // Checks if the highlight actor is created.
1920 TextEditor editor = TextEditor::New();
1921 DALI_TEST_CHECK( editor );
1923 application.GetScene().Add( editor );
1925 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1926 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1927 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1928 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1929 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1931 // Avoid a crash when core load gl resources.
1932 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1938 // Tap on the text editor
1939 TestGenerateTap( application, 3.0f, 25.0f );
1941 // Render and notify
1942 application.SendNotification();
1943 application.Render();
1945 // Move at the end of the text.
1946 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1947 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1949 // Render and notify
1950 application.SendNotification();
1951 application.Render();
1953 for( unsigned int index = 0u; index < 10u; ++index )
1955 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1956 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1958 // Render and notify
1959 application.SendNotification();
1960 application.Render();
1964 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1966 // Render and notify
1967 application.SendNotification();
1968 application.Render();
1970 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1972 // Add some key events
1973 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1974 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1976 // Render and notify
1977 application.SendNotification();
1978 application.Render();
1980 for( unsigned int index = 0u; index < 10u; ++index )
1982 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1983 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1991 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2002 int utcDaliTextEditorEvent05(void)
2004 ToolkitTestApplication application;
2005 tet_infoline(" utcDaliTextEditorEvent05");
2007 // Checks if the highlight actor is created.
2009 TextEditor editor = TextEditor::New();
2010 DALI_TEST_CHECK( editor );
2012 application.GetScene().Add( editor );
2014 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
2015 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2016 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2017 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2018 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2019 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2020 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
2021 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2022 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
2023 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
2025 // Avoid a crash when core load gl resources.
2026 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2028 // Render and notify
2029 application.SendNotification();
2030 application.Render();
2032 // Tap on the text editor
2033 TestGenerateTap( application, 3.0f, 25.0f );
2035 // Render and notify
2036 application.SendNotification();
2037 application.Render();
2039 // Move at the end of the text.
2040 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2041 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2043 // Render and notify
2044 application.SendNotification();
2045 application.Render();
2047 for( unsigned int index = 0u; index < 10u; ++index )
2050 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2052 // Render and notify
2053 application.SendNotification();
2054 application.Render();
2056 // Modify duration after scroll is enabled
2057 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
2059 // Continuous scroll left to increase coverage
2060 for( unsigned int index = 0u; index < 10u; ++index )
2062 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2064 // Render and notify
2065 application.SendNotification();
2066 application.Render();
2068 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2069 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
2070 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
2071 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2072 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2074 // Press Escape to increase coverage
2075 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2076 application.SendNotification();
2077 application.Render();
2079 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2084 int utcDaliTextEditorEvent06(void)
2086 ToolkitTestApplication application;
2087 tet_infoline(" utcDaliTextEditorEvent06");
2089 // Checks if the highlight actor is created.
2091 TextEditor editor = TextEditor::New();
2092 DALI_TEST_CHECK( editor );
2094 application.GetScene().Add( editor );
2096 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2097 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2098 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2099 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2100 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2102 // Avoid a crash when core load gl resources.
2103 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2105 // Render and notify
2106 application.SendNotification();
2107 application.Render();
2109 // Tap on the text editor
2110 TestGenerateTap( application, 3.0f, 25.0f );
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2116 // Move to seconds line of the text.
2117 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2119 // Render and notify
2120 application.SendNotification();
2121 application.Render();
2123 float layoutHeight = editor.GetHeightForWidth( 100.f );
2126 // Add another script characters ( glyph height is defferent )
2127 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2130 // Delete characters
2131 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2132 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2143 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2144 application.SendNotification();
2145 application.Render();
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.SendNotification();
2149 application.Render();
2151 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2152 application.SendNotification();
2153 application.Render();
2155 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 application.SendNotification();
2157 application.Render();
2159 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 application.SendNotification();
2161 application.Render();
2163 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 application.SendNotification();
2165 application.Render();
2167 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 application.SendNotification();
2169 application.Render();
2174 int utcDaliTextEditorEvent07(void)
2176 ToolkitTestApplication application;
2177 tet_infoline(" utcDaliTextEditorEvent07");
2179 // Checks if the highlight actor is created.
2181 TextEditor editor = TextEditor::New();
2182 DALI_TEST_CHECK( editor );
2184 application.GetScene().Add( editor );
2186 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2187 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2188 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2189 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2190 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2192 // Avoid a crash when core load gl resources.
2193 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2195 // Render and notify
2196 application.SendNotification();
2197 application.Render();
2199 // Tap on the text editor
2200 TestGenerateTap( application, 3.0f, 25.0f );
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2206 // Move to second line of the text.
2207 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 // Render and notify
2210 application.SendNotification();
2211 application.Render();
2213 // Select some text in the right of the current cursor position
2214 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2216 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 // Cut the selected text
2224 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2225 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 // Render and notify
2228 application.SendNotification();
2229 application.Render();
2231 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2233 // Select some text in the left of the current cursor position
2234 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2235 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 // Render and notify
2240 application.SendNotification();
2241 application.Render();
2243 // Copy the selected text
2244 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2245 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 ) );
2247 // Render and notify
2248 application.SendNotification();
2249 application.Render();
2251 // Move the cursor to the third line
2252 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2253 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 // Render and notify
2256 application.SendNotification();
2257 application.Render();
2259 // Paste the selected text at the current cursor position
2260 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2261 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 ) );
2263 // Render and notify
2264 application.SendNotification();
2265 application.Render();
2267 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2270 // Disable Shift Selection
2271 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2273 // Test to select some text in the right of the current cursor position
2274 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 // Render and notify
2280 application.SendNotification();
2281 application.Render();
2283 // Cut the selected text
2284 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2285 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2287 // Render and notify
2288 application.SendNotification();
2289 application.Render();
2291 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2292 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2294 // Test to select some text in the left of the current cursor position
2295 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2296 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2300 // Render and notify
2301 application.SendNotification();
2302 application.Render();
2304 // Copy the selected text
2305 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 // Render and notify
2309 application.SendNotification();
2310 application.Render();
2312 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2313 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2316 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 ) );
2318 // Render and notify
2319 application.SendNotification();
2320 application.Render();
2322 // replace text with "c"
2323 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 // Render and notify
2326 application.SendNotification();
2327 application.Render();
2330 DALI_TEST_EQUALS( "c", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2333 DevelTextEditor::SelectWholeText(editor);
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2339 // Copy the selected text using logical keys
2340 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2341 application.ProcessEvent( GenerateKey( "ؤ", "c", "ؤ", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2343 // Render and notify
2344 application.SendNotification();
2345 application.Render();
2348 DevelTextEditor::SelectNone(editor);
2350 // Render and notify
2351 application.SendNotification();
2352 application.Render();
2354 // Paste the selected using logical keys
2355 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2356 application.ProcessEvent( GenerateKey( "ر", "v", "ر", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2359 DALI_TEST_EQUALS( "cc", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2361 // select all using logical keys
2362 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2363 application.ProcessEvent( GenerateKey( "ش", "a", "ش", KEY_A_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2365 // Render and notify
2366 application.SendNotification();
2367 application.Render();
2369 // cut text using logical keys
2370 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371 application.ProcessEvent( GenerateKey( "ء", "x", "ء", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2378 DALI_TEST_EQUALS( "", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2383 int utcDaliTextEditorEvent08(void)
2385 ToolkitTestApplication application;
2386 tet_infoline(" utcDaliTextEditorEvent08");
2388 // Checks if the highlight actor is released correctly.
2390 TextEditor editor = TextEditor::New();
2391 DALI_TEST_CHECK( editor );
2393 application.GetScene().Add( editor );
2395 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2396 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2397 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2398 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2399 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2401 // Avoid a crash when core load gl resources.
2402 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // Tap on the text editor
2409 TestGenerateTap( application, 3.0f, 25.0f );
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2415 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2416 // Test to select some text in the left of the current cursor position
2417 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2420 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2422 // Render and notify
2423 application.SendNotification();
2424 application.Render();
2426 // Test to the left selection handle position and the right selection handle position
2427 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2428 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2429 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2430 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2432 // Render and notify
2433 application.SendNotification();
2434 application.Render();
2436 // Test to select full text in the left of the current cursor position
2437 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2438 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2439 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2440 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2441 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2442 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2444 // Render and notify
2445 application.SendNotification();
2446 application.Render();
2448 // Test to release the current full text selection
2449 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2450 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2452 // Render and notify
2453 application.SendNotification();
2454 application.Render();
2456 // Test to move the current cursor position correctly
2457 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2464 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2466 // Render and notify
2467 application.SendNotification();
2468 application.Render();
2470 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2472 // Test to select some text in the right of the current cursor position
2473 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2474 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2475 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2477 // Render and notify
2478 application.SendNotification();
2479 application.Render();
2481 // Test the cursor position with right arrow key
2482 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2484 // Render and notify
2485 application.SendNotification();
2486 application.Render();
2489 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2491 // Render and notify
2492 application.SendNotification();
2493 application.Render();
2495 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2497 // Test to select some text in the left of the current cursor position
2498 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2499 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2500 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2501 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2502 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2504 // Render and notify
2505 application.SendNotification();
2506 application.Render();
2508 // Test the cursor position with left arrow key
2509 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2511 // Render and notify
2512 application.SendNotification();
2513 application.Render();
2516 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2518 // Render and notify
2519 application.SendNotification();
2520 application.Render();
2522 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2524 // Test to select some text in the right of the current cursor position
2525 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2526 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2527 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2528 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Test the cursor position with left arrow key
2535 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2537 // Render and notify
2538 application.SendNotification();
2539 application.Render();
2542 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::DOWN, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2544 // Render and notify
2545 application.SendNotification();
2546 application.Render();
2548 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2550 // Test to select some text in the left of the current cursor position
2551 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2552 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2553 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2554 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2556 // Render and notify
2557 application.SendNotification();
2558 application.Render();
2560 // Test the cursor position with right arrow key
2561 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2563 // Render and notify
2564 application.SendNotification();
2565 application.Render();
2568 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::DOWN, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2570 // Render and notify
2571 application.SendNotification();
2572 application.Render();
2574 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2579 int utcDaliTextEditorHandles(void)
2581 ToolkitTestApplication application;
2582 tet_infoline(" utcDaliTextEditorHandles");
2584 TextEditor editor = TextEditor::New();
2585 DALI_TEST_CHECK( editor );
2587 application.GetScene().Add( editor );
2589 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2590 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2591 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2592 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2594 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2595 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_LEFT_SELECTION_FILE_NAME } } );
2596 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2597 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, Property::Map{ {"filename", HANDLE_RIGHT_SELECTION_FILE_NAME } } );
2599 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2600 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2601 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2603 // Avoid a crash when core load gl resources.
2604 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2606 // Render and notify
2607 application.SendNotification();
2608 application.Render();
2610 // Tap first to get the focus.
2611 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2613 // Render and notify
2614 application.SendNotification();
2615 application.Render();
2617 // Tap to create the grab handle.
2618 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2620 // Render and notify
2621 application.SendNotification();
2622 application.Render();
2624 // Get the active layer where the text's decoration is added.
2625 Actor activeLayer = editor.GetChildAt( 1u );
2627 // Get the handle's actor.
2628 Actor handle = activeLayer.GetChildAt( 1u );
2629 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2631 // Render and notify
2632 application.SendNotification();
2633 application.Render();
2635 // Touch the grab handle to set it as pressed.
2636 Vector2 touchPos( 10.0f, 50.0f );
2637 Dali::Integration::TouchEvent event;
2638 event = Dali::Integration::TouchEvent();
2639 event.AddPoint( GetPointDownInside( touchPos ) );
2640 application.ProcessEvent( event );
2642 // Render and notify
2643 application.SendNotification();
2644 application.Render();
2646 // Pan the grab handle
2647 uint32_t time = 100;
2648 TestStartPan( application, Vector2(10.0f, 50.0f), Vector2(10.0f, 50.0f), time );
2649 TestMovePan( application, Vector2(10.0f, 30.0f), time );
2650 TestEndPan( application, Vector2(10.0f, 50.0f), time);
2651 application.SendNotification();
2652 application.Render();
2655 // Release the grab handle.
2656 event = Dali::Integration::TouchEvent();
2657 event.AddPoint( GetPointUpInside( touchPos ) );
2658 application.ProcessEvent( event );
2660 // Render and notify
2661 application.SendNotification();
2662 application.Render();
2664 // Tap first to get the focus.
2665 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2667 // Render and notify
2668 application.SendNotification();
2669 application.Render();
2671 // Double tap to select a word and create the selection handles.
2672 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2674 // Render and notify
2675 application.SendNotification();
2676 application.Render();
2678 touchPos = Vector2( 10.0f, 50.0f );
2680 // Touch the left selection handle to set it as pressed.
2681 event = Dali::Integration::TouchEvent();
2682 event.AddPoint( GetPointDownInside( touchPos ) );
2683 application.ProcessEvent( event );
2685 // Render and notify
2686 application.SendNotification();
2687 application.Render();
2689 // Release the left selection handle.
2690 event = Dali::Integration::TouchEvent();
2691 event.AddPoint( GetPointUpInside( touchPos ) );
2692 application.ProcessEvent( event );
2694 // Render and notify
2695 application.SendNotification();
2696 application.Render();
2701 int utcDaliTextEditorUnderPropertyStringP(void)
2703 ToolkitTestApplication application;
2704 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2705 TextEditor editor = TextEditor::New();
2706 DALI_TEST_CHECK( editor );
2708 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2710 application.GetScene().Add( editor );
2712 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2713 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2715 tet_infoline("Set underline settings with a map");
2716 // Check the input underline property
2717 Property::Map underlineMapSet;
2718 Property::Map underlineMapGet;
2719 underlineMapSet.Insert( "enable", true );
2720 underlineMapSet.Insert( "color", Color::BLUE );
2721 underlineMapSet.Insert( "height", 2 );
2723 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2724 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2725 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2726 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2728 tet_infoline("Set underline settings with a string");
2729 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2730 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2733 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2735 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2736 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2737 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2738 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2740 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2745 int utcDaliTextEditorShadowPropertyStringP(void)
2747 ToolkitTestApplication application;
2748 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2750 TextEditor editor = TextEditor::New();
2752 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2754 application.GetScene().Add( editor );
2756 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2758 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2762 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2767 int utcDaliTextEditorFontStylePropertyStringP(void)
2769 ToolkitTestApplication application;
2770 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2772 TextEditor editor = TextEditor::New();
2774 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2776 application.GetScene().Add( editor );
2778 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2780 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2784 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2789 int utcDaliTextEditorGetPropertyLinecountP(void)
2791 ToolkitTestApplication application;
2793 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2797 TextEditor editor = TextEditor::New();
2798 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2799 editor.SetProperty( TextEditor::Property::TEXT,
2800 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2802 application.GetScene().Add( editor );
2804 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2805 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2806 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2808 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2809 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2810 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2815 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2818 ToolkitTestApplication application;
2819 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2821 TextEditor editor = TextEditor::New();
2822 DALI_TEST_CHECK( editor );
2824 application.GetScene().Add( editor );
2826 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2827 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2828 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2829 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2830 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2831 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2833 bool startedCalled = false;
2834 bool finishedCalled = false;
2836 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2837 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2839 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2841 // Render and notify
2842 application.SendNotification();
2843 application.Render();
2845 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2846 application.SendNotification();
2847 application.Render(6000);
2849 application.SendNotification();
2850 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2851 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2856 int UtcDaliToolkitTextEditorTextWrapMode(void)
2858 ToolkitTestApplication application;
2859 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2863 TextEditor editor = TextEditor::New();
2864 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2865 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2867 application.GetScene().Add( editor );
2869 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2870 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2872 application.SendNotification();
2873 application.Render();
2875 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2876 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2878 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2879 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2881 application.SendNotification();
2882 application.Render();
2884 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2885 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2887 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2888 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2890 application.SendNotification();
2891 application.Render();
2893 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2894 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2896 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2897 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2899 application.SendNotification();
2900 application.Render();
2902 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2903 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2908 int UtcDaliTextEditorSetPaddingProperty(void)
2910 ToolkitTestApplication application;
2911 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2913 TextEditor editor = TextEditor::New();
2914 DALI_TEST_CHECK( editor );
2915 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2916 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2917 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2918 application.GetScene().Add( editor );
2920 application.SendNotification();
2921 application.Render();
2923 Vector3 originalSize = editor.GetNaturalSize();
2925 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2927 application.SendNotification();
2928 application.Render();
2930 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2932 Vector3 paddingAddedSize = editor.GetNaturalSize();
2934 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2936 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2941 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2943 ToolkitTestApplication application;
2944 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2946 TextEditor editor = TextEditor::New();
2947 DALI_TEST_CHECK( editor );
2948 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2949 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2950 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2951 application.GetScene().Add( editor );
2953 application.SendNotification();
2954 application.Render();
2956 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2957 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2959 // Check the enable shift selection property
2960 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2961 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2963 application.SendNotification();
2964 application.Render();
2969 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2971 ToolkitTestApplication application;
2972 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2974 TextEditor editor = TextEditor::New();
2975 DALI_TEST_CHECK( editor );
2976 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2977 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2978 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2979 application.GetScene().Add( editor );
2981 application.SendNotification();
2982 application.Render();
2984 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2985 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2987 // Check the enable grab handle property
2988 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2989 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2991 application.SendNotification();
2992 application.Render();
2997 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2999 ToolkitTestApplication application;
3000 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
3002 TextEditor editor = TextEditor::New();
3003 DALI_TEST_CHECK( editor );
3004 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3005 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3006 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3007 application.GetScene().Add( editor );
3009 application.SendNotification();
3010 application.Render();
3012 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
3013 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3015 // Check the enable match system language direction property
3016 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3017 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3019 application.SendNotification();
3020 application.Render();
3025 int UtcDaliTextEditorGetInputMethodContext(void)
3027 ToolkitTestApplication application;
3028 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
3030 TextEditor editor = TextEditor::New();
3031 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );
3036 int utcDaliTextEditorMaxCharactersReached(void)
3038 ToolkitTestApplication application;
3039 tet_infoline("utcDaliTextEditorMaxCharactersReached");
3041 TextEditor editor = TextEditor::New();
3042 DALI_TEST_CHECK( editor );
3044 application.GetScene().Add( editor );
3046 const int maxNumberOfCharacters = 1;
3047 editor.SetProperty( DevelTextEditor::Property::MAX_LENGTH, maxNumberOfCharacters );
3048 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelTextEditor::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
3050 editor.SetKeyInputFocus();
3052 // connect to the text changed signal.
3053 ConnectionTracker* testTracker = new ConnectionTracker();
3054 DevelTextEditor::MaxLengthReachedSignal( editor ).Connect(&TestMaxLengthReachedCallback);
3055 bool maxLengthReachedSignal = false;
3056 editor.ConnectSignal( testTracker, "maxLengthReached", CallbackFunctor(&maxLengthReachedSignal) );
3058 gMaxCharactersCallBackCalled = false;
3060 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3061 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3063 DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
3064 DALI_TEST_CHECK( maxLengthReachedSignal );
3069 int UtcDaliTextEditorSelectWholeText(void)
3071 ToolkitTestApplication application;
3072 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3074 TextEditor textEditor = TextEditor::New();
3076 application.GetScene().Add( textEditor );
3078 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3079 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3080 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3082 // Avoid a crash when core load gl resources.
3083 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3085 application.SendNotification();
3086 application.Render();
3088 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3090 DevelTextEditor::SelectWholeText( textEditor );
3092 application.SendNotification();
3093 application.Render();
3095 // Nothing should have been selected. The number of children is still 1
3096 DALI_TEST_EQUALS( 1u, textEditor.GetChildCount(), TEST_LOCATION );
3098 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3100 application.SendNotification();
3101 application.Render();
3103 DevelTextEditor::SelectWholeText( textEditor );
3105 application.SendNotification();
3106 application.Render();
3108 // Should be 2 children, the stencil and the layer
3109 DALI_TEST_EQUALS( 2u, textEditor.GetChildCount(), TEST_LOCATION );
3111 // The offscreen root actor should have two actors: the renderer and the highlight actor.
3112 Actor stencil = textEditor.GetChildAt( 0u );
3114 // The highlight actor is drawn first, so is the first actor in the list
3115 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3116 DALI_TEST_CHECK( highlight );
3121 int UtcDaliTextEditorSelectNone(void)
3123 ToolkitTestApplication application;
3124 tet_infoline(" UtcDaliTextEditorSelectWholeText ");
3126 TextEditor textEditor = TextEditor::New();
3128 application.GetScene().Add( textEditor );
3130 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3131 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3132 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3134 // Avoid a crash when core load gl resources.
3135 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3137 application.SendNotification();
3138 application.Render();
3140 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3142 application.SendNotification();
3143 application.Render();
3145 // Nothing is selected
3146 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3147 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3149 DevelTextEditor::SelectWholeText( textEditor );
3151 application.SendNotification();
3152 application.Render();
3154 // whole text is selected
3155 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3156 DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3158 DevelTextEditor::SelectNone( textEditor );
3160 application.SendNotification();
3161 application.Render();
3163 // Nothing is selected
3164 selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3165 DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3170 int UtcDaliTextEditorSelectRange(void)
3172 ToolkitTestApplication application;
3173 tet_infoline("utcDaliTextEditorSelectRange");
3175 TextEditor textEditor = TextEditor::New();
3176 DALI_TEST_CHECK( textEditor );
3178 application.GetScene().Add( textEditor );
3180 // Avoid a crash when core load gl resources.
3181 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3183 application.SendNotification();
3184 application.Render();
3186 textEditor.SetProperty( TextEditor::Property::TEXT, "Hello world" );
3188 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_START, 0 );
3189 textEditor.SetProperty( DevelTextEditor::Property::SELECTED_TEXT_END, 5 );
3191 // Hello is selected
3192 std::string selectedText = textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT ).Get<std::string>();
3193 DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3195 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3196 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3201 int UtcDaliTextEditorEnableEditing(void)
3203 ToolkitTestApplication application;
3204 tet_infoline(" UtcDaliTextEditorEnableEditing ");
3206 TextEditor textEditor = TextEditor::New();
3208 application.GetScene().Add( textEditor );
3210 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3211 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3212 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3214 // Avoid a crash when core load gl resources.
3215 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3217 application.SendNotification();
3218 application.Render();
3220 textEditor.SetKeyInputFocus();
3221 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, false );
3222 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3224 // Render and notify
3225 application.SendNotification();
3226 application.Render();
3228 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3229 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3231 textEditor.SetKeyInputFocus();
3232 textEditor.SetProperty( DevelTextEditor::Property::ENABLE_EDITING, true );
3233 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3235 // Render and notify
3236 application.SendNotification();
3237 application.Render();
3239 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3240 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3245 int UtcDaliTextEditorScrolling(void)
3247 ToolkitTestApplication application;
3248 tet_infoline(" UtcDaliTextEditorScrolling ");
3250 TextEditor textEditor = TextEditor::New();
3251 DALI_TEST_CHECK( textEditor );
3253 application.GetScene().Add( textEditor );
3255 // Avoid a crash when core load gl resources.
3256 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3258 application.SendNotification();
3259 application.Render();
3261 textEditor.SetProperty(TextEditor::Property::TEXT, "Tex1\nTex2\nTex3\nTex4\nTex5\nTex6\nTex7\nTex8");
3262 textEditor.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER);
3263 textEditor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER);
3264 textEditor.SetProperty(Actor::Property::SIZE, Vector2(60.0f, 160.0f));
3266 application.SendNotification();
3267 application.Render();
3269 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3270 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3273 DevelTextEditor::ScrollBy(textEditor, Vector2(1.0f, 1.0f));
3275 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, TEST_LOCATION );
3276 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3278 DevelTextEditor::ScrollBy(textEditor, Vector2(0.0f, 1000.0f));
3280 DALI_TEST_NOT_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 1.0f, 0.1f, TEST_LOCATION );
3281 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3283 textEditor.SetProperty(DevelTextEditor::Property::VERTICAL_SCROLL_POSITION , 0.0f);
3284 textEditor.SetProperty(DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION , 0.0f);
3286 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::VERTICAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3287 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::HORIZONTAL_SCROLL_POSITION ).Get<float>(), 0.0f, TEST_LOCATION );
3292 int UtcDaliToolkitTextEditorFontSizeScale(void)
3294 ToolkitTestApplication application;
3295 tet_infoline(" UtcDaliToolkitTextEditorFontSizeScale");
3297 TextEditor textEditor = TextEditor::New();
3298 textEditor.SetProperty( TextEditor::Property::POINT_SIZE, 30.f );
3299 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3300 Vector3 nonScaledSize = textEditor.GetNaturalSize();
3302 TextEditor textEditorScaled = TextEditor::New();
3303 textEditorScaled.SetProperty( TextEditor::Property::POINT_SIZE, 15.f );
3304 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3305 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3306 Vector3 scaledSize = textEditorScaled.GetNaturalSize();
3308 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3310 textEditor.SetProperty( TextEditor::Property::PIXEL_SIZE, 30.f );
3311 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
3312 nonScaledSize = textEditor.GetNaturalSize();
3314 textEditorScaled.SetProperty( TextEditor::Property::PIXEL_SIZE, 15.f );
3315 textEditorScaled.SetProperty( Toolkit::DevelTextEditor::Property::FONT_SIZE_SCALE, 2.f );
3316 textEditorScaled.SetProperty( TextEditor::Property::TEXT, "Test" );
3317 scaledSize = textEditorScaled.GetNaturalSize();
3319 DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3324 int UtcDaliTextEditorPrimaryCursorPosition(void)
3326 ToolkitTestApplication application;
3327 tet_infoline(" UtcDaliTextPrimaryCursorPosition ");
3329 TextEditor textEditor = TextEditor::New();
3331 application.GetScene().Add( textEditor );
3333 textEditor.SetProperty( TextEditor::Property::TEXT, "ABCEF");
3334 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3335 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3336 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3338 // Avoid a crash when core load gl resources.
3339 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3341 textEditor.SetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION, 3);
3342 application.SendNotification();
3343 application.Render();
3345 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3347 // Render and notify
3348 application.SendNotification();
3349 application.Render();
3351 DALI_TEST_EQUALS( textEditor.GetProperty( TextEditor::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3352 DALI_TEST_EQUALS( textEditor.GetProperty( DevelTextEditor::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3357 int UtcDaliTextEditorLineCountAfterGetNaturalSize(void)
3359 ToolkitTestApplication application;
3360 tet_infoline(" UtcDaliTextEditorLineCountAfterGetNaturalSize ");
3362 TextEditor textEditor = TextEditor::New();
3363 textEditor.SetProperty(TextEditor::Property::TEXT, "A\nB\nC\nD\nE\nF\n");
3364 textEditor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3365 textEditor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3366 textEditor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3367 application.GetScene().Add( textEditor );
3369 application.SendNotification();
3370 application.Render();
3373 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3374 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );
3376 textEditor.GetNaturalSize();
3378 // Create a tap event to touch the text editor.
3379 TestGenerateTap( application, 18.0f, 25.0f );
3381 application.SendNotification();
3382 application.Render();
3384 lineCount = textEditor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
3385 DALI_TEST_EQUALS( lineCount, 7, TEST_LOCATION );