2 * Copyright (c) 2019 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/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali-toolkit-test-suite-utils.h>
27 #include <dali-toolkit/dali-toolkit.h>
28 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
31 using namespace Toolkit;
33 void dali_texteditor_startup(void)
35 test_return_value = TET_UNDEF;
38 void dali_texteditor_cleanup(void)
40 test_return_value = TET_PASS;
46 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
47 const char* const PROPERTY_NAME_TEXT = "text";
48 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
49 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
50 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
51 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
52 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
53 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
54 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
55 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
56 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
57 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
58 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
59 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
60 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
61 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
62 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
63 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
64 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
70 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
71 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
72 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
73 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
74 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
75 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
77 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
78 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
79 const char* const PROPERTY_NAME_UNDERLINE = "underline";
80 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
81 const char* const PROPERTY_NAME_SHADOW = "shadow";
82 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
83 const char* const PROPERTY_NAME_EMBOSS = "emboss";
84 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
85 const char* const PROPERTY_NAME_OUTLINE = "outline";
86 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
88 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
89 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
90 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
91 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
92 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
93 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
94 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
95 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
96 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
97 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
98 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
99 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
100 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
101 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
104 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
105 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
107 const float RENDER_FRAME_INTERVAL = 16.66f;
109 const unsigned int DEFAULT_FONT_SIZE = 1152u;
110 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
112 const int KEY_A_CODE = 38;
113 const int KEY_D_CODE = 40;
114 const int KEY_C_CODE = 54;
115 const int KEY_V_CODE = 55;
116 const int KEY_X_CODE = 53;
117 const int KEY_WHITE_SPACE_CODE = 65;
119 const int KEY_SHIFT_MODIFIER = 257;
120 const int KEY_CONTROL_MODIFIER = 258;
122 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
124 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126 static bool gTextChangedCallBackCalled;
127 static bool gInputStyleChangedCallbackCalled;
128 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
130 struct CallbackFunctor
132 CallbackFunctor(bool* callbackFlag)
133 : mCallbackFlag( callbackFlag )
139 *mCallbackFlag = true;
144 static void TestTextChangedCallback( TextEditor control )
146 tet_infoline(" TestTextChangedCallback");
148 gTextChangedCallBackCalled = true;
151 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
153 tet_infoline(" TestInputStyleChangedCallback");
155 gInputStyleChangedCallbackCalled = true;
156 gInputStyleMask = mask;
159 // Generate a KeyEvent to send to Core.
160 Integration::KeyEvent GenerateKey( const std::string& keyName,
161 const std::string& logicalKey,
162 const std::string& keyString,
165 unsigned long timeStamp,
166 const Integration::KeyEvent::State& keyState,
167 const std::string& compose = "",
168 const std::string& deviceName = DEFAULT_DEVICE_NAME,
169 const Device::Class::Type& deviceClass = Device::Class::NONE,
170 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
172 return Integration::KeyEvent( keyName,
185 Dali::Integration::Point GetPointDownInside( Vector2& pos )
187 Dali::Integration::Point point;
188 point.SetState( PointState::DOWN );
189 point.SetScreenPosition( pos );
193 Dali::Integration::Point GetPointUpInside( Vector2& pos )
195 Dali::Integration::Point point;
196 point.SetState( PointState::UP );
197 point.SetScreenPosition( pos );
201 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
203 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
205 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
207 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
209 Property::Value* valueSet = NULL;
210 if ( valueGet.first.type == Property::Key::INDEX )
212 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
216 // Get Key is a string so searching Set Map for a string key
217 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
220 if( NULL != valueSet )
222 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
224 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
227 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
229 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
232 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
234 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
237 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
239 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
242 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
244 Vector2 vector2Get = valueGet.second.Get<Vector2>();
245 Vector2 vector2Set = valueSet->Get<Vector2>();
246 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
249 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
251 Vector4 vector4Get = valueGet.second.Get<Vector4>();
252 Vector4 vector4Set = valueSet->Get<Vector4>();
253 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 );
259 if ( valueGet.first.type == Property::Key::INDEX )
261 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
265 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
275 class ScrollStateChangeCallback : public Dali::ConnectionTracker
278 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
279 : mStartedCalled( startedCalled ),
280 mFinishedCalled( finishedCalled )
284 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
286 if( type == TextEditor::Scroll::STARTED )
288 mStartedCalled = true;
290 else if( type == TextEditor::Scroll::FINISHED )
292 mFinishedCalled = true;
296 bool& mStartedCalled;
297 bool& mFinishedCalled;
302 int UtcDaliToolkitTextEditorConstructorP(void)
304 ToolkitTestApplication application;
305 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
306 TextEditor textEditor;
307 DALI_TEST_CHECK( !textEditor );
311 int UtcDaliToolkitTextEditorNewP(void)
313 ToolkitTestApplication application;
314 tet_infoline(" UtcDaliToolkitTextEditorNewP");
315 TextEditor textEditor = TextEditor::New();
316 DALI_TEST_CHECK( textEditor );
320 int UtcDaliToolkitTextEditorDownCastP(void)
322 ToolkitTestApplication application;
323 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
324 TextEditor textEditor1 = TextEditor::New();
325 BaseHandle object( textEditor1 );
327 TextEditor textEditor2 = TextEditor::DownCast( object );
328 DALI_TEST_CHECK( textEditor2 );
330 TextEditor textEditor3 = DownCast< TextEditor >( object );
331 DALI_TEST_CHECK( textEditor3 );
335 int UtcDaliToolkitTextEditorDownCastN(void)
337 ToolkitTestApplication application;
338 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
339 BaseHandle uninitializedObject;
340 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
341 DALI_TEST_CHECK( !textEditor1 );
343 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
344 DALI_TEST_CHECK( !textEditor2 );
348 int UtcDaliToolkitTextEditorCopyConstructorP(void)
350 ToolkitTestApplication application;
351 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
352 TextEditor textEditor = TextEditor::New();
353 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
355 TextEditor copy( textEditor );
356 DALI_TEST_CHECK( copy );
357 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
361 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
363 ToolkitTestApplication application;
364 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
365 TextEditor textEditor = TextEditor::New();
366 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
368 TextEditor copy = textEditor;
369 DALI_TEST_CHECK( copy );
370 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
374 int UtcDaliTextEditorNewP(void)
376 ToolkitTestApplication application;
377 tet_infoline(" UtcDaliToolkitTextEditorNewP");
378 TextEditor textEditor = TextEditor::New();
379 DALI_TEST_CHECK( textEditor );
383 // Positive test case for a method
384 int UtcDaliTextEditorGetPropertyP(void)
386 ToolkitTestApplication application;
387 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
388 TextEditor editor = TextEditor::New();
389 DALI_TEST_CHECK( editor );
391 // Check Property Indices are correct
392 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
393 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
394 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
395 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
396 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
397 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
398 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
399 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
400 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
401 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
402 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
403 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
404 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
405 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
406 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
407 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
408 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
409 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
410 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
411 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
412 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
413 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
414 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
415 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
416 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
417 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
451 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
454 Property::Map imageMap;
455 imageMap[mapKey] =mapValue;
457 editor.SetProperty( property , imageMap );
458 Property::Value propValue = editor.GetProperty( property );
459 Property::Map* resultMap = propValue.GetMap();
461 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
469 // Positive test case for a method
470 int UtcDaliTextEditorSetPropertyP(void)
472 ToolkitTestApplication application;
473 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
474 TextEditor editor = TextEditor::New();
475 DALI_TEST_CHECK( editor );
476 Stage::GetCurrent().Add( editor );
478 // Note - we can't check the defaults since the stylesheets are platform-specific
480 // Check the render backend property.
481 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
482 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
484 // Check text property.
485 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
486 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
488 // Check text's color property
489 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
490 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
492 // Check font properties.
493 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
494 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
496 Property::Map fontStyleMapSet;
497 Property::Map fontStyleMapGet;
498 Property::Value* slantValue = NULL;
500 fontStyleMapSet.Insert( "weight", "bold" );
501 fontStyleMapSet.Insert( "width", "condensed" );
502 fontStyleMapSet.Insert( "slant", "italic" );
504 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
505 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
506 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
507 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
509 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
510 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
513 fontStyleMapSet.Clear();
514 fontStyleMapSet.Insert( "weight", "normal" );
515 fontStyleMapSet.Insert( "slant", "oblique" );
516 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
517 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
518 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
519 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
521 fontStyleMapSet.Clear();
522 fontStyleMapSet.Insert( "slant", "roman" );
523 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
524 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
526 // Replace 'roman' for 'normal'.
527 slantValue = fontStyleMapGet.Find( "slant" );
528 if( NULL != slantValue )
530 if( "normal" == slantValue->Get<std::string>() )
532 fontStyleMapGet["slant"] = "roman";
535 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
536 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
538 fontStyleMapSet.Clear();
540 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
541 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
542 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
543 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
545 // Check that the Alignment properties can be correctly set
546 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
547 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
549 // Check scroll properties.
550 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
551 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
552 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
553 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
555 // Check cursor properties
556 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
557 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
558 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
559 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
561 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
562 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
563 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
564 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
565 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
566 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
567 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
568 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
570 // Check handle images
571 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
572 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
573 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
574 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
575 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
577 // Check handle images
578 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
579 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
580 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
581 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
582 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
583 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
585 // Check the highlight color
586 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
587 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
589 // Decoration bounding box
590 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
591 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
593 // Check the enable markup property.
594 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
595 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
596 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
598 // Check input color property.
599 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
600 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
602 // Check input font properties.
603 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
604 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
606 fontStyleMapSet.Clear();
607 fontStyleMapSet.Insert( "weight", "bold" );
608 fontStyleMapSet.Insert( "width", "condensed" );
609 fontStyleMapSet.Insert( "slant", "italic" );
611 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
612 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
613 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
616 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
617 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
619 // Reset input font style.
620 fontStyleMapSet.Clear();
621 fontStyleMapSet.Insert( "weight", "normal" );
622 fontStyleMapSet.Insert( "slant", "oblique" );
624 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
625 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
626 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
627 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
629 fontStyleMapSet.Clear();
630 fontStyleMapSet.Insert( "slant", "roman" );
632 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
633 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
635 // Replace 'roman' for 'normal'.
636 slantValue = fontStyleMapGet.Find( "slant" );
637 if( NULL != slantValue )
639 if( "normal" == slantValue->Get<std::string>() )
641 fontStyleMapGet["slant"] = "roman";
644 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
645 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
647 fontStyleMapSet.Clear();
649 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
650 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
651 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
652 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
654 // Check the line spacing property
655 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
656 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
657 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 // Check the input line spacing property
660 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
662 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
664 // Check the underline property
666 Property::Map underlineMapSet;
667 Property::Map underlineMapGet;
669 underlineMapSet.Insert( "enable", true );
670 underlineMapSet.Insert( "color", Color::RED );
671 underlineMapSet.Insert( "height", 1 );
673 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
675 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
676 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
677 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
679 // Check the input underline property
680 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
681 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
683 // Check the shadow property
684 Property::Map shadowMapSet;
685 Property::Map shadowMapGet;
687 shadowMapSet.Insert( "color", Color::GREEN );
688 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
689 shadowMapSet.Insert( "blurRadius", 3.0f );
691 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
693 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
694 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
695 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
697 // Check the input shadow property
698 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
699 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
701 // Check the emboss property
702 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
703 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
705 // Check the input emboss property
706 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
707 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
709 // Check the outline property
711 // Test string type first
712 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
713 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
714 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
716 // Then test the property map type
717 Property::Map outlineMapSet;
718 Property::Map outlineMapGet;
720 outlineMapSet["color"] = Color::RED;
721 outlineMapSet["width"] = 2.0f;
723 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
725 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
726 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
727 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
729 // Check the input outline property
730 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
731 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
733 // Check the smooth scroll property
734 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
735 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
736 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
738 // Check the smooth scroll duration property
739 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
740 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
742 // Check the scroll bar property
743 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
744 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
745 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
747 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
748 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
749 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
750 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
752 // Check the pixel size of font
753 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
754 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
756 // Check placeholder text properties.
757 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
758 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
760 // Check placeholder text's color property.
761 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
762 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
764 // Check the enable selection property
765 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
766 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
768 // Check the placeholder property with pixel size
769 Property::Map placeholderPixelSizeMapSet;
770 Property::Map placeholderPixelSizeMapGet;
771 Property::Map placeholderFontstyleMap;
772 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
773 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
774 placeholderPixelSizeMapSet["color"] = Color::BLUE;
775 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
776 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
778 placeholderFontstyleMap.Insert( "weight", "bold" );
779 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
780 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
782 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
783 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
785 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
786 Property::Map placeholderConversionMap;
787 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
788 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
789 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
790 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
791 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
792 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
794 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
796 // Check the placeholder property with point size
797 Property::Map placeholderMapSet;
798 Property::Map placeholderMapGet;
799 placeholderMapSet["text"] = "Setting Placeholder Text";
800 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
801 placeholderMapSet["color"] = Color::RED;
802 placeholderMapSet["fontFamily"] = "Arial";
803 placeholderMapSet["pointSize"] = 12.0f;
804 // Check the placeholder font style property
805 placeholderFontstyleMap.Clear();
807 placeholderFontstyleMap.Insert( "weight", "bold" );
808 placeholderFontstyleMap.Insert( "width", "condensed" );
809 placeholderFontstyleMap.Insert( "slant", "italic" );
810 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
811 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
813 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
814 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
816 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
817 placeholderConversionMap.Clear();
818 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
819 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
820 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
821 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
822 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
823 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
824 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
827 placeholderFontstyleMap.Clear();
828 placeholderFontstyleMap.Insert( "weight", "normal" );
829 placeholderFontstyleMap.Insert( "slant", "oblique" );
830 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
831 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
833 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
834 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
835 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
836 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
838 placeholderFontstyleMap.Clear();
839 placeholderFontstyleMap.Insert( "slant", "roman" );
840 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
841 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
843 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
845 placeholderFontstyleMap.Clear();
846 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
848 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
849 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
850 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
851 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
852 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
854 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
855 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
857 application.SendNotification();
858 application.Render();
863 // Positive Atlas Text Renderer test
864 int utcDaliTextEditorAtlasRenderP(void)
866 ToolkitTestApplication application;
867 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
868 StyleManager styleManager = StyleManager::Get();
869 styleManager.ApplyDefaultTheme();
870 TextEditor editor = TextEditor::New();
871 DALI_TEST_CHECK( editor );
873 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
875 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
877 Stage::GetCurrent().Add( editor );
881 // Render some text with the shared atlas backend
882 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
883 application.SendNotification();
884 application.Render();
888 tet_result(TET_FAIL);
893 // Positive test for the textChanged signal.
894 int utcDaliTextEditorTextChangedP(void)
896 ToolkitTestApplication application;
897 tet_infoline(" utcDaliTextEditorTextChangedP");
898 TextEditor editor = TextEditor::New();
899 DALI_TEST_CHECK( editor );
901 Stage::GetCurrent().Add( editor );
903 // connect to the text changed signal.
904 ConnectionTracker* testTracker = new ConnectionTracker();
905 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
906 bool textChangedSignal = false;
907 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
909 gTextChangedCallBackCalled = false;
910 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
911 DALI_TEST_CHECK( gTextChangedCallBackCalled );
912 DALI_TEST_CHECK( textChangedSignal );
914 application.SendNotification();
916 editor.SetKeyInputFocus();
918 gTextChangedCallBackCalled = false;
919 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
920 DALI_TEST_CHECK( gTextChangedCallBackCalled );
925 int utcDaliTextEditorInputStyleChanged01(void)
927 ToolkitTestApplication application;
928 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
930 // The text-editor emits signals when the input style changes. These changes of style are
931 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
932 // can't be emitted during the size negotiation as the callbacks may update the UI.
933 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
934 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
935 application.CreateAdaptor();
939 char* pathNamePtr = get_current_dir_name();
940 const std::string pathName( pathNamePtr );
943 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
944 fontClient.SetDpi( 93u, 93u );
946 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
947 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
949 TextEditor editor = TextEditor::New();
950 DALI_TEST_CHECK( editor );
953 editor.SetSize( 300.f, 50.f );
954 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
955 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
957 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
958 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
960 // connect to the text changed signal.
961 ConnectionTracker* testTracker = new ConnectionTracker();
962 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
963 bool inputStyleChangedSignal = false;
964 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
966 Stage::GetCurrent().Add( editor );
969 application.SendNotification();
970 application.Render();
972 // Executes the idle callbacks added by the text control on the change of input style.
973 application.RunIdles();
975 gInputStyleChangedCallbackCalled = false;
976 gInputStyleMask = TextEditor::InputStyle::NONE;
977 inputStyleChangedSignal = false;
979 // Create a tap event to touch the text editor.
980 TestGenerateTap( application, 18.0f, 25.0f );
983 application.SendNotification();
984 application.Render();
986 // Executes the idle callbacks added by the text control on the change of input style.
987 application.RunIdles();
989 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
990 if( gInputStyleChangedCallbackCalled )
992 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
994 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
995 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
997 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
998 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1000 DALI_TEST_CHECK( inputStyleChangedSignal );
1002 gInputStyleChangedCallbackCalled = false;
1003 gInputStyleMask = TextEditor::InputStyle::NONE;
1004 inputStyleChangedSignal = false;
1006 // Create a tap event to touch the text editor.
1007 TestGenerateTap( application, 30.0f, 25.0f );
1009 // Render and notify
1010 application.SendNotification();
1011 application.Render();
1013 // Executes the idle callbacks added by the text control on the change of input style.
1014 application.RunIdles();
1016 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1017 DALI_TEST_CHECK( !inputStyleChangedSignal );
1019 gInputStyleChangedCallbackCalled = false;
1020 gInputStyleMask = TextEditor::InputStyle::NONE;
1021 inputStyleChangedSignal = false;
1023 // Create a tap event to touch the text editor.
1024 TestGenerateTap( application, 43.0f, 25.0f );
1026 // Render and notify
1027 application.SendNotification();
1028 application.Render();
1030 // Executes the idle callbacks added by the text control on the change of input style.
1031 application.RunIdles();
1033 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1034 if( gInputStyleChangedCallbackCalled )
1036 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1038 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1039 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1041 DALI_TEST_CHECK( inputStyleChangedSignal );
1043 gInputStyleChangedCallbackCalled = false;
1044 gInputStyleMask = TextEditor::InputStyle::NONE;
1045 inputStyleChangedSignal = false;
1047 // Create a tap event to touch the text editor.
1048 TestGenerateTap( application, 88.0f, 25.0f );
1050 // Render and notify
1051 application.SendNotification();
1052 application.Render();
1054 // Executes the idle callbacks added by the text control on the change of input style.
1055 application.RunIdles();
1057 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1058 if( gInputStyleChangedCallbackCalled )
1060 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1062 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1063 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1065 Property::Map fontStyleMapSet;
1066 Property::Map fontStyleMapGet;
1068 fontStyleMapSet.Insert( "weight", "bold" );
1070 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1071 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1072 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1074 DALI_TEST_CHECK( inputStyleChangedSignal );
1076 gInputStyleChangedCallbackCalled = false;
1077 gInputStyleMask = TextEditor::InputStyle::NONE;
1078 inputStyleChangedSignal = false;
1080 // Create a tap event to touch the text editor.
1081 TestGenerateTap( application, 115.0f, 25.0f );
1083 // Render and notify
1084 application.SendNotification();
1085 application.Render();
1087 // Executes the idle callbacks added by the text control on the change of input style.
1088 application.RunIdles();
1090 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1091 DALI_TEST_CHECK( !inputStyleChangedSignal );
1093 gInputStyleChangedCallbackCalled = false;
1094 gInputStyleMask = TextEditor::InputStyle::NONE;
1095 inputStyleChangedSignal = false;
1097 // Create a tap event to touch the text editor.
1098 TestGenerateTap( application, 164.0f, 25.0f );
1100 // Render and notify
1101 application.SendNotification();
1102 application.Render();
1104 // Executes the idle callbacks added by the text control on the change of input style.
1105 application.RunIdles();
1107 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1108 if( gInputStyleChangedCallbackCalled )
1110 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1112 Property::Map fontStyleMapSet;
1113 Property::Map fontStyleMapGet;
1115 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1116 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1117 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1119 DALI_TEST_CHECK( inputStyleChangedSignal );
1121 gInputStyleChangedCallbackCalled = false;
1122 gInputStyleMask = TextEditor::InputStyle::NONE;
1123 inputStyleChangedSignal = false;
1125 // Create a tap event to touch the text editor.
1126 TestGenerateTap( application, 191.0f, 25.0f );
1128 // Render and notify
1129 application.SendNotification();
1130 application.Render();
1132 // Executes the idle callbacks added by the text control on the change of input style.
1133 application.RunIdles();
1135 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1136 DALI_TEST_CHECK( !inputStyleChangedSignal );
1141 int utcDaliTextEditorInputStyleChanged02(void)
1143 ToolkitTestApplication application;
1144 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1146 // The text-editor emits signals when the input style changes. These changes of style are
1147 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1148 // can't be emitted during the size negotiation as the callbacks may update the UI.
1149 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1150 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1151 application.CreateAdaptor();
1155 char* pathNamePtr = get_current_dir_name();
1156 const std::string pathName( pathNamePtr );
1157 free( pathNamePtr );
1159 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1160 fontClient.SetDpi( 93u, 93u );
1162 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1163 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1165 TextEditor editor = TextEditor::New();
1166 DALI_TEST_CHECK( editor );
1169 editor.SetSize( 300.f, 50.f );
1170 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1171 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1173 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1174 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>" );
1176 // connect to the text changed signal.
1177 ConnectionTracker* testTracker = new ConnectionTracker();
1178 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1179 bool inputStyleChangedSignal = false;
1180 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1182 Stage::GetCurrent().Add( editor );
1184 // Render and notify
1185 application.SendNotification();
1186 application.Render();
1188 // Executes the idle callbacks added by the text control on the change of input style.
1189 application.RunIdles();
1191 gInputStyleChangedCallbackCalled = false;
1192 gInputStyleMask = TextEditor::InputStyle::NONE;
1193 inputStyleChangedSignal = false;
1195 // Create a tap event to touch the text editor.
1196 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1197 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1199 // Render and notify
1200 application.SendNotification();
1201 application.Render();
1203 // Executes the idle callbacks added by the text control on the change of input style.
1204 application.RunIdles();
1206 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1207 if( gInputStyleChangedCallbackCalled )
1209 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1210 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1211 TextEditor::InputStyle::POINT_SIZE |
1212 TextEditor::InputStyle::COLOR ),
1215 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1216 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1218 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1219 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1221 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1222 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1224 DALI_TEST_CHECK( inputStyleChangedSignal );
1226 gInputStyleChangedCallbackCalled = false;
1227 gInputStyleMask = TextEditor::InputStyle::NONE;
1228 inputStyleChangedSignal = false;
1230 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1232 // Render and notify
1233 application.SendNotification();
1234 application.Render();
1236 // Executes the idle callbacks added by the text control on the change of input style.
1237 application.RunIdles();
1239 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1240 if( gInputStyleChangedCallbackCalled )
1242 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1243 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1246 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1247 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1249 DALI_TEST_CHECK( inputStyleChangedSignal );
1251 gInputStyleChangedCallbackCalled = false;
1252 gInputStyleMask = TextEditor::InputStyle::NONE;
1253 inputStyleChangedSignal = false;
1255 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1257 // Render and notify
1258 application.SendNotification();
1259 application.Render();
1261 // Executes the idle callbacks added by the text control on the change of input style.
1262 application.RunIdles();
1264 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1265 DALI_TEST_CHECK( !inputStyleChangedSignal );
1267 gInputStyleChangedCallbackCalled = false;
1268 gInputStyleMask = TextEditor::InputStyle::NONE;
1269 inputStyleChangedSignal = false;
1271 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1273 // Render and notify
1274 application.SendNotification();
1275 application.Render();
1277 // Executes the idle callbacks added by the text control on the change of input style.
1278 application.RunIdles();
1280 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1281 if( gInputStyleChangedCallbackCalled )
1283 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1284 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1287 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1288 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1290 DALI_TEST_CHECK( inputStyleChangedSignal );
1292 gInputStyleChangedCallbackCalled = false;
1293 gInputStyleMask = TextEditor::InputStyle::NONE;
1294 inputStyleChangedSignal = false;
1296 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1298 Property::Map fontStyleMapSet;
1299 fontStyleMapSet.Insert( "weight", "thin" );
1300 fontStyleMapSet.Insert( "width", "condensed" );
1301 fontStyleMapSet.Insert( "slant", "italic" );
1303 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1304 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1305 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1307 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1308 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1309 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1310 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1312 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1314 // Render and notify
1315 application.SendNotification();
1316 application.Render();
1318 // Executes the idle callbacks added by the text control on the change of input style.
1319 application.RunIdles();
1321 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1322 DALI_TEST_CHECK( !inputStyleChangedSignal );
1324 // Create a tap event to touch the text editor.
1325 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1327 // Render and notify
1328 application.SendNotification();
1329 application.Render();
1331 // Executes the idle callbacks added by the text control on the change of input style.
1332 application.RunIdles();
1334 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1335 if( gInputStyleChangedCallbackCalled )
1337 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1338 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1339 TextEditor::InputStyle::POINT_SIZE |
1340 TextEditor::InputStyle::FONT_STYLE |
1341 TextEditor::InputStyle::LINE_SPACING |
1342 TextEditor::InputStyle::UNDERLINE |
1343 TextEditor::InputStyle::SHADOW |
1344 TextEditor::InputStyle::EMBOSS |
1345 TextEditor::InputStyle::OUTLINE ),
1348 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1349 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1351 DALI_TEST_CHECK( inputStyleChangedSignal );
1353 gInputStyleChangedCallbackCalled = false;
1354 gInputStyleMask = TextEditor::InputStyle::NONE;
1355 inputStyleChangedSignal = false;
1357 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1359 fontStyleMapSet.Clear();
1360 fontStyleMapSet.Insert( "weight", "black" );
1361 fontStyleMapSet.Insert( "width", "expanded" );
1362 fontStyleMapSet.Insert( "slant", "oblique" );
1364 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1366 // Create a tap event to touch the text editor.
1367 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1369 // Render and notify
1370 application.SendNotification();
1371 application.Render();
1373 // Executes the idle callbacks added by the text control on the change of input style.
1374 application.RunIdles();
1376 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1377 if( gInputStyleChangedCallbackCalled )
1379 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1380 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1381 TextEditor::InputStyle::POINT_SIZE |
1382 TextEditor::InputStyle::FONT_STYLE ),
1385 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1386 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1388 DALI_TEST_CHECK( inputStyleChangedSignal );
1393 int utcDaliTextEditorEvent01(void)
1395 ToolkitTestApplication application;
1396 tet_infoline(" utcDaliTextEditorEvent01");
1398 // Creates a tap event. After creating a tap event the text editor should
1399 // have the focus and add text with key events should be possible.
1401 TextEditor editor = TextEditor::New();
1402 DALI_TEST_CHECK( editor );
1404 Stage::GetCurrent().Add( editor );
1406 editor.SetSize( 300.f, 50.f );
1407 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1408 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1410 // Avoid a crash when core load gl resources.
1411 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1413 // Render and notify
1414 application.SendNotification();
1415 application.Render();
1417 // Add a key event but as the text editor has not the focus it should do nothing.
1418 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1420 // Render and notify
1421 application.SendNotification();
1422 application.Render();
1424 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1426 // Create a tap event to touch the text editor.
1427 TestGenerateTap( application, 150.0f, 25.0f );
1429 // Render and notify
1430 application.SendNotification();
1431 application.Render();
1433 // Now the text editor has the focus, so it can handle the key events.
1434 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1435 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1437 // Render and notify
1438 application.SendNotification();
1439 application.Render();
1441 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1443 // Create a second text editor and send key events to it.
1444 TextEditor editor2 = TextEditor::New();
1446 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1447 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1448 editor2.SetSize( 100.f, 100.f );
1449 editor2.SetPosition( 100.f, 100.f );
1451 Stage::GetCurrent().Add( editor2 );
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
1457 // Create a tap event on the second text editor.
1458 TestGenerateTap( application, 150.0f, 125.0f );
1460 // Render and notify
1461 application.SendNotification();
1462 application.Render();
1464 // The second text editor has the focus. It should handle the key events.
1465 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1466 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1468 // Render and notify
1469 application.SendNotification();
1470 application.Render();
1472 // Check the text has been added to the second text editor.
1473 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1478 int utcDaliTextEditorEvent02(void)
1480 ToolkitTestApplication application;
1481 tet_infoline(" utcDaliTextEditorEvent02");
1483 // Checks if the right number of actors are created.
1485 TextEditor editor = TextEditor::New();
1486 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1487 DALI_TEST_CHECK( editor );
1489 Stage::GetCurrent().Add( editor );
1491 editor.SetSize( 300.f, 50.f );
1492 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1493 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1495 // Avoid a crash when core load gl resources.
1496 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1498 // Render and notify
1499 application.SendNotification();
1500 application.Render();
1502 // Check there are the expected number of children (the stencil).
1503 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1505 Actor stencil = editor.GetChildAt( 0u );
1507 // Create a tap event to touch the text editor.
1508 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1510 // Render and notify
1511 application.SendNotification();
1512 application.Render();
1514 Actor layer = editor.GetChildAt( 1u );
1515 DALI_TEST_CHECK( layer.IsLayer() );
1517 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1518 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1520 // Now the text editor has the focus, so it can handle the key events.
1521 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1522 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1524 // Render and notify
1525 application.SendNotification();
1526 application.Render();
1528 // Checks the cursor and the renderer have been created.
1529 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1530 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1532 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1533 DALI_TEST_CHECK( cursor );
1535 // The stencil actor has a container with all the actors which contain the text renderers.
1536 Actor container = stencil.GetChildAt( 0u );
1537 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1539 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1540 DALI_TEST_CHECK( renderer );
1543 // Move the cursor and check the position changes.
1544 Vector3 position1 = cursor.GetCurrentPosition();
1546 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1547 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1549 // Render and notify
1550 application.SendNotification();
1551 application.Render();
1553 Vector3 position2 = cursor.GetCurrentPosition();
1555 DALI_TEST_CHECK( position2.x < position1.x );
1557 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1558 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 Vector3 position3 = cursor.GetCurrentPosition();
1566 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1568 // Send some taps and check the cursor positions.
1570 // Try to tap at the beginning.
1571 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1573 // Render and notify
1574 application.SendNotification();
1575 application.Render();
1577 // Cursor position should be the same than position1.
1578 Vector3 position4 = cursor.GetCurrentPosition();
1580 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1582 // Tap away from the start position.
1583 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1585 // Render and notify
1586 application.SendNotification();
1587 application.Render();
1589 Vector3 position5 = cursor.GetCurrentPosition();
1591 DALI_TEST_CHECK( position5.x > position4.x );
1593 // Remove all the text.
1594 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1595 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1596 editor.SetProperty( TextEditor::Property::TEXT, "" );
1598 // Render and notify
1599 application.SendNotification();
1600 application.Render();
1602 // Cursor position should be the same than position2.
1603 Vector3 position6 = cursor.GetCurrentPosition();
1605 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1607 // Should not be a renderer.
1608 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1613 int utcDaliTextEditorEvent03(void)
1615 ToolkitTestApplication application;
1616 tet_infoline(" utcDaliTextEditorEvent03");
1618 // Checks if the highlight actor is created.
1620 TextEditor editor = TextEditor::New();
1621 DALI_TEST_CHECK( editor );
1623 Stage::GetCurrent().Add( editor );
1625 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1626 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1627 editor.SetSize( 30.f, 50.f );
1628 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1629 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1631 // Avoid a crash when core load gl resources.
1632 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1634 // Render and notify
1635 application.SendNotification();
1636 application.Render();
1638 // Send some taps and check text controller with clipboard window
1639 Dali::Clipboard clipboard = Clipboard::Get();
1640 clipboard.ShowClipboard();
1641 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1642 clipboard.HideClipboard();
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 // Tap first to get the focus.
1649 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 // Double tap to select a word.
1656 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1658 // Render and notify
1659 application.SendNotification();
1660 application.Render();
1662 // The stencil actor should have two actors: the renderer and the highlight actor.
1663 Actor stencil = editor.GetChildAt( 0u );
1665 // Highlight needs to be drawn before text, so should come first in child order
1666 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1667 DALI_TEST_CHECK( highlight );
1669 // The stencil actor has a container with all the actors which contain the text renderers.
1670 Actor container = stencil.GetChildAt( 1u );
1671 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1673 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1674 DALI_TEST_CHECK( renderer );
1677 // Double tap out of bounds
1678 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1679 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1681 // Render and notify
1682 application.SendNotification();
1683 application.Render();
1685 // The stencil actor should have one actors: the renderer actor.
1686 stencil = editor.GetChildAt( 0u );
1688 // The stencil actor has a container with all the actors which contain the text renderers.
1689 container = stencil.GetChildAt( 0u );
1690 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1692 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1693 DALI_TEST_CHECK( renderer );
1697 TestGenerateLongPress(application, 1.0f, 25.0f);
1699 // Render and notify
1700 application.SendNotification();
1701 application.Render();
1706 int utcDaliTextEditorEvent04(void)
1708 ToolkitTestApplication application;
1709 tet_infoline(" utcDaliTextEditorEvent04");
1711 // Checks if the highlight actor is created.
1713 TextEditor editor = TextEditor::New();
1714 DALI_TEST_CHECK( editor );
1716 Stage::GetCurrent().Add( editor );
1718 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1719 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1720 editor.SetSize( 100.f, 50.f );
1721 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1722 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1724 // Avoid a crash when core load gl resources.
1725 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1727 // Render and notify
1728 application.SendNotification();
1729 application.Render();
1731 // Tap on the text editor
1732 TestGenerateTap( application, 3.0f, 25.0f );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 // Move at the end of the text.
1739 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1740 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1746 for( unsigned int index = 0u; index < 10u; ++index )
1748 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1749 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1757 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1759 // Render and notify
1760 application.SendNotification();
1761 application.Render();
1763 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1765 // Add some key events
1766 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1767 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 for( unsigned int index = 0u; index < 10u; ++index )
1775 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1776 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1784 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1786 // Render and notify
1787 application.SendNotification();
1788 application.Render();
1790 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1795 int utcDaliTextEditorEvent05(void)
1797 ToolkitTestApplication application;
1798 tet_infoline(" utcDaliTextEditorEvent05");
1800 // Checks if the highlight actor is created.
1802 TextEditor editor = TextEditor::New();
1803 DALI_TEST_CHECK( editor );
1805 Stage::GetCurrent().Add( editor );
1807 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1808 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1809 editor.SetSize( 50.f, 50.f );
1810 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1811 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1812 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1813 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1814 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1815 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1816 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1818 // Avoid a crash when core load gl resources.
1819 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1821 // Render and notify
1822 application.SendNotification();
1823 application.Render();
1825 // Tap on the text editor
1826 TestGenerateTap( application, 3.0f, 25.0f );
1828 // Render and notify
1829 application.SendNotification();
1830 application.Render();
1832 // Move at the end of the text.
1833 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1834 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 for( unsigned int index = 0u; index < 10u; ++index )
1843 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Modify duration after scroll is enabled
1850 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1852 // Continuous scroll left to increase coverage
1853 for( unsigned int index = 0u; index < 10u; ++index )
1855 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1862 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1863 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1864 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1865 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1867 // Press Escape to increase coverage
1868 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1869 application.SendNotification();
1870 application.Render();
1872 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1877 int utcDaliTextEditorEvent06(void)
1879 ToolkitTestApplication application;
1880 tet_infoline(" utcDaliTextEditorEvent06");
1882 // Checks if the highlight actor is created.
1884 TextEditor editor = TextEditor::New();
1885 DALI_TEST_CHECK( editor );
1887 Stage::GetCurrent().Add( editor );
1889 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1890 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1891 editor.SetSize( 100.f, 50.f );
1892 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1893 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1895 // Avoid a crash when core load gl resources.
1896 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 // Tap on the text editor
1903 TestGenerateTap( application, 3.0f, 25.0f );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 // Move to seconds line of the text.
1910 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1912 // Render and notify
1913 application.SendNotification();
1914 application.Render();
1916 float layoutHeight = editor.GetHeightForWidth( 100.f );
1919 // Add another script characters ( glyph height is defferent )
1920 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1921 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1923 // Delete characters
1924 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1925 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1927 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1929 // Render and notify
1930 application.SendNotification();
1931 application.Render();
1933 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1936 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1937 application.SendNotification();
1938 application.Render();
1940 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1941 application.SendNotification();
1942 application.Render();
1944 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1945 application.SendNotification();
1946 application.Render();
1948 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1949 application.SendNotification();
1950 application.Render();
1952 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1953 application.SendNotification();
1954 application.Render();
1956 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1957 application.SendNotification();
1958 application.Render();
1960 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1961 application.SendNotification();
1962 application.Render();
1967 int utcDaliTextEditorEvent07(void)
1969 ToolkitTestApplication application;
1970 tet_infoline(" utcDaliTextEditorEvent07");
1972 // Checks if the highlight actor is created.
1974 TextEditor editor = TextEditor::New();
1975 DALI_TEST_CHECK( editor );
1977 Stage::GetCurrent().Add( editor );
1979 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1980 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1981 editor.SetSize( 100.f, 50.f );
1982 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1983 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1985 // Avoid a crash when core load gl resources.
1986 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1988 // Render and notify
1989 application.SendNotification();
1990 application.Render();
1992 // Tap on the text editor
1993 TestGenerateTap( application, 3.0f, 25.0f );
1995 // Render and notify
1996 application.SendNotification();
1997 application.Render();
1999 // Move to second line of the text.
2000 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2002 // Render and notify
2003 application.SendNotification();
2004 application.Render();
2006 // Select some text in the right of the current cursor position
2007 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2008 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2009 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2010 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2012 // Render and notify
2013 application.SendNotification();
2014 application.Render();
2016 // Cut the selected text
2017 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2018 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 ) );
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2026 // Select some text in the left of the current cursor position
2027 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2028 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2029 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2030 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2032 // Render and notify
2033 application.SendNotification();
2034 application.Render();
2036 // Copy the selected text
2037 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2038 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 ) );
2040 // Render and notify
2041 application.SendNotification();
2042 application.Render();
2044 // Move the cursor to the third line
2045 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 // Paste the selected text at the current cursor position
2053 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2054 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 ) );
2056 // Render and notify
2057 application.SendNotification();
2058 application.Render();
2060 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2063 // Disable Shift Selection
2064 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2066 // Test to select some text in the right of the current cursor position
2067 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2068 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2069 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 // Render and notify
2073 application.SendNotification();
2074 application.Render();
2076 // Cut the selected text
2077 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080 // Render and notify
2081 application.SendNotification();
2082 application.Render();
2084 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2085 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2087 // Test to select some text in the left of the current cursor position
2088 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2089 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2090 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2093 // Render and notify
2094 application.SendNotification();
2095 application.Render();
2097 // Copy the selected text
2098 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 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 ) );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2106 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2111 int utcDaliTextEditorEvent08(void)
2113 ToolkitTestApplication application;
2114 tet_infoline(" utcDaliTextEditorEvent08");
2116 // Checks if the highlight actor is released correctly.
2118 TextEditor editor = TextEditor::New();
2119 DALI_TEST_CHECK( editor );
2121 Stage::GetCurrent().Add( editor );
2123 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2124 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2125 editor.SetSize( 100.f, 50.f );
2126 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2127 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2129 // Avoid a crash when core load gl resources.
2130 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2132 // Render and notify
2133 application.SendNotification();
2134 application.Render();
2136 // Tap on the text editor
2137 TestGenerateTap( application, 3.0f, 25.0f );
2139 // Render and notify
2140 application.SendNotification();
2141 application.Render();
2143 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2144 // Test to select some text in the left of the current cursor position
2145 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2146 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2150 // Render and notify
2151 application.SendNotification();
2152 application.Render();
2154 // Test to the left selection handle position and the right selection handle position
2155 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Test to select full text in the left of the current cursor position
2165 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2166 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2167 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2169 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2170 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 // Test to release the current full text selection
2177 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2178 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2180 // Render and notify
2181 application.SendNotification();
2182 application.Render();
2184 // Test to move the current cursor position correctly
2185 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2187 // Render and notify
2188 application.SendNotification();
2189 application.Render();
2192 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2194 // Render and notify
2195 application.SendNotification();
2196 application.Render();
2198 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2200 // Test to select some text in the right of the current cursor position
2201 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // Test the cursor position with right arrow key
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2217 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2225 // Test to select some text in the left of the current cursor position
2226 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2227 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2228 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2229 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2230 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2232 // Render and notify
2233 application.SendNotification();
2234 application.Render();
2236 // Test the cursor position with left arrow key
2237 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2239 // Render and notify
2240 application.SendNotification();
2241 application.Render();
2244 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2246 // Render and notify
2247 application.SendNotification();
2248 application.Render();
2250 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2252 // Test to select some text in the right of the current cursor position
2253 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2254 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2258 // Render and notify
2259 application.SendNotification();
2260 application.Render();
2262 // Test the cursor position with left arrow key
2263 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2265 // Render and notify
2266 application.SendNotification();
2267 application.Render();
2270 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 // Render and notify
2273 application.SendNotification();
2274 application.Render();
2276 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2278 // Test to select some text in the left of the current cursor position
2279 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284 // Render and notify
2285 application.SendNotification();
2286 application.Render();
2288 // Test the cursor position with right arrow key
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 // Render and notify
2292 application.SendNotification();
2293 application.Render();
2296 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 // Render and notify
2299 application.SendNotification();
2300 application.Render();
2302 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2307 int utcDaliTextEditorHandles(void)
2309 ToolkitTestApplication application;
2310 tet_infoline(" utcDaliTextEditorHandles");
2312 TextEditor editor = TextEditor::New();
2313 DALI_TEST_CHECK( editor );
2315 Stage::GetCurrent().Add( editor );
2317 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2318 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2319 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2320 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2322 Property::Map imagePropertyMap;
2323 imagePropertyMap["type"] = "BufferImage";
2324 imagePropertyMap["width"] = 40;
2325 imagePropertyMap["height"] = 40;
2327 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2328 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2329 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2330 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2332 editor.SetSize( 30.f, 500.f );
2333 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2334 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2336 // Avoid a crash when core load gl resources.
2337 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
2343 // Tap first to get the focus.
2344 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2346 // Render and notify
2347 application.SendNotification();
2348 application.Render();
2350 // Tap to create the grab handle.
2351 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2353 // Render and notify
2354 application.SendNotification();
2355 application.Render();
2357 // Get the active layer where the text's decoration is added.
2358 Actor activeLayer = editor.GetChildAt( 1u );
2360 // Get the handle's actor.
2361 Actor handle = activeLayer.GetChildAt( 1u );
2362 handle.SetSize( 100.f, 100.f );
2364 // Render and notify
2365 application.SendNotification();
2366 application.Render();
2368 // Touch the grab handle to set it as pressed.
2369 Vector2 touchPos( 10.0f, 50.0f );
2370 Dali::Integration::TouchEvent event;
2371 event = Dali::Integration::TouchEvent();
2372 event.AddPoint( GetPointDownInside( touchPos ) );
2373 application.ProcessEvent( event );
2375 // Render and notify
2376 application.SendNotification();
2377 application.Render();
2379 // Release the grab handle.
2380 event = Dali::Integration::TouchEvent();
2381 event.AddPoint( GetPointUpInside( touchPos ) );
2382 application.ProcessEvent( event );
2384 // Render and notify
2385 application.SendNotification();
2386 application.Render();
2388 // Tap first to get the focus.
2389 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2391 // Render and notify
2392 application.SendNotification();
2393 application.Render();
2395 // Double tap to select a word and create the selection handles.
2396 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2398 // Render and notify
2399 application.SendNotification();
2400 application.Render();
2402 touchPos = Vector2( 10.0f, 50.0f );
2404 // Touch the left selection handle to set it as pressed.
2405 event = Dali::Integration::TouchEvent();
2406 event.AddPoint( GetPointDownInside( touchPos ) );
2407 application.ProcessEvent( event );
2409 // Render and notify
2410 application.SendNotification();
2411 application.Render();
2413 // Release the left selection handle.
2414 event = Dali::Integration::TouchEvent();
2415 event.AddPoint( GetPointUpInside( touchPos ) );
2416 application.ProcessEvent( event );
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2425 int utcDaliTextEditorUnderPropertyStringP(void)
2427 ToolkitTestApplication application;
2428 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2429 TextEditor editor = TextEditor::New();
2430 DALI_TEST_CHECK( editor );
2432 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2434 Stage::GetCurrent().Add( editor );
2436 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2437 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2439 tet_infoline("Set underline settings with a map");
2440 // Check the input underline property
2441 Property::Map underlineMapSet;
2442 Property::Map underlineMapGet;
2443 underlineMapSet.Insert( "enable", true );
2444 underlineMapSet.Insert( "color", Color::BLUE );
2445 underlineMapSet.Insert( "height", 2 );
2447 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2448 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2449 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2450 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2452 tet_infoline("Set underline settings with a string");
2453 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2454 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2457 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2459 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2460 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2461 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2462 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2464 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2469 int utcDaliTextEditorShadowPropertyStringP(void)
2471 ToolkitTestApplication application;
2472 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2474 TextEditor editor = TextEditor::New();
2476 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2478 Stage::GetCurrent().Add( editor );
2480 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2482 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2486 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2491 int utcDaliTextEditorFontStylePropertyStringP(void)
2493 ToolkitTestApplication application;
2494 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2496 TextEditor editor = TextEditor::New();
2498 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2500 Stage::GetCurrent().Add( editor );
2502 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2504 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2508 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2513 int utcDaliTextEditorGetPropertyLinecountP(void)
2515 ToolkitTestApplication application;
2517 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2521 TextEditor editor = TextEditor::New();
2522 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2523 editor.SetProperty( TextEditor::Property::TEXT,
2524 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2526 Stage::GetCurrent().Add( editor );
2528 editor.SetSize( 100.0f, 100.0f );
2529 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2530 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2532 editor.SetSize( 50.0f, 100.0f );
2533 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2534 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2539 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2542 ToolkitTestApplication application;
2543 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2545 TextEditor editor = TextEditor::New();
2546 DALI_TEST_CHECK( editor );
2548 Stage::GetCurrent().Add( editor );
2550 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2551 editor.SetSize( 50.f, 50.f );
2552 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2553 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2554 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2555 editor.SetKeyboardFocusable(true);
2557 bool startedCalled = false;
2558 bool finishedCalled = false;
2560 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2561 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2563 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2565 // Render and notify
2566 application.SendNotification();
2567 application.Render();
2569 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2570 application.SendNotification();
2571 application.Render(6000);
2573 application.SendNotification();
2574 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2575 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2580 int UtcDaliToolkitTextEditorTextWrapMode(void)
2582 ToolkitTestApplication application;
2583 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2587 TextEditor editor = TextEditor::New();
2588 editor.SetSize( 150.0f, 300.f );
2589 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2591 Stage::GetCurrent().Add( editor );
2593 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2594 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2596 application.SendNotification();
2597 application.Render();
2599 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2600 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2602 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2603 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2605 application.SendNotification();
2606 application.Render();
2608 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2609 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2611 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2612 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2614 application.SendNotification();
2615 application.Render();
2617 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2618 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2620 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2621 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2623 application.SendNotification();
2624 application.Render();
2626 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2627 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2632 int UtcDaliTextEditorSetPaddingProperty(void)
2634 ToolkitTestApplication application;
2635 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2637 TextEditor editor = TextEditor::New();
2638 DALI_TEST_CHECK( editor );
2639 editor.SetSize( 300.f, 50.f );
2640 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2641 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2642 Stage::GetCurrent().Add( editor );
2644 application.SendNotification();
2645 application.Render();
2647 Vector3 originalSize = editor.GetNaturalSize();
2649 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2651 application.SendNotification();
2652 application.Render();
2654 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2656 Vector3 paddingAddedSize = editor.GetNaturalSize();
2658 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2660 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2665 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2667 ToolkitTestApplication application;
2668 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2670 TextEditor editor = TextEditor::New();
2671 DALI_TEST_CHECK( editor );
2672 editor.SetSize( 300.f, 50.f );
2673 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2674 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2675 Stage::GetCurrent().Add( editor );
2677 application.SendNotification();
2678 application.Render();
2680 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2681 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2683 // Check the enable shift selection property
2684 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2685 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2687 application.SendNotification();
2688 application.Render();
2693 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2695 ToolkitTestApplication application;
2696 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2698 TextEditor editor = TextEditor::New();
2699 DALI_TEST_CHECK( editor );
2700 editor.SetSize( 300.f, 50.f );
2701 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2702 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2703 Stage::GetCurrent().Add( editor );
2705 application.SendNotification();
2706 application.Render();
2708 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2709 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2711 // Check the enable grab handle property
2712 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2713 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2715 application.SendNotification();
2716 application.Render();
2721 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2723 ToolkitTestApplication application;
2724 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2726 TextEditor editor = TextEditor::New();
2727 DALI_TEST_CHECK( editor );
2728 editor.SetSize( 300.f, 50.f );
2729 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2730 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2731 Stage::GetCurrent().Add( editor );
2733 application.SendNotification();
2734 application.Render();
2736 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2737 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2739 // Check the enable match system language direction property
2740 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2741 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2743 application.SendNotification();
2744 application.Render();
2749 int UtcDaliTextEditorGetInputMethodContext(void)
2751 ToolkitTestApplication application;
2752 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2754 TextEditor editor = TextEditor::New();
2755 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );