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/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
32 using namespace Toolkit;
34 void dali_texteditor_startup(void)
36 test_return_value = TET_UNDEF;
39 void dali_texteditor_cleanup(void)
41 test_return_value = TET_PASS;
47 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
48 const char* const PROPERTY_NAME_TEXT = "text";
49 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
50 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
51 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
52 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
53 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
54 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
55 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
56 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
57 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
58 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
59 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
61 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
62 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
64 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
71 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
72 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
73 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
74 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
75 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
76 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
78 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
79 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
80 const char* const PROPERTY_NAME_UNDERLINE = "underline";
81 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
82 const char* const PROPERTY_NAME_SHADOW = "shadow";
83 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
84 const char* const PROPERTY_NAME_EMBOSS = "emboss";
85 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
86 const char* const PROPERTY_NAME_OUTLINE = "outline";
87 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
89 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
91 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
92 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
93 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
94 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
95 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
96 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
98 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
99 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
100 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
101 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
102 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
105 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
106 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
108 const float RENDER_FRAME_INTERVAL = 16.66f;
110 const unsigned int DEFAULT_FONT_SIZE = 1152u;
111 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
113 const int KEY_A_CODE = 38;
114 const int KEY_D_CODE = 40;
115 const int KEY_C_CODE = 54;
116 const int KEY_V_CODE = 55;
117 const int KEY_X_CODE = 53;
118 const int KEY_WHITE_SPACE_CODE = 65;
120 const int KEY_SHIFT_MODIFIER = 257;
121 const int KEY_CONTROL_MODIFIER = 258;
123 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
127 static bool gTextChangedCallBackCalled;
128 static bool gInputStyleChangedCallbackCalled;
129 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
131 struct CallbackFunctor
133 CallbackFunctor(bool* callbackFlag)
134 : mCallbackFlag( callbackFlag )
140 *mCallbackFlag = true;
145 static void TestTextChangedCallback( TextEditor control )
147 tet_infoline(" TestTextChangedCallback");
149 gTextChangedCallBackCalled = true;
152 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
154 tet_infoline(" TestInputStyleChangedCallback");
156 gInputStyleChangedCallbackCalled = true;
157 gInputStyleMask = mask;
160 // Generate a KeyEvent to send to Core.
161 Integration::KeyEvent GenerateKey( const std::string& keyName,
162 const std::string& logicalKey,
163 const std::string& keyString,
166 unsigned long timeStamp,
167 const Integration::KeyEvent::State& keyState,
168 const std::string& compose = "",
169 const std::string& deviceName = DEFAULT_DEVICE_NAME,
170 const Device::Class::Type& deviceClass = Device::Class::NONE,
171 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
173 return Integration::KeyEvent( keyName,
186 Dali::Integration::Point GetPointDownInside( Vector2& pos )
188 Dali::Integration::Point point;
189 point.SetState( PointState::DOWN );
190 point.SetScreenPosition( pos );
194 Dali::Integration::Point GetPointUpInside( Vector2& pos )
196 Dali::Integration::Point point;
197 point.SetState( PointState::UP );
198 point.SetScreenPosition( pos );
202 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
204 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
206 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
208 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
210 Property::Value* valueSet = NULL;
211 if ( valueGet.first.type == Property::Key::INDEX )
213 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
217 // Get Key is a string so searching Set Map for a string key
218 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
221 if( NULL != valueSet )
223 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
225 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
228 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
230 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
233 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
235 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
238 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
240 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
243 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
245 Vector2 vector2Get = valueGet.second.Get<Vector2>();
246 Vector2 vector2Set = valueSet->Get<Vector2>();
247 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
250 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
252 Vector4 vector4Get = valueGet.second.Get<Vector4>();
253 Vector4 vector4Set = valueSet->Get<Vector4>();
254 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 );
260 if ( valueGet.first.type == Property::Key::INDEX )
262 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
266 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
276 class ScrollStateChangeCallback : public Dali::ConnectionTracker
279 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
280 : mStartedCalled( startedCalled ),
281 mFinishedCalled( finishedCalled )
285 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
287 if( type == TextEditor::Scroll::STARTED )
289 mStartedCalled = true;
291 else if( type == TextEditor::Scroll::FINISHED )
293 mFinishedCalled = true;
297 bool& mStartedCalled;
298 bool& mFinishedCalled;
303 int UtcDaliToolkitTextEditorConstructorP(void)
305 ToolkitTestApplication application;
306 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
307 TextEditor textEditor;
308 DALI_TEST_CHECK( !textEditor );
312 int UtcDaliToolkitTextEditorNewP(void)
314 ToolkitTestApplication application;
315 tet_infoline(" UtcDaliToolkitTextEditorNewP");
316 TextEditor textEditor = TextEditor::New();
317 DALI_TEST_CHECK( textEditor );
321 int UtcDaliToolkitTextEditorDownCastP(void)
323 ToolkitTestApplication application;
324 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
325 TextEditor textEditor1 = TextEditor::New();
326 BaseHandle object( textEditor1 );
328 TextEditor textEditor2 = TextEditor::DownCast( object );
329 DALI_TEST_CHECK( textEditor2 );
331 TextEditor textEditor3 = DownCast< TextEditor >( object );
332 DALI_TEST_CHECK( textEditor3 );
336 int UtcDaliToolkitTextEditorDownCastN(void)
338 ToolkitTestApplication application;
339 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
340 BaseHandle uninitializedObject;
341 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
342 DALI_TEST_CHECK( !textEditor1 );
344 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
345 DALI_TEST_CHECK( !textEditor2 );
349 int UtcDaliToolkitTextEditorCopyConstructorP(void)
351 ToolkitTestApplication application;
352 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
353 TextEditor textEditor = TextEditor::New();
354 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
356 TextEditor copy( textEditor );
357 DALI_TEST_CHECK( copy );
358 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
362 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
364 ToolkitTestApplication application;
365 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
366 TextEditor textEditor = TextEditor::New();
367 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
369 TextEditor copy = textEditor;
370 DALI_TEST_CHECK( copy );
371 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
375 int UtcDaliTextEditorNewP(void)
377 ToolkitTestApplication application;
378 tet_infoline(" UtcDaliToolkitTextEditorNewP");
379 TextEditor textEditor = TextEditor::New();
380 DALI_TEST_CHECK( textEditor );
384 // Positive test case for a method
385 int UtcDaliTextEditorGetPropertyP(void)
387 ToolkitTestApplication application;
388 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
389 TextEditor editor = TextEditor::New();
390 DALI_TEST_CHECK( editor );
392 // Check Property Indices are correct
393 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
394 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
395 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
396 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
397 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
398 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
399 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
400 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
401 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
402 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
403 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
404 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
405 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
406 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
407 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
408 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
409 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
410 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
411 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
412 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
413 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
414 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
415 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
416 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
417 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
452 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
455 Property::Map imageMap;
456 imageMap[mapKey] =mapValue;
458 editor.SetProperty( property , imageMap );
459 Property::Value propValue = editor.GetProperty( property );
460 Property::Map* resultMap = propValue.GetMap();
462 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
470 // Positive test case for a method
471 int UtcDaliTextEditorSetPropertyP(void)
473 ToolkitTestApplication application;
474 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
475 TextEditor editor = TextEditor::New();
476 DALI_TEST_CHECK( editor );
477 Stage::GetCurrent().Add( editor );
479 // Note - we can't check the defaults since the stylesheets are platform-specific
481 // Check the render backend property.
482 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
483 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
485 // Check text property.
486 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
487 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
489 // Check text's color property
490 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
491 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
493 // Check font properties.
494 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
495 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
497 Property::Map fontStyleMapSet;
498 Property::Map fontStyleMapGet;
499 Property::Value* slantValue = NULL;
501 fontStyleMapSet.Insert( "weight", "bold" );
502 fontStyleMapSet.Insert( "width", "condensed" );
503 fontStyleMapSet.Insert( "slant", "italic" );
505 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
506 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
507 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
508 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
510 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
511 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
514 fontStyleMapSet.Clear();
515 fontStyleMapSet.Insert( "weight", "normal" );
516 fontStyleMapSet.Insert( "slant", "oblique" );
517 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
518 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
519 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
520 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
522 fontStyleMapSet.Clear();
523 fontStyleMapSet.Insert( "slant", "roman" );
524 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
525 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
527 // Replace 'roman' for 'normal'.
528 slantValue = fontStyleMapGet.Find( "slant" );
529 if( NULL != slantValue )
531 if( "normal" == slantValue->Get<std::string>() )
533 fontStyleMapGet["slant"] = "roman";
536 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
537 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
539 fontStyleMapSet.Clear();
541 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
542 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
543 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
544 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
546 // Check that the Alignment properties can be correctly set
547 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
548 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
550 // Check scroll properties.
551 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
552 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
553 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
554 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
556 // Check cursor properties
557 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
558 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
559 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
560 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
562 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
563 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
564 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
565 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
566 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
567 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
568 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
569 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
571 // Check handle images
572 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
573 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
574 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
575 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
576 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
578 // Check handle images
579 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
580 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
581 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
582 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
583 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
584 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
586 // Check the highlight color
587 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
588 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
590 // Decoration bounding box
591 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
592 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
594 // Check the enable markup property.
595 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
596 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
597 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
599 // Check input color property.
600 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
601 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
603 // Check input font properties.
604 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
605 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
607 fontStyleMapSet.Clear();
608 fontStyleMapSet.Insert( "weight", "bold" );
609 fontStyleMapSet.Insert( "width", "condensed" );
610 fontStyleMapSet.Insert( "slant", "italic" );
612 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
613 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
614 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
615 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
617 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
618 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
620 // Reset input font style.
621 fontStyleMapSet.Clear();
622 fontStyleMapSet.Insert( "weight", "normal" );
623 fontStyleMapSet.Insert( "slant", "oblique" );
625 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
626 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
627 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
628 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
630 fontStyleMapSet.Clear();
631 fontStyleMapSet.Insert( "slant", "roman" );
633 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
634 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
636 // Replace 'roman' for 'normal'.
637 slantValue = fontStyleMapGet.Find( "slant" );
638 if( NULL != slantValue )
640 if( "normal" == slantValue->Get<std::string>() )
642 fontStyleMapGet["slant"] = "roman";
645 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
646 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
648 fontStyleMapSet.Clear();
650 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
651 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
652 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
653 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
655 // Check the line spacing property
656 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
658 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
660 // Check the input line spacing property
661 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
662 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
663 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
665 // Check the underline property
667 Property::Map underlineMapSet;
668 Property::Map underlineMapGet;
670 underlineMapSet.Insert( "enable", true );
671 underlineMapSet.Insert( "color", Color::RED );
672 underlineMapSet.Insert( "height", 1 );
674 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
676 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
677 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
678 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
680 // Check the input underline property
681 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
682 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
684 // Check the shadow property
685 Property::Map shadowMapSet;
686 Property::Map shadowMapGet;
688 shadowMapSet.Insert( "color", Color::GREEN );
689 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
690 shadowMapSet.Insert( "blurRadius", 3.0f );
692 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
694 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
695 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
696 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
698 // Check the input shadow property
699 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
700 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
702 // Check the emboss property
703 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
704 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
706 // Check the input emboss property
707 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
708 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
710 // Check the outline property
712 // Test string type first
713 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
714 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
715 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
717 // Then test the property map type
718 Property::Map outlineMapSet;
719 Property::Map outlineMapGet;
721 outlineMapSet["color"] = Color::RED;
722 outlineMapSet["width"] = 2.0f;
724 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
726 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
727 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
728 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
730 // Check the input outline property
731 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
732 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
734 // Check the smooth scroll property
735 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
736 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
737 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
739 // Check the smooth scroll duration property
740 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
741 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
743 // Check the scroll bar property
744 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
745 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
746 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
748 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
749 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
750 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
751 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
753 // Check the pixel size of font
754 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
755 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
757 // Check placeholder text properties.
758 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
759 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
761 // Check placeholder text's color property.
762 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
763 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
765 // Check the enable selection property
766 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
767 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
769 // Check the placeholder property with pixel size
770 Property::Map placeholderPixelSizeMapSet;
771 Property::Map placeholderPixelSizeMapGet;
772 Property::Map placeholderFontstyleMap;
773 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
774 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
775 placeholderPixelSizeMapSet["color"] = Color::BLUE;
776 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
777 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
779 placeholderFontstyleMap.Insert( "weight", "bold" );
780 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
781 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
783 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
784 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
786 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
787 Property::Map placeholderConversionMap;
788 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
789 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
790 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
791 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
792 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
793 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
795 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
797 // Check the placeholder property with point size
798 Property::Map placeholderMapSet;
799 Property::Map placeholderMapGet;
800 placeholderMapSet["text"] = "Setting Placeholder Text";
801 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
802 placeholderMapSet["color"] = Color::RED;
803 placeholderMapSet["fontFamily"] = "Arial";
804 placeholderMapSet["pointSize"] = 12.0f;
805 // Check the placeholder font style property
806 placeholderFontstyleMap.Clear();
808 placeholderFontstyleMap.Insert( "weight", "bold" );
809 placeholderFontstyleMap.Insert( "width", "condensed" );
810 placeholderFontstyleMap.Insert( "slant", "italic" );
811 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
812 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
814 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
815 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
817 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
818 placeholderConversionMap.Clear();
819 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
820 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
821 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
822 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
823 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
824 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
825 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
828 placeholderFontstyleMap.Clear();
829 placeholderFontstyleMap.Insert( "weight", "normal" );
830 placeholderFontstyleMap.Insert( "slant", "oblique" );
831 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
832 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
834 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
835 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
836 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
837 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
839 placeholderFontstyleMap.Clear();
840 placeholderFontstyleMap.Insert( "slant", "roman" );
841 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
842 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
844 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
846 placeholderFontstyleMap.Clear();
847 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
849 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
850 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
851 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
852 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
853 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
855 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
856 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
858 application.SendNotification();
859 application.Render();
864 // Positive Atlas Text Renderer test
865 int utcDaliTextEditorAtlasRenderP(void)
867 ToolkitTestApplication application;
868 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
869 StyleManager styleManager = StyleManager::Get();
870 styleManager.ApplyDefaultTheme();
871 TextEditor editor = TextEditor::New();
872 DALI_TEST_CHECK( editor );
874 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
876 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
878 Stage::GetCurrent().Add( editor );
882 // Render some text with the shared atlas backend
883 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
884 application.SendNotification();
885 application.Render();
889 tet_result(TET_FAIL);
894 // Positive test for the textChanged signal.
895 int utcDaliTextEditorTextChangedP(void)
897 ToolkitTestApplication application;
898 tet_infoline(" utcDaliTextEditorTextChangedP");
899 TextEditor editor = TextEditor::New();
900 DALI_TEST_CHECK( editor );
902 Stage::GetCurrent().Add( editor );
904 // connect to the text changed signal.
905 ConnectionTracker* testTracker = new ConnectionTracker();
906 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
907 bool textChangedSignal = false;
908 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
910 gTextChangedCallBackCalled = false;
911 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
912 DALI_TEST_CHECK( gTextChangedCallBackCalled );
913 DALI_TEST_CHECK( textChangedSignal );
915 application.SendNotification();
917 editor.SetKeyInputFocus();
919 gTextChangedCallBackCalled = false;
920 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
921 DALI_TEST_CHECK( gTextChangedCallBackCalled );
926 int utcDaliTextEditorInputStyleChanged01(void)
928 // The text-editor emits signals when the input style changes. These changes of style are
929 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
930 // can't be emitted during the size negotiation as the callbacks may update the UI.
931 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
932 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
933 ToolkitTestApplication application;
934 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
938 char* pathNamePtr = get_current_dir_name();
939 const std::string pathName( pathNamePtr );
942 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
943 fontClient.SetDpi( 93u, 93u );
945 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
946 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
948 TextEditor editor = TextEditor::New();
949 DALI_TEST_CHECK( editor );
952 editor.SetSize( 300.f, 50.f );
953 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
954 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
956 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
957 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
959 // connect to the text changed signal.
960 ConnectionTracker* testTracker = new ConnectionTracker();
961 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
962 bool inputStyleChangedSignal = false;
963 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
965 Stage::GetCurrent().Add( editor );
968 application.SendNotification();
969 application.Render();
971 // Executes the idle callbacks added by the text control on the change of input style.
972 application.RunIdles();
974 gInputStyleChangedCallbackCalled = false;
975 gInputStyleMask = TextEditor::InputStyle::NONE;
976 inputStyleChangedSignal = false;
978 // Create a tap event to touch the text editor.
979 TestGenerateTap( application, 18.0f, 25.0f );
982 application.SendNotification();
983 application.Render();
985 // Executes the idle callbacks added by the text control on the change of input style.
986 application.RunIdles();
988 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
989 if( gInputStyleChangedCallbackCalled )
991 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
993 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
994 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
996 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
997 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
999 DALI_TEST_CHECK( inputStyleChangedSignal );
1001 gInputStyleChangedCallbackCalled = false;
1002 gInputStyleMask = TextEditor::InputStyle::NONE;
1003 inputStyleChangedSignal = false;
1005 // Create a tap event to touch the text editor.
1006 TestGenerateTap( application, 30.0f, 25.0f );
1008 // Render and notify
1009 application.SendNotification();
1010 application.Render();
1012 // Executes the idle callbacks added by the text control on the change of input style.
1013 application.RunIdles();
1015 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1016 DALI_TEST_CHECK( !inputStyleChangedSignal );
1018 gInputStyleChangedCallbackCalled = false;
1019 gInputStyleMask = TextEditor::InputStyle::NONE;
1020 inputStyleChangedSignal = false;
1022 // Create a tap event to touch the text editor.
1023 TestGenerateTap( application, 43.0f, 25.0f );
1025 // Render and notify
1026 application.SendNotification();
1027 application.Render();
1029 // Executes the idle callbacks added by the text control on the change of input style.
1030 application.RunIdles();
1032 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1033 if( gInputStyleChangedCallbackCalled )
1035 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1037 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1038 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1040 DALI_TEST_CHECK( inputStyleChangedSignal );
1042 gInputStyleChangedCallbackCalled = false;
1043 gInputStyleMask = TextEditor::InputStyle::NONE;
1044 inputStyleChangedSignal = false;
1046 // Create a tap event to touch the text editor.
1047 TestGenerateTap( application, 88.0f, 25.0f );
1049 // Render and notify
1050 application.SendNotification();
1051 application.Render();
1053 // Executes the idle callbacks added by the text control on the change of input style.
1054 application.RunIdles();
1056 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1057 if( gInputStyleChangedCallbackCalled )
1059 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1061 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1062 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1064 Property::Map fontStyleMapSet;
1065 Property::Map fontStyleMapGet;
1067 fontStyleMapSet.Insert( "weight", "bold" );
1069 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1070 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1071 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1073 DALI_TEST_CHECK( inputStyleChangedSignal );
1075 gInputStyleChangedCallbackCalled = false;
1076 gInputStyleMask = TextEditor::InputStyle::NONE;
1077 inputStyleChangedSignal = false;
1079 // Create a tap event to touch the text editor.
1080 TestGenerateTap( application, 115.0f, 25.0f );
1082 // Render and notify
1083 application.SendNotification();
1084 application.Render();
1086 // Executes the idle callbacks added by the text control on the change of input style.
1087 application.RunIdles();
1089 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1090 DALI_TEST_CHECK( !inputStyleChangedSignal );
1092 gInputStyleChangedCallbackCalled = false;
1093 gInputStyleMask = TextEditor::InputStyle::NONE;
1094 inputStyleChangedSignal = false;
1096 // Create a tap event to touch the text editor.
1097 TestGenerateTap( application, 164.0f, 25.0f );
1099 // Render and notify
1100 application.SendNotification();
1101 application.Render();
1103 // Executes the idle callbacks added by the text control on the change of input style.
1104 application.RunIdles();
1106 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1107 if( gInputStyleChangedCallbackCalled )
1109 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1111 Property::Map fontStyleMapSet;
1112 Property::Map fontStyleMapGet;
1114 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1115 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1116 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1118 DALI_TEST_CHECK( inputStyleChangedSignal );
1120 gInputStyleChangedCallbackCalled = false;
1121 gInputStyleMask = TextEditor::InputStyle::NONE;
1122 inputStyleChangedSignal = false;
1124 // Create a tap event to touch the text editor.
1125 TestGenerateTap( application, 191.0f, 25.0f );
1127 // Render and notify
1128 application.SendNotification();
1129 application.Render();
1131 // Executes the idle callbacks added by the text control on the change of input style.
1132 application.RunIdles();
1134 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1135 DALI_TEST_CHECK( !inputStyleChangedSignal );
1140 int utcDaliTextEditorInputStyleChanged02(void)
1142 // The text-editor emits signals when the input style changes. These changes of style are
1143 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1144 // can't be emitted during the size negotiation as the callbacks may update the UI.
1145 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1146 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1147 ToolkitTestApplication application;
1148 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1152 char* pathNamePtr = get_current_dir_name();
1153 const std::string pathName( pathNamePtr );
1154 free( pathNamePtr );
1156 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1157 fontClient.SetDpi( 93u, 93u );
1159 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1160 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1162 TextEditor editor = TextEditor::New();
1163 DALI_TEST_CHECK( editor );
1166 editor.SetSize( 300.f, 50.f );
1167 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1168 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1170 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1171 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>" );
1173 // connect to the text changed signal.
1174 ConnectionTracker* testTracker = new ConnectionTracker();
1175 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1176 bool inputStyleChangedSignal = false;
1177 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1179 Stage::GetCurrent().Add( editor );
1181 // Render and notify
1182 application.SendNotification();
1183 application.Render();
1185 // Executes the idle callbacks added by the text control on the change of input style.
1186 application.RunIdles();
1188 gInputStyleChangedCallbackCalled = false;
1189 gInputStyleMask = TextEditor::InputStyle::NONE;
1190 inputStyleChangedSignal = false;
1192 // Create a tap event to touch the text editor.
1193 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1194 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1196 // Render and notify
1197 application.SendNotification();
1198 application.Render();
1200 // Executes the idle callbacks added by the text control on the change of input style.
1201 application.RunIdles();
1203 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1204 if( gInputStyleChangedCallbackCalled )
1206 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1207 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1208 TextEditor::InputStyle::POINT_SIZE |
1209 TextEditor::InputStyle::COLOR ),
1212 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1213 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1215 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1216 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1218 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1219 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1221 DALI_TEST_CHECK( inputStyleChangedSignal );
1223 gInputStyleChangedCallbackCalled = false;
1224 gInputStyleMask = TextEditor::InputStyle::NONE;
1225 inputStyleChangedSignal = false;
1227 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1229 // Render and notify
1230 application.SendNotification();
1231 application.Render();
1233 // Executes the idle callbacks added by the text control on the change of input style.
1234 application.RunIdles();
1236 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1237 if( gInputStyleChangedCallbackCalled )
1239 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1240 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1243 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1244 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1246 DALI_TEST_CHECK( inputStyleChangedSignal );
1248 gInputStyleChangedCallbackCalled = false;
1249 gInputStyleMask = TextEditor::InputStyle::NONE;
1250 inputStyleChangedSignal = false;
1252 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1254 // Render and notify
1255 application.SendNotification();
1256 application.Render();
1258 // Executes the idle callbacks added by the text control on the change of input style.
1259 application.RunIdles();
1261 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1262 DALI_TEST_CHECK( !inputStyleChangedSignal );
1264 gInputStyleChangedCallbackCalled = false;
1265 gInputStyleMask = TextEditor::InputStyle::NONE;
1266 inputStyleChangedSignal = false;
1268 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1270 // Render and notify
1271 application.SendNotification();
1272 application.Render();
1274 // Executes the idle callbacks added by the text control on the change of input style.
1275 application.RunIdles();
1277 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1278 if( gInputStyleChangedCallbackCalled )
1280 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1281 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1284 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1285 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1287 DALI_TEST_CHECK( inputStyleChangedSignal );
1289 gInputStyleChangedCallbackCalled = false;
1290 gInputStyleMask = TextEditor::InputStyle::NONE;
1291 inputStyleChangedSignal = false;
1293 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1295 Property::Map fontStyleMapSet;
1296 fontStyleMapSet.Insert( "weight", "thin" );
1297 fontStyleMapSet.Insert( "width", "condensed" );
1298 fontStyleMapSet.Insert( "slant", "italic" );
1300 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1301 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1302 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1304 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1305 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1306 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1307 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1309 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1311 // Render and notify
1312 application.SendNotification();
1313 application.Render();
1315 // Executes the idle callbacks added by the text control on the change of input style.
1316 application.RunIdles();
1318 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1319 DALI_TEST_CHECK( !inputStyleChangedSignal );
1321 // Create a tap event to touch the text editor.
1322 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1324 // Render and notify
1325 application.SendNotification();
1326 application.Render();
1328 // Executes the idle callbacks added by the text control on the change of input style.
1329 application.RunIdles();
1331 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1332 if( gInputStyleChangedCallbackCalled )
1334 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1335 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1336 TextEditor::InputStyle::POINT_SIZE |
1337 TextEditor::InputStyle::FONT_STYLE |
1338 TextEditor::InputStyle::LINE_SPACING |
1339 TextEditor::InputStyle::UNDERLINE |
1340 TextEditor::InputStyle::SHADOW |
1341 TextEditor::InputStyle::EMBOSS |
1342 TextEditor::InputStyle::OUTLINE ),
1345 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1346 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1348 DALI_TEST_CHECK( inputStyleChangedSignal );
1350 gInputStyleChangedCallbackCalled = false;
1351 gInputStyleMask = TextEditor::InputStyle::NONE;
1352 inputStyleChangedSignal = false;
1354 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1356 fontStyleMapSet.Clear();
1357 fontStyleMapSet.Insert( "weight", "black" );
1358 fontStyleMapSet.Insert( "width", "expanded" );
1359 fontStyleMapSet.Insert( "slant", "oblique" );
1361 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1363 // Create a tap event to touch the text editor.
1364 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1366 // Render and notify
1367 application.SendNotification();
1368 application.Render();
1370 // Executes the idle callbacks added by the text control on the change of input style.
1371 application.RunIdles();
1373 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1374 if( gInputStyleChangedCallbackCalled )
1376 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1377 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1378 TextEditor::InputStyle::POINT_SIZE |
1379 TextEditor::InputStyle::FONT_STYLE ),
1382 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1383 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1385 DALI_TEST_CHECK( inputStyleChangedSignal );
1390 int utcDaliTextEditorEvent01(void)
1392 ToolkitTestApplication application;
1393 tet_infoline(" utcDaliTextEditorEvent01");
1395 // Creates a tap event. After creating a tap event the text editor should
1396 // have the focus and add text with key events should be possible.
1398 TextEditor editor = TextEditor::New();
1399 DALI_TEST_CHECK( editor );
1401 Stage::GetCurrent().Add( editor );
1403 editor.SetSize( 300.f, 50.f );
1404 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1405 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1407 // Avoid a crash when core load gl resources.
1408 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1410 // Render and notify
1411 application.SendNotification();
1412 application.Render();
1414 // Add a key event but as the text editor has not the focus it should do nothing.
1415 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1417 // Render and notify
1418 application.SendNotification();
1419 application.Render();
1421 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1423 // Create a tap event to touch the text editor.
1424 TestGenerateTap( application, 150.0f, 25.0f );
1426 // Render and notify
1427 application.SendNotification();
1428 application.Render();
1430 // Now the text editor has the focus, so it can handle the key events.
1431 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1432 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1434 // Render and notify
1435 application.SendNotification();
1436 application.Render();
1438 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1440 // Create a second text editor and send key events to it.
1441 TextEditor editor2 = TextEditor::New();
1443 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1444 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1445 editor2.SetSize( 100.f, 100.f );
1446 editor2.SetPosition( 100.f, 100.f );
1448 Stage::GetCurrent().Add( editor2 );
1450 // Render and notify
1451 application.SendNotification();
1452 application.Render();
1454 // Create a tap event on the second text editor.
1455 TestGenerateTap( application, 150.0f, 125.0f );
1457 // Render and notify
1458 application.SendNotification();
1459 application.Render();
1461 // The second text editor has the focus. It should handle the key events.
1462 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1463 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1465 // Render and notify
1466 application.SendNotification();
1467 application.Render();
1469 // Check the text has been added to the second text editor.
1470 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1475 int utcDaliTextEditorEvent02(void)
1477 ToolkitTestApplication application;
1478 tet_infoline(" utcDaliTextEditorEvent02");
1480 // Checks if the right number of actors are created.
1482 TextEditor editor = TextEditor::New();
1483 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1484 DALI_TEST_CHECK( editor );
1486 Stage::GetCurrent().Add( editor );
1488 editor.SetSize( 300.f, 50.f );
1489 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1490 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1492 // Avoid a crash when core load gl resources.
1493 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1495 // Render and notify
1496 application.SendNotification();
1497 application.Render();
1499 // Check there are the expected number of children (the stencil).
1500 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1502 Actor stencil = editor.GetChildAt( 0u );
1504 // Create a tap event to touch the text editor.
1505 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1507 // Render and notify
1508 application.SendNotification();
1509 application.Render();
1511 Actor layer = editor.GetChildAt( 1u );
1512 DALI_TEST_CHECK( layer.IsLayer() );
1514 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1515 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1517 // Now the text editor has the focus, so it can handle the key events.
1518 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1519 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1521 // Render and notify
1522 application.SendNotification();
1523 application.Render();
1525 // Checks the cursor and the renderer have been created.
1526 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1527 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1529 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1530 DALI_TEST_CHECK( cursor );
1532 // The stencil actor has a container with all the actors which contain the text renderers.
1533 Actor container = stencil.GetChildAt( 0u );
1534 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1536 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1537 DALI_TEST_CHECK( renderer );
1540 // Move the cursor and check the position changes.
1541 Vector3 position1 = cursor.GetCurrentPosition();
1543 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1544 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1546 // Render and notify
1547 application.SendNotification();
1548 application.Render();
1550 Vector3 position2 = cursor.GetCurrentPosition();
1552 DALI_TEST_CHECK( position2.x < position1.x );
1554 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1555 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1557 // Render and notify
1558 application.SendNotification();
1559 application.Render();
1561 Vector3 position3 = cursor.GetCurrentPosition();
1563 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1565 // Send some taps and check the cursor positions.
1567 // Try to tap at the beginning.
1568 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1570 // Render and notify
1571 application.SendNotification();
1572 application.Render();
1574 // Cursor position should be the same than position1.
1575 Vector3 position4 = cursor.GetCurrentPosition();
1577 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1579 // Tap away from the start position.
1580 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 Vector3 position5 = cursor.GetCurrentPosition();
1588 DALI_TEST_CHECK( position5.x > position4.x );
1590 // Remove all the text.
1591 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1592 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1593 editor.SetProperty( TextEditor::Property::TEXT, "" );
1595 // Render and notify
1596 application.SendNotification();
1597 application.Render();
1599 // Cursor position should be the same than position2.
1600 Vector3 position6 = cursor.GetCurrentPosition();
1602 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1604 // Should not be a renderer.
1605 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1610 int utcDaliTextEditorEvent03(void)
1612 ToolkitTestApplication application;
1613 tet_infoline(" utcDaliTextEditorEvent03");
1615 // Checks if the highlight actor is created.
1617 TextEditor editor = TextEditor::New();
1618 DALI_TEST_CHECK( editor );
1620 Stage::GetCurrent().Add( editor );
1622 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1623 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1624 editor.SetSize( 30.f, 50.f );
1625 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1626 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1628 // Avoid a crash when core load gl resources.
1629 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1631 // Render and notify
1632 application.SendNotification();
1633 application.Render();
1635 // Send some taps and check text controller with clipboard window
1636 Dali::Clipboard clipboard = Clipboard::Get();
1637 clipboard.ShowClipboard();
1638 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1639 clipboard.HideClipboard();
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Tap first to get the focus.
1646 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1648 // Render and notify
1649 application.SendNotification();
1650 application.Render();
1652 // Double tap to select a word.
1653 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 // The stencil actor should have two actors: the renderer and the highlight actor.
1660 Actor stencil = editor.GetChildAt( 0u );
1662 // Highlight needs to be drawn before text, so should come first in child order
1663 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1664 DALI_TEST_CHECK( highlight );
1666 // The stencil actor has a container with all the actors which contain the text renderers.
1667 Actor container = stencil.GetChildAt( 1u );
1668 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1670 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1671 DALI_TEST_CHECK( renderer );
1674 // Double tap out of bounds
1675 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1676 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1678 // Render and notify
1679 application.SendNotification();
1680 application.Render();
1682 // The stencil actor should have one actors: the renderer actor.
1683 stencil = editor.GetChildAt( 0u );
1685 // The stencil actor has a container with all the actors which contain the text renderers.
1686 container = stencil.GetChildAt( 0u );
1687 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1689 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1690 DALI_TEST_CHECK( renderer );
1694 TestGenerateLongPress(application, 1.0f, 25.0f);
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1703 int utcDaliTextEditorEvent04(void)
1705 ToolkitTestApplication application;
1706 tet_infoline(" utcDaliTextEditorEvent04");
1708 // Checks if the highlight actor is created.
1710 TextEditor editor = TextEditor::New();
1711 DALI_TEST_CHECK( editor );
1713 Stage::GetCurrent().Add( editor );
1715 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1716 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1717 editor.SetSize( 100.f, 50.f );
1718 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1719 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1721 // Avoid a crash when core load gl resources.
1722 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1724 // Render and notify
1725 application.SendNotification();
1726 application.Render();
1728 // Tap on the text editor
1729 TestGenerateTap( application, 3.0f, 25.0f );
1731 // Render and notify
1732 application.SendNotification();
1733 application.Render();
1735 // Move at the end of the text.
1736 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1737 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 for( unsigned int index = 0u; index < 10u; ++index )
1745 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1746 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1754 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1756 // Render and notify
1757 application.SendNotification();
1758 application.Render();
1760 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1762 // Add some key events
1763 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1764 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1766 // Render and notify
1767 application.SendNotification();
1768 application.Render();
1770 for( unsigned int index = 0u; index < 10u; ++index )
1772 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1781 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1783 // Render and notify
1784 application.SendNotification();
1785 application.Render();
1787 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1792 int utcDaliTextEditorEvent05(void)
1794 ToolkitTestApplication application;
1795 tet_infoline(" utcDaliTextEditorEvent05");
1797 // Checks if the highlight actor is created.
1799 TextEditor editor = TextEditor::New();
1800 DALI_TEST_CHECK( editor );
1802 Stage::GetCurrent().Add( editor );
1804 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1805 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1806 editor.SetSize( 50.f, 50.f );
1807 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1808 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1809 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1810 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1811 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1812 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1813 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1815 // Avoid a crash when core load gl resources.
1816 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1818 // Render and notify
1819 application.SendNotification();
1820 application.Render();
1822 // Tap on the text editor
1823 TestGenerateTap( application, 3.0f, 25.0f );
1825 // Render and notify
1826 application.SendNotification();
1827 application.Render();
1829 // Move at the end of the text.
1830 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1831 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1833 // Render and notify
1834 application.SendNotification();
1835 application.Render();
1837 for( unsigned int index = 0u; index < 10u; ++index )
1840 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 // Modify duration after scroll is enabled
1847 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1849 // Continuous scroll left to increase coverage
1850 for( unsigned int index = 0u; index < 10u; ++index )
1852 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1854 // Render and notify
1855 application.SendNotification();
1856 application.Render();
1858 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1859 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1860 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1861 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1862 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1864 // Press Escape to increase coverage
1865 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 application.SendNotification();
1867 application.Render();
1869 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1874 int utcDaliTextEditorEvent06(void)
1876 ToolkitTestApplication application;
1877 tet_infoline(" utcDaliTextEditorEvent06");
1879 // Checks if the highlight actor is created.
1881 TextEditor editor = TextEditor::New();
1882 DALI_TEST_CHECK( editor );
1884 Stage::GetCurrent().Add( editor );
1886 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1887 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1888 editor.SetSize( 100.f, 50.f );
1889 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1890 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1892 // Avoid a crash when core load gl resources.
1893 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1895 // Render and notify
1896 application.SendNotification();
1897 application.Render();
1899 // Tap on the text editor
1900 TestGenerateTap( application, 3.0f, 25.0f );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1906 // Move to seconds line of the text.
1907 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1909 // Render and notify
1910 application.SendNotification();
1911 application.Render();
1913 float layoutHeight = editor.GetHeightForWidth( 100.f );
1916 // Add another script characters ( glyph height is defferent )
1917 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1918 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1920 // Delete characters
1921 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1922 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1924 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1926 // Render and notify
1927 application.SendNotification();
1928 application.Render();
1930 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1933 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1934 application.SendNotification();
1935 application.Render();
1937 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1938 application.SendNotification();
1939 application.Render();
1941 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1942 application.SendNotification();
1943 application.Render();
1945 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1946 application.SendNotification();
1947 application.Render();
1949 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1950 application.SendNotification();
1951 application.Render();
1953 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1954 application.SendNotification();
1955 application.Render();
1957 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1958 application.SendNotification();
1959 application.Render();
1964 int utcDaliTextEditorEvent07(void)
1966 ToolkitTestApplication application;
1967 tet_infoline(" utcDaliTextEditorEvent07");
1969 // Checks if the highlight actor is created.
1971 TextEditor editor = TextEditor::New();
1972 DALI_TEST_CHECK( editor );
1974 Stage::GetCurrent().Add( editor );
1976 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1977 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1978 editor.SetSize( 100.f, 50.f );
1979 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1980 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1982 // Avoid a crash when core load gl resources.
1983 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 // Tap on the text editor
1990 TestGenerateTap( application, 3.0f, 25.0f );
1992 // Render and notify
1993 application.SendNotification();
1994 application.Render();
1996 // Move to second line of the text.
1997 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1999 // Render and notify
2000 application.SendNotification();
2001 application.Render();
2003 // Select some text in the right of the current cursor position
2004 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2005 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2006 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2007 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2009 // Render and notify
2010 application.SendNotification();
2011 application.Render();
2013 // Cut the selected text
2014 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2015 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 ) );
2017 // Render and notify
2018 application.SendNotification();
2019 application.Render();
2021 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2023 // Select some text in the left of the current cursor position
2024 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2025 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2026 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2027 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2029 // Render and notify
2030 application.SendNotification();
2031 application.Render();
2033 // Copy the selected text
2034 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2035 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 ) );
2037 // Render and notify
2038 application.SendNotification();
2039 application.Render();
2041 // Move the cursor to the third line
2042 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2043 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 // Render and notify
2046 application.SendNotification();
2047 application.Render();
2049 // Paste the selected text at the current cursor position
2050 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 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 ) );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2060 // Disable Shift Selection
2061 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2063 // Test to select some text in the right of the current cursor position
2064 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2067 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2069 // Render and notify
2070 application.SendNotification();
2071 application.Render();
2073 // Cut the selected text
2074 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2075 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 ) );
2077 // Render and notify
2078 application.SendNotification();
2079 application.Render();
2081 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2082 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2084 // Test to select some text in the left of the current cursor position
2085 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2086 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2087 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2088 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2090 // Render and notify
2091 application.SendNotification();
2092 application.Render();
2094 // Copy the selected text
2095 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2096 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 ) );
2098 // Render and notify
2099 application.SendNotification();
2100 application.Render();
2102 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2103 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2108 int utcDaliTextEditorEvent08(void)
2110 ToolkitTestApplication application;
2111 tet_infoline(" utcDaliTextEditorEvent08");
2113 // Checks if the highlight actor is released correctly.
2115 TextEditor editor = TextEditor::New();
2116 DALI_TEST_CHECK( editor );
2118 Stage::GetCurrent().Add( editor );
2120 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2121 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2122 editor.SetSize( 100.f, 50.f );
2123 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2124 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2126 // Avoid a crash when core load gl resources.
2127 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2129 // Render and notify
2130 application.SendNotification();
2131 application.Render();
2133 // Tap on the text editor
2134 TestGenerateTap( application, 3.0f, 25.0f );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2141 // Test to select some text in the left of the current cursor position
2142 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2143 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2144 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2145 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 // Test to the left selection handle position and the right selection handle position
2152 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2153 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2154 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2155 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 // Render and notify
2158 application.SendNotification();
2159 application.Render();
2161 // Test to select full text in the left of the current cursor position
2162 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2169 // Render and notify
2170 application.SendNotification();
2171 application.Render();
2173 // Test to release the current full text selection
2174 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2175 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2177 // Render and notify
2178 application.SendNotification();
2179 application.Render();
2181 // Test to move the current cursor position correctly
2182 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2189 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 // Render and notify
2192 application.SendNotification();
2193 application.Render();
2195 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2197 // Test to select some text in the right of the current cursor position
2198 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2199 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2200 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2206 // Test the cursor position with right arrow key
2207 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 // Render and notify
2210 application.SendNotification();
2211 application.Render();
2214 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2216 // Render and notify
2217 application.SendNotification();
2218 application.Render();
2220 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2222 // Test to select some text in the left of the current cursor position
2223 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2224 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2225 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 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 ) );
2229 // Render and notify
2230 application.SendNotification();
2231 application.Render();
2233 // Test the cursor position with left arrow key
2234 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2236 // Render and notify
2237 application.SendNotification();
2238 application.Render();
2241 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2243 // Render and notify
2244 application.SendNotification();
2245 application.Render();
2247 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2249 // Test to select some text in the right of the current cursor position
2250 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2251 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2252 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2253 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2255 // Render and notify
2256 application.SendNotification();
2257 application.Render();
2259 // Test the cursor position with left arrow key
2260 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2262 // Render and notify
2263 application.SendNotification();
2264 application.Render();
2267 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2269 // Render and notify
2270 application.SendNotification();
2271 application.Render();
2273 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2275 // Test to select some text in the left of the current cursor position
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 // Render and notify
2282 application.SendNotification();
2283 application.Render();
2285 // Test the cursor position with right arrow key
2286 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2293 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2295 // Render and notify
2296 application.SendNotification();
2297 application.Render();
2299 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2304 int utcDaliTextEditorHandles(void)
2306 ToolkitTestApplication application;
2307 tet_infoline(" utcDaliTextEditorHandles");
2309 TextEditor editor = TextEditor::New();
2310 DALI_TEST_CHECK( editor );
2312 Stage::GetCurrent().Add( editor );
2314 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2315 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2316 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2317 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2319 Property::Map imagePropertyMap;
2320 imagePropertyMap["type"] = "BufferImage";
2321 imagePropertyMap["width"] = 40;
2322 imagePropertyMap["height"] = 40;
2324 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2325 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2326 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2327 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2329 editor.SetSize( 30.f, 500.f );
2330 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2331 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2333 // Avoid a crash when core load gl resources.
2334 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2336 // Render and notify
2337 application.SendNotification();
2338 application.Render();
2340 // Tap first to get the focus.
2341 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2343 // Render and notify
2344 application.SendNotification();
2345 application.Render();
2347 // Tap to create the grab handle.
2348 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2350 // Render and notify
2351 application.SendNotification();
2352 application.Render();
2354 // Get the active layer where the text's decoration is added.
2355 Actor activeLayer = editor.GetChildAt( 1u );
2357 // Get the handle's actor.
2358 Actor handle = activeLayer.GetChildAt( 1u );
2359 handle.SetSize( 100.f, 100.f );
2361 // Render and notify
2362 application.SendNotification();
2363 application.Render();
2365 // Touch the grab handle to set it as pressed.
2366 Vector2 touchPos( 10.0f, 50.0f );
2367 Dali::Integration::TouchEvent event;
2368 event = Dali::Integration::TouchEvent();
2369 event.AddPoint( GetPointDownInside( touchPos ) );
2370 application.ProcessEvent( event );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 // Release the grab handle.
2377 event = Dali::Integration::TouchEvent();
2378 event.AddPoint( GetPointUpInside( touchPos ) );
2379 application.ProcessEvent( event );
2381 // Render and notify
2382 application.SendNotification();
2383 application.Render();
2385 // Tap first to get the focus.
2386 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2388 // Render and notify
2389 application.SendNotification();
2390 application.Render();
2392 // Double tap to select a word and create the selection handles.
2393 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 touchPos = Vector2( 10.0f, 50.0f );
2401 // Touch the left selection handle to set it as pressed.
2402 event = Dali::Integration::TouchEvent();
2403 event.AddPoint( GetPointDownInside( touchPos ) );
2404 application.ProcessEvent( event );
2406 // Render and notify
2407 application.SendNotification();
2408 application.Render();
2410 // Release the left selection handle.
2411 event = Dali::Integration::TouchEvent();
2412 event.AddPoint( GetPointUpInside( touchPos ) );
2413 application.ProcessEvent( event );
2415 // Render and notify
2416 application.SendNotification();
2417 application.Render();
2422 int utcDaliTextEditorUnderPropertyStringP(void)
2424 ToolkitTestApplication application;
2425 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2426 TextEditor editor = TextEditor::New();
2427 DALI_TEST_CHECK( editor );
2429 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2431 Stage::GetCurrent().Add( editor );
2433 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2434 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2436 tet_infoline("Set underline settings with a map");
2437 // Check the input underline property
2438 Property::Map underlineMapSet;
2439 Property::Map underlineMapGet;
2440 underlineMapSet.Insert( "enable", true );
2441 underlineMapSet.Insert( "color", Color::BLUE );
2442 underlineMapSet.Insert( "height", 2 );
2444 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2445 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2446 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2447 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2449 tet_infoline("Set underline settings with a string");
2450 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2451 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2454 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2456 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2457 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2458 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2459 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2461 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2466 int utcDaliTextEditorShadowPropertyStringP(void)
2468 ToolkitTestApplication application;
2469 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2471 TextEditor editor = TextEditor::New();
2473 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2475 Stage::GetCurrent().Add( editor );
2477 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2479 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2483 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2488 int utcDaliTextEditorFontStylePropertyStringP(void)
2490 ToolkitTestApplication application;
2491 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2493 TextEditor editor = TextEditor::New();
2495 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2497 Stage::GetCurrent().Add( editor );
2499 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2501 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2505 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2510 int utcDaliTextEditorGetPropertyLinecountP(void)
2512 ToolkitTestApplication application;
2514 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2518 TextEditor editor = TextEditor::New();
2519 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2520 editor.SetProperty( TextEditor::Property::TEXT,
2521 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2523 Stage::GetCurrent().Add( editor );
2525 editor.SetSize( 100.0f, 100.0f );
2526 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2527 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2529 editor.SetSize( 50.0f, 100.0f );
2530 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2531 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2536 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2539 ToolkitTestApplication application;
2540 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2542 TextEditor editor = TextEditor::New();
2543 DALI_TEST_CHECK( editor );
2545 Stage::GetCurrent().Add( editor );
2547 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2548 editor.SetSize( 50.f, 50.f );
2549 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2550 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2551 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2552 editor.SetKeyboardFocusable(true);
2554 bool startedCalled = false;
2555 bool finishedCalled = false;
2557 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2558 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2560 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2562 // Render and notify
2563 application.SendNotification();
2564 application.Render();
2566 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2567 application.SendNotification();
2568 application.Render(6000);
2570 application.SendNotification();
2571 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2572 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2577 int UtcDaliToolkitTextEditorTextWrapMode(void)
2579 ToolkitTestApplication application;
2580 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2584 TextEditor editor = TextEditor::New();
2585 editor.SetSize( 150.0f, 300.f );
2586 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2588 Stage::GetCurrent().Add( editor );
2590 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2591 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2593 application.SendNotification();
2594 application.Render();
2596 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2597 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2599 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2600 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2602 application.SendNotification();
2603 application.Render();
2605 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2606 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2608 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2609 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2611 application.SendNotification();
2612 application.Render();
2614 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2615 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2617 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2618 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2620 application.SendNotification();
2621 application.Render();
2623 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2624 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2629 int UtcDaliTextEditorSetPaddingProperty(void)
2631 ToolkitTestApplication application;
2632 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2634 TextEditor editor = TextEditor::New();
2635 DALI_TEST_CHECK( editor );
2636 editor.SetSize( 300.f, 50.f );
2637 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2638 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2639 Stage::GetCurrent().Add( editor );
2641 application.SendNotification();
2642 application.Render();
2644 Vector3 originalSize = editor.GetNaturalSize();
2646 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2648 application.SendNotification();
2649 application.Render();
2651 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2653 Vector3 paddingAddedSize = editor.GetNaturalSize();
2655 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2657 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2662 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2664 ToolkitTestApplication application;
2665 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2667 TextEditor editor = TextEditor::New();
2668 DALI_TEST_CHECK( editor );
2669 editor.SetSize( 300.f, 50.f );
2670 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2671 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2672 Stage::GetCurrent().Add( editor );
2674 application.SendNotification();
2675 application.Render();
2677 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2678 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2680 // Check the enable shift selection property
2681 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2682 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2684 application.SendNotification();
2685 application.Render();
2690 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2692 ToolkitTestApplication application;
2693 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2695 TextEditor editor = TextEditor::New();
2696 DALI_TEST_CHECK( editor );
2697 editor.SetSize( 300.f, 50.f );
2698 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2699 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2700 Stage::GetCurrent().Add( editor );
2702 application.SendNotification();
2703 application.Render();
2705 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2706 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2708 // Check the enable grab handle property
2709 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2710 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2712 application.SendNotification();
2713 application.Render();
2718 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2720 ToolkitTestApplication application;
2721 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2723 TextEditor editor = TextEditor::New();
2724 DALI_TEST_CHECK( editor );
2725 editor.SetSize( 300.f, 50.f );
2726 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2727 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2728 Stage::GetCurrent().Add( editor );
2730 application.SendNotification();
2731 application.Render();
2733 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2734 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2736 // Check the enable match system language direction property
2737 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2738 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2740 application.SendNotification();
2741 application.Render();
2746 int UtcDaliTextEditorGetInputMethodContext(void)
2748 ToolkitTestApplication application;
2749 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2751 TextEditor editor = TextEditor::New();
2752 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );