2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/devel-api/text-abstraction/font-client.h>
25 #include <dali/integration-api/events/key-event-integ.h>
26 #include <dali/integration-api/events/touch-event-integ.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
30 #include <dali-toolkit/devel-api/text/rendering-backend.h>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
101 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
102 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
103 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
106 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
107 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const unsigned int DEFAULT_FONT_SIZE = 1152u;
112 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
114 const int KEY_A_CODE = 38;
115 const int KEY_D_CODE = 40;
116 const int KEY_C_CODE = 54;
117 const int KEY_V_CODE = 55;
118 const int KEY_X_CODE = 53;
119 const int KEY_WHITE_SPACE_CODE = 65;
121 const int KEY_SHIFT_MODIFIER = 257;
122 const int KEY_CONTROL_MODIFIER = 258;
124 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
126 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
128 static bool gTextChangedCallBackCalled;
129 static bool gInputStyleChangedCallbackCalled;
130 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
132 struct CallbackFunctor
134 CallbackFunctor(bool* callbackFlag)
135 : mCallbackFlag( callbackFlag )
141 *mCallbackFlag = true;
146 static void TestTextChangedCallback( TextEditor control )
148 tet_infoline(" TestTextChangedCallback");
150 gTextChangedCallBackCalled = true;
153 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
155 tet_infoline(" TestInputStyleChangedCallback");
157 gInputStyleChangedCallbackCalled = true;
158 gInputStyleMask = mask;
161 // Generate a KeyEvent to send to Core.
162 Integration::KeyEvent GenerateKey( const std::string& keyName,
163 const std::string& logicalKey,
164 const std::string& keyString,
167 unsigned long timeStamp,
168 const Integration::KeyEvent::State& keyState,
169 const std::string& compose = "",
170 const std::string& deviceName = DEFAULT_DEVICE_NAME,
171 const Device::Class::Type& deviceClass = Device::Class::NONE,
172 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
174 return Integration::KeyEvent( keyName,
187 Dali::Integration::Point GetPointDownInside( Vector2& pos )
189 Dali::Integration::Point point;
190 point.SetState( PointState::DOWN );
191 point.SetScreenPosition( pos );
195 Dali::Integration::Point GetPointUpInside( Vector2& pos )
197 Dali::Integration::Point point;
198 point.SetState( PointState::UP );
199 point.SetScreenPosition( pos );
203 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
205 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
207 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
209 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
211 Property::Value* valueSet = NULL;
212 if ( valueGet.first.type == Property::Key::INDEX )
214 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
218 // Get Key is a string so searching Set Map for a string key
219 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
222 if( NULL != valueSet )
224 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
226 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
229 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
231 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
234 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
236 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
239 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
241 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
244 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
246 Vector2 vector2Get = valueGet.second.Get<Vector2>();
247 Vector2 vector2Set = valueSet->Get<Vector2>();
248 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
251 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
253 Vector4 vector4Get = valueGet.second.Get<Vector4>();
254 Vector4 vector4Set = valueSet->Get<Vector4>();
255 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 );
261 if ( valueGet.first.type == Property::Key::INDEX )
263 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
267 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
277 class ScrollStateChangeCallback : public Dali::ConnectionTracker
280 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
281 : mStartedCalled( startedCalled ),
282 mFinishedCalled( finishedCalled )
286 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
288 if( type == TextEditor::Scroll::STARTED )
290 mStartedCalled = true;
292 else if( type == TextEditor::Scroll::FINISHED )
294 mFinishedCalled = true;
298 bool& mStartedCalled;
299 bool& mFinishedCalled;
304 int UtcDaliToolkitTextEditorConstructorP(void)
306 ToolkitTestApplication application;
307 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
308 TextEditor textEditor;
309 DALI_TEST_CHECK( !textEditor );
313 int UtcDaliToolkitTextEditorNewP(void)
315 ToolkitTestApplication application;
316 tet_infoline(" UtcDaliToolkitTextEditorNewP");
317 TextEditor textEditor = TextEditor::New();
318 DALI_TEST_CHECK( textEditor );
322 int UtcDaliToolkitTextEditorDownCastP(void)
324 ToolkitTestApplication application;
325 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
326 TextEditor textEditor1 = TextEditor::New();
327 BaseHandle object( textEditor1 );
329 TextEditor textEditor2 = TextEditor::DownCast( object );
330 DALI_TEST_CHECK( textEditor2 );
332 TextEditor textEditor3 = DownCast< TextEditor >( object );
333 DALI_TEST_CHECK( textEditor3 );
337 int UtcDaliToolkitTextEditorDownCastN(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
341 BaseHandle uninitializedObject;
342 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
343 DALI_TEST_CHECK( !textEditor1 );
345 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
346 DALI_TEST_CHECK( !textEditor2 );
350 int UtcDaliToolkitTextEditorCopyConstructorP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
354 TextEditor textEditor = TextEditor::New();
355 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
357 TextEditor copy( textEditor );
358 DALI_TEST_CHECK( copy );
359 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
363 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
365 ToolkitTestApplication application;
366 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
367 TextEditor textEditor = TextEditor::New();
368 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
370 TextEditor copy = textEditor;
371 DALI_TEST_CHECK( copy );
372 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
376 int UtcDaliTextEditorNewP(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextEditorNewP");
380 TextEditor textEditor = TextEditor::New();
381 DALI_TEST_CHECK( textEditor );
385 // Positive test case for a method
386 int UtcDaliTextEditorGetPropertyP(void)
388 ToolkitTestApplication application;
389 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
390 TextEditor editor = TextEditor::New();
391 DALI_TEST_CHECK( editor );
393 // Check Property Indices are correct
394 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextEditor::Property::RENDERING_BACKEND );
395 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
396 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
397 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
398 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
399 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
400 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
401 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
402 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
403 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
404 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
405 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
406 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
407 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
408 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
409 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
410 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
411 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
412 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
413 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
414 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
415 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
416 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
417 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
453 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
456 Property::Map imageMap;
457 imageMap[mapKey] =mapValue;
459 editor.SetProperty( property , imageMap );
460 Property::Value propValue = editor.GetProperty( property );
461 Property::Map* resultMap = propValue.GetMap();
463 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
471 // Positive test case for a method
472 int UtcDaliTextEditorSetPropertyP(void)
474 ToolkitTestApplication application;
475 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
476 TextEditor editor = TextEditor::New();
477 DALI_TEST_CHECK( editor );
478 Stage::GetCurrent().Add( editor );
480 // Note - we can't check the defaults since the stylesheets are platform-specific
482 // Check the render backend property.
483 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
484 DALI_TEST_EQUALS( (DevelText::RenderingType)editor.GetProperty<int>( DevelTextEditor::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
486 // Check text property.
487 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
488 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
490 // Check text's color property
491 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
492 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
494 // Check font properties.
495 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
496 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
498 Property::Map fontStyleMapSet;
499 Property::Map fontStyleMapGet;
500 Property::Value* slantValue = NULL;
502 fontStyleMapSet.Insert( "weight", "bold" );
503 fontStyleMapSet.Insert( "width", "condensed" );
504 fontStyleMapSet.Insert( "slant", "italic" );
506 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
507 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
508 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
509 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
511 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
512 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
515 fontStyleMapSet.Clear();
516 fontStyleMapSet.Insert( "weight", "normal" );
517 fontStyleMapSet.Insert( "slant", "oblique" );
518 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
519 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
520 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
521 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
523 fontStyleMapSet.Clear();
524 fontStyleMapSet.Insert( "slant", "roman" );
525 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
526 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
528 // Replace 'roman' for 'normal'.
529 slantValue = fontStyleMapGet.Find( "slant" );
530 if( NULL != slantValue )
532 if( "normal" == slantValue->Get<std::string>() )
534 fontStyleMapGet["slant"] = "roman";
537 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
538 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
540 fontStyleMapSet.Clear();
542 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
543 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
544 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
545 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
547 // Check that the Alignment properties can be correctly set
548 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
549 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
551 // Check scroll properties.
552 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
553 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
554 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
555 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
557 // Check cursor properties
558 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
559 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
560 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
561 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
563 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
564 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
565 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
566 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
567 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
568 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
569 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
570 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
572 // Check handle images
573 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
574 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
575 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
576 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
577 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
579 // Check handle images
580 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
581 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
582 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
583 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
584 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
585 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
587 // Check the highlight color
588 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
589 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
591 // Decoration bounding box
592 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
593 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
595 // Check the enable markup property.
596 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
597 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
598 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
600 // Check input color property.
601 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
602 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
604 // Check input font properties.
605 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
606 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
608 fontStyleMapSet.Clear();
609 fontStyleMapSet.Insert( "weight", "bold" );
610 fontStyleMapSet.Insert( "width", "condensed" );
611 fontStyleMapSet.Insert( "slant", "italic" );
613 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
614 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
615 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
616 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
618 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
619 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
621 // Reset input font style.
622 fontStyleMapSet.Clear();
623 fontStyleMapSet.Insert( "weight", "normal" );
624 fontStyleMapSet.Insert( "slant", "oblique" );
626 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
627 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
628 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
629 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
631 fontStyleMapSet.Clear();
632 fontStyleMapSet.Insert( "slant", "roman" );
634 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
635 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
637 // Replace 'roman' for 'normal'.
638 slantValue = fontStyleMapGet.Find( "slant" );
639 if( NULL != slantValue )
641 if( "normal" == slantValue->Get<std::string>() )
643 fontStyleMapGet["slant"] = "roman";
646 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
647 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
649 fontStyleMapSet.Clear();
651 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
652 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
653 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
654 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
656 // Check the line spacing property
657 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
658 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
659 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 // Check the input line spacing property
662 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
663 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
664 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
666 // Check the underline property
668 Property::Map underlineMapSet;
669 Property::Map underlineMapGet;
671 underlineMapSet.Insert( "enable", true );
672 underlineMapSet.Insert( "color", Color::RED );
673 underlineMapSet.Insert( "height", 1 );
675 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
677 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
678 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
679 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
681 // Check the input underline property
682 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
683 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
685 // Check the shadow property
686 Property::Map shadowMapSet;
687 Property::Map shadowMapGet;
689 shadowMapSet.Insert( "color", Color::GREEN );
690 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
691 shadowMapSet.Insert( "blurRadius", 3.0f );
693 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
695 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
696 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
697 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
699 // Check the input shadow property
700 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
701 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
703 // Check the emboss property
704 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
705 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
707 // Check the input emboss property
708 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
709 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
711 // Check the outline property
713 // Test string type first
714 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
715 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
716 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
718 // Then test the property map type
719 Property::Map outlineMapSet;
720 Property::Map outlineMapGet;
722 outlineMapSet["color"] = Color::RED;
723 outlineMapSet["width"] = 2.0f;
725 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
727 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
728 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
729 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
731 // Check the input outline property
732 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
733 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
735 // Check the smooth scroll property
736 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
737 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
738 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
740 // Check the smooth scroll duration property
741 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
742 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
744 // Check the scroll bar property
745 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
746 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
747 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
749 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
750 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
751 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
752 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 // Check the pixel size of font
755 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
756 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
758 // Check placeholder text properties.
759 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
760 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
762 // Check placeholder text's color property.
763 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
764 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
766 // Check the enable selection property
767 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
768 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
770 // Check the placeholder property with pixel size
771 Property::Map placeholderPixelSizeMapSet;
772 Property::Map placeholderPixelSizeMapGet;
773 Property::Map placeholderFontstyleMap;
774 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
775 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
776 placeholderPixelSizeMapSet["color"] = Color::BLUE;
777 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
778 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
780 placeholderFontstyleMap.Insert( "weight", "bold" );
781 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
782 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
784 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
785 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
787 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
788 Property::Map placeholderConversionMap;
789 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
790 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
791 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
792 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
793 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
794 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
796 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
798 // Check the placeholder property with point size
799 Property::Map placeholderMapSet;
800 Property::Map placeholderMapGet;
801 placeholderMapSet["text"] = "Setting Placeholder Text";
802 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
803 placeholderMapSet["color"] = Color::RED;
804 placeholderMapSet["fontFamily"] = "Arial";
805 placeholderMapSet["pointSize"] = 12.0f;
806 // Check the placeholder font style property
807 placeholderFontstyleMap.Clear();
809 placeholderFontstyleMap.Insert( "weight", "bold" );
810 placeholderFontstyleMap.Insert( "width", "condensed" );
811 placeholderFontstyleMap.Insert( "slant", "italic" );
812 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
813 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
815 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
816 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
818 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
819 placeholderConversionMap.Clear();
820 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
821 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
822 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
823 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
824 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
825 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
826 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
829 placeholderFontstyleMap.Clear();
830 placeholderFontstyleMap.Insert( "weight", "normal" );
831 placeholderFontstyleMap.Insert( "slant", "oblique" );
832 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
833 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
835 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
836 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
837 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
838 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
840 placeholderFontstyleMap.Clear();
841 placeholderFontstyleMap.Insert( "slant", "roman" );
842 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
843 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
845 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
847 placeholderFontstyleMap.Clear();
848 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
850 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
851 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
852 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
853 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
854 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
856 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
857 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
859 application.SendNotification();
860 application.Render();
865 // Positive Atlas Text Renderer test
866 int utcDaliTextEditorAtlasRenderP(void)
868 ToolkitTestApplication application;
869 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
870 StyleManager styleManager = StyleManager::Get();
871 styleManager.ApplyDefaultTheme();
872 TextEditor editor = TextEditor::New();
873 DALI_TEST_CHECK( editor );
875 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
877 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
879 Stage::GetCurrent().Add( editor );
883 // Render some text with the shared atlas backend
884 editor.SetProperty( DevelTextEditor::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
885 application.SendNotification();
886 application.Render();
890 tet_result(TET_FAIL);
895 // Positive test for the textChanged signal.
896 int utcDaliTextEditorTextChangedP(void)
898 ToolkitTestApplication application;
899 tet_infoline(" utcDaliTextEditorTextChangedP");
900 TextEditor editor = TextEditor::New();
901 DALI_TEST_CHECK( editor );
903 Stage::GetCurrent().Add( editor );
905 // connect to the text changed signal.
906 ConnectionTracker* testTracker = new ConnectionTracker();
907 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
908 bool textChangedSignal = false;
909 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
911 gTextChangedCallBackCalled = false;
912 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
913 DALI_TEST_CHECK( gTextChangedCallBackCalled );
914 DALI_TEST_CHECK( textChangedSignal );
916 application.SendNotification();
918 editor.SetKeyInputFocus();
920 gTextChangedCallBackCalled = false;
921 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
922 DALI_TEST_CHECK( gTextChangedCallBackCalled );
927 int utcDaliTextEditorInputStyleChanged01(void)
929 // The text-editor emits signals when the input style changes. These changes of style are
930 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
931 // can't be emitted during the size negotiation as the callbacks may update the UI.
932 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
933 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
934 ToolkitTestApplication application;
935 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
939 char* pathNamePtr = get_current_dir_name();
940 const std::string pathName( pathNamePtr );
943 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
944 fontClient.SetDpi( 93u, 93u );
946 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
947 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
949 TextEditor editor = TextEditor::New();
950 DALI_TEST_CHECK( editor );
953 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
954 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
955 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
957 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
958 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
960 // connect to the text changed signal.
961 ConnectionTracker* testTracker = new ConnectionTracker();
962 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
963 bool inputStyleChangedSignal = false;
964 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
966 Stage::GetCurrent().Add( editor );
969 application.SendNotification();
970 application.Render();
972 // Executes the idle callbacks added by the text control on the change of input style.
973 application.RunIdles();
975 gInputStyleChangedCallbackCalled = false;
976 gInputStyleMask = TextEditor::InputStyle::NONE;
977 inputStyleChangedSignal = false;
979 // Create a tap event to touch the text editor.
980 TestGenerateTap( application, 18.0f, 25.0f );
983 application.SendNotification();
984 application.Render();
986 // Executes the idle callbacks added by the text control on the change of input style.
987 application.RunIdles();
989 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
990 if( gInputStyleChangedCallbackCalled )
992 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
994 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
995 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
997 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
998 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1000 DALI_TEST_CHECK( inputStyleChangedSignal );
1002 gInputStyleChangedCallbackCalled = false;
1003 gInputStyleMask = TextEditor::InputStyle::NONE;
1004 inputStyleChangedSignal = false;
1006 // Create a tap event to touch the text editor.
1007 TestGenerateTap( application, 30.0f, 25.0f );
1009 // Render and notify
1010 application.SendNotification();
1011 application.Render();
1013 // Executes the idle callbacks added by the text control on the change of input style.
1014 application.RunIdles();
1016 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1017 DALI_TEST_CHECK( !inputStyleChangedSignal );
1019 gInputStyleChangedCallbackCalled = false;
1020 gInputStyleMask = TextEditor::InputStyle::NONE;
1021 inputStyleChangedSignal = false;
1023 // Create a tap event to touch the text editor.
1024 TestGenerateTap( application, 43.0f, 25.0f );
1026 // Render and notify
1027 application.SendNotification();
1028 application.Render();
1030 // Executes the idle callbacks added by the text control on the change of input style.
1031 application.RunIdles();
1033 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1034 if( gInputStyleChangedCallbackCalled )
1036 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1038 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1039 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1041 DALI_TEST_CHECK( inputStyleChangedSignal );
1043 gInputStyleChangedCallbackCalled = false;
1044 gInputStyleMask = TextEditor::InputStyle::NONE;
1045 inputStyleChangedSignal = false;
1047 // Create a tap event to touch the text editor.
1048 TestGenerateTap( application, 88.0f, 25.0f );
1050 // Render and notify
1051 application.SendNotification();
1052 application.Render();
1054 // Executes the idle callbacks added by the text control on the change of input style.
1055 application.RunIdles();
1057 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1058 if( gInputStyleChangedCallbackCalled )
1060 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1062 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1063 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1065 Property::Map fontStyleMapSet;
1066 Property::Map fontStyleMapGet;
1068 fontStyleMapSet.Insert( "weight", "bold" );
1070 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1071 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1072 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1074 DALI_TEST_CHECK( inputStyleChangedSignal );
1076 gInputStyleChangedCallbackCalled = false;
1077 gInputStyleMask = TextEditor::InputStyle::NONE;
1078 inputStyleChangedSignal = false;
1080 // Create a tap event to touch the text editor.
1081 TestGenerateTap( application, 115.0f, 25.0f );
1083 // Render and notify
1084 application.SendNotification();
1085 application.Render();
1087 // Executes the idle callbacks added by the text control on the change of input style.
1088 application.RunIdles();
1090 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1091 DALI_TEST_CHECK( !inputStyleChangedSignal );
1093 gInputStyleChangedCallbackCalled = false;
1094 gInputStyleMask = TextEditor::InputStyle::NONE;
1095 inputStyleChangedSignal = false;
1097 // Create a tap event to touch the text editor.
1098 TestGenerateTap( application, 164.0f, 25.0f );
1100 // Render and notify
1101 application.SendNotification();
1102 application.Render();
1104 // Executes the idle callbacks added by the text control on the change of input style.
1105 application.RunIdles();
1107 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1108 if( gInputStyleChangedCallbackCalled )
1110 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1112 Property::Map fontStyleMapSet;
1113 Property::Map fontStyleMapGet;
1115 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1116 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1117 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1119 DALI_TEST_CHECK( inputStyleChangedSignal );
1121 gInputStyleChangedCallbackCalled = false;
1122 gInputStyleMask = TextEditor::InputStyle::NONE;
1123 inputStyleChangedSignal = false;
1125 // Create a tap event to touch the text editor.
1126 TestGenerateTap( application, 191.0f, 25.0f );
1128 // Render and notify
1129 application.SendNotification();
1130 application.Render();
1132 // Executes the idle callbacks added by the text control on the change of input style.
1133 application.RunIdles();
1135 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1136 DALI_TEST_CHECK( !inputStyleChangedSignal );
1141 int utcDaliTextEditorInputStyleChanged02(void)
1143 // The text-editor emits signals when the input style changes. These changes of style are
1144 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1145 // can't be emitted during the size negotiation as the callbacks may update the UI.
1146 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1147 // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1148 ToolkitTestApplication application;
1149 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1153 char* pathNamePtr = get_current_dir_name();
1154 const std::string pathName( pathNamePtr );
1155 free( pathNamePtr );
1157 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1158 fontClient.SetDpi( 93u, 93u );
1160 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1161 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1163 TextEditor editor = TextEditor::New();
1164 DALI_TEST_CHECK( editor );
1167 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1168 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1169 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1171 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1172 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>" );
1174 // connect to the text changed signal.
1175 ConnectionTracker* testTracker = new ConnectionTracker();
1176 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1177 bool inputStyleChangedSignal = false;
1178 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1180 Stage::GetCurrent().Add( editor );
1182 // Render and notify
1183 application.SendNotification();
1184 application.Render();
1186 // Executes the idle callbacks added by the text control on the change of input style.
1187 application.RunIdles();
1189 gInputStyleChangedCallbackCalled = false;
1190 gInputStyleMask = TextEditor::InputStyle::NONE;
1191 inputStyleChangedSignal = false;
1193 // Create a tap event to touch the text editor.
1194 TestGenerateTap( application, 53.0f, 25.0f, 100 );
1195 TestGenerateTap( application, 53.0f, 25.0f, 200 );
1197 // Render and notify
1198 application.SendNotification();
1199 application.Render();
1201 // Executes the idle callbacks added by the text control on the change of input style.
1202 application.RunIdles();
1204 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1205 if( gInputStyleChangedCallbackCalled )
1207 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1208 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1209 TextEditor::InputStyle::POINT_SIZE |
1210 TextEditor::InputStyle::COLOR ),
1213 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1214 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1216 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1217 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1219 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1220 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1222 DALI_TEST_CHECK( inputStyleChangedSignal );
1224 gInputStyleChangedCallbackCalled = false;
1225 gInputStyleMask = TextEditor::InputStyle::NONE;
1226 inputStyleChangedSignal = false;
1228 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1230 // Render and notify
1231 application.SendNotification();
1232 application.Render();
1234 // Executes the idle callbacks added by the text control on the change of input style.
1235 application.RunIdles();
1237 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1238 if( gInputStyleChangedCallbackCalled )
1240 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1241 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1244 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1245 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1247 DALI_TEST_CHECK( inputStyleChangedSignal );
1249 gInputStyleChangedCallbackCalled = false;
1250 gInputStyleMask = TextEditor::InputStyle::NONE;
1251 inputStyleChangedSignal = false;
1253 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1255 // Render and notify
1256 application.SendNotification();
1257 application.Render();
1259 // Executes the idle callbacks added by the text control on the change of input style.
1260 application.RunIdles();
1262 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1263 DALI_TEST_CHECK( !inputStyleChangedSignal );
1265 gInputStyleChangedCallbackCalled = false;
1266 gInputStyleMask = TextEditor::InputStyle::NONE;
1267 inputStyleChangedSignal = false;
1269 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1271 // Render and notify
1272 application.SendNotification();
1273 application.Render();
1275 // Executes the idle callbacks added by the text control on the change of input style.
1276 application.RunIdles();
1278 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1279 if( gInputStyleChangedCallbackCalled )
1281 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1282 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1285 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1286 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1288 DALI_TEST_CHECK( inputStyleChangedSignal );
1290 gInputStyleChangedCallbackCalled = false;
1291 gInputStyleMask = TextEditor::InputStyle::NONE;
1292 inputStyleChangedSignal = false;
1294 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1296 Property::Map fontStyleMapSet;
1297 fontStyleMapSet.Insert( "weight", "thin" );
1298 fontStyleMapSet.Insert( "width", "condensed" );
1299 fontStyleMapSet.Insert( "slant", "italic" );
1301 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1302 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1303 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1305 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1306 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1307 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1308 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1310 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Executes the idle callbacks added by the text control on the change of input style.
1317 application.RunIdles();
1319 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1320 DALI_TEST_CHECK( !inputStyleChangedSignal );
1322 // Create a tap event to touch the text editor.
1323 TestGenerateTap( application, 63.0f, 25.0f, 900 );
1325 // Render and notify
1326 application.SendNotification();
1327 application.Render();
1329 // Executes the idle callbacks added by the text control on the change of input style.
1330 application.RunIdles();
1332 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1333 if( gInputStyleChangedCallbackCalled )
1335 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1336 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1337 TextEditor::InputStyle::POINT_SIZE |
1338 TextEditor::InputStyle::FONT_STYLE |
1339 TextEditor::InputStyle::LINE_SPACING |
1340 TextEditor::InputStyle::UNDERLINE |
1341 TextEditor::InputStyle::SHADOW |
1342 TextEditor::InputStyle::EMBOSS |
1343 TextEditor::InputStyle::OUTLINE ),
1346 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1347 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1349 DALI_TEST_CHECK( inputStyleChangedSignal );
1351 gInputStyleChangedCallbackCalled = false;
1352 gInputStyleMask = TextEditor::InputStyle::NONE;
1353 inputStyleChangedSignal = false;
1355 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1357 fontStyleMapSet.Clear();
1358 fontStyleMapSet.Insert( "weight", "black" );
1359 fontStyleMapSet.Insert( "width", "expanded" );
1360 fontStyleMapSet.Insert( "slant", "oblique" );
1362 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1364 // Create a tap event to touch the text editor.
1365 TestGenerateTap( application, 30.0f, 25.0f, 1500 );
1367 // Render and notify
1368 application.SendNotification();
1369 application.Render();
1371 // Executes the idle callbacks added by the text control on the change of input style.
1372 application.RunIdles();
1374 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1375 if( gInputStyleChangedCallbackCalled )
1377 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1378 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1379 TextEditor::InputStyle::POINT_SIZE |
1380 TextEditor::InputStyle::FONT_STYLE ),
1383 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1384 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1386 DALI_TEST_CHECK( inputStyleChangedSignal );
1391 int utcDaliTextEditorEvent01(void)
1393 ToolkitTestApplication application;
1394 tet_infoline(" utcDaliTextEditorEvent01");
1396 // Creates a tap event. After creating a tap event the text editor should
1397 // have the focus and add text with key events should be possible.
1399 TextEditor editor = TextEditor::New();
1400 DALI_TEST_CHECK( editor );
1402 Stage::GetCurrent().Add( editor );
1404 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1405 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1406 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1408 // Avoid a crash when core load gl resources.
1409 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1411 // Render and notify
1412 application.SendNotification();
1413 application.Render();
1415 // Add a key event but as the text editor has not the focus it should do nothing.
1416 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1418 // Render and notify
1419 application.SendNotification();
1420 application.Render();
1422 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1424 // Create a tap event to touch the text editor.
1425 TestGenerateTap( application, 150.0f, 25.0f );
1427 // Render and notify
1428 application.SendNotification();
1429 application.Render();
1431 // Now the text editor has the focus, so it can handle the key events.
1432 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1433 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1441 // Create a second text editor and send key events to it.
1442 TextEditor editor2 = TextEditor::New();
1444 editor2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1445 editor2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1446 editor2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
1447 editor2.SetProperty( Actor::Property::POSITION, Vector2( 100.f, 100.f ));
1449 Stage::GetCurrent().Add( editor2 );
1451 // Render and notify
1452 application.SendNotification();
1453 application.Render();
1455 // Create a tap event on the second text editor.
1456 TestGenerateTap( application, 150.0f, 125.0f );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 // The second text editor has the focus. It should handle the key events.
1463 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1464 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1466 // Render and notify
1467 application.SendNotification();
1468 application.Render();
1470 // Check the text has been added to the second text editor.
1471 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1476 int utcDaliTextEditorEvent02(void)
1478 ToolkitTestApplication application;
1479 tet_infoline(" utcDaliTextEditorEvent02");
1481 // Checks if the right number of actors are created.
1483 TextEditor editor = TextEditor::New();
1484 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1485 DALI_TEST_CHECK( editor );
1487 Stage::GetCurrent().Add( editor );
1489 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1490 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1491 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1493 // Avoid a crash when core load gl resources.
1494 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1496 // Render and notify
1497 application.SendNotification();
1498 application.Render();
1500 // Check there are the expected number of children (the stencil).
1501 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1503 Actor stencil = editor.GetChildAt( 0u );
1505 // Create a tap event to touch the text editor.
1506 TestGenerateTap( application, 150.0f, 25.0f, 100 );
1508 // Render and notify
1509 application.SendNotification();
1510 application.Render();
1512 Actor layer = editor.GetChildAt( 1u );
1513 DALI_TEST_CHECK( layer.GetProperty< bool >( Actor::Property::IS_LAYER ) );
1515 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1516 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1518 // Now the text editor has the focus, so it can handle the key events.
1519 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1520 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1522 // Render and notify
1523 application.SendNotification();
1524 application.Render();
1526 // Checks the cursor and the renderer have been created.
1527 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1528 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1530 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1531 DALI_TEST_CHECK( cursor );
1533 // The stencil actor has a container with all the actors which contain the text renderers.
1534 Actor container = stencil.GetChildAt( 0u );
1535 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1537 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1538 DALI_TEST_CHECK( renderer );
1541 // Move the cursor and check the position changes.
1542 Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1544 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1545 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1553 DALI_TEST_CHECK( position2.x < position1.x );
1555 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1556 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1558 // Render and notify
1559 application.SendNotification();
1560 application.Render();
1562 Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1564 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1566 // Send some taps and check the cursor positions.
1568 // Try to tap at the beginning.
1569 TestGenerateTap( application, 1.0f, 25.0f, 700 );
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 // Cursor position should be the same than position1.
1576 Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1578 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1580 // Tap away from the start position.
1581 TestGenerateTap( application, 16.0f, 25.0f, 1400 );
1583 // Render and notify
1584 application.SendNotification();
1585 application.Render();
1587 Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1589 DALI_TEST_CHECK( position5.x > position4.x );
1591 // Remove all the text.
1592 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1593 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1594 editor.SetProperty( TextEditor::Property::TEXT, "" );
1596 // Render and notify
1597 application.SendNotification();
1598 application.Render();
1600 // Cursor position should be the same than position2.
1601 Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
1603 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1605 // Should not be a renderer.
1606 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1611 int utcDaliTextEditorEvent03(void)
1613 ToolkitTestApplication application;
1614 tet_infoline(" utcDaliTextEditorEvent03");
1616 // Checks if the highlight actor is created.
1618 TextEditor editor = TextEditor::New();
1619 DALI_TEST_CHECK( editor );
1621 Stage::GetCurrent().Add( editor );
1623 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1624 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1625 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
1626 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1627 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1629 // Avoid a crash when core load gl resources.
1630 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1632 // Render and notify
1633 application.SendNotification();
1634 application.Render();
1636 // Send some taps and check text controller with clipboard window
1637 Dali::Clipboard clipboard = Clipboard::Get();
1638 clipboard.ShowClipboard();
1639 TestGenerateTap( application, 3.0f, 25.0f, 100 );
1640 clipboard.HideClipboard();
1642 // Render and notify
1643 application.SendNotification();
1644 application.Render();
1646 // Tap first to get the focus.
1647 TestGenerateTap( application, 3.0f, 25.0f, 1000 );
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 // Double tap to select a word.
1654 TestGenerateTap( application, 3.0f, 25.0f, 1100 );
1656 // Render and notify
1657 application.SendNotification();
1658 application.Render();
1660 // The stencil actor should have two actors: the renderer and the highlight actor.
1661 Actor stencil = editor.GetChildAt( 0u );
1663 // Highlight needs to be drawn before text, so should come first in child order
1664 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1665 DALI_TEST_CHECK( highlight );
1667 // The stencil actor has a container with all the actors which contain the text renderers.
1668 Actor container = stencil.GetChildAt( 1u );
1669 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1671 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1672 DALI_TEST_CHECK( renderer );
1675 // Double tap out of bounds
1676 TestGenerateTap( application, 29.0f, 25.0f, 1700 );
1677 TestGenerateTap( application, 29.0f, 25.0f, 1800 );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // The stencil actor should have one actors: the renderer actor.
1684 stencil = editor.GetChildAt( 0u );
1686 // The stencil actor has a container with all the actors which contain the text renderers.
1687 container = stencil.GetChildAt( 0u );
1688 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1690 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1691 DALI_TEST_CHECK( renderer );
1695 TestGenerateLongPress(application, 1.0f, 25.0f);
1697 // Render and notify
1698 application.SendNotification();
1699 application.Render();
1704 int utcDaliTextEditorEvent04(void)
1706 ToolkitTestApplication application;
1707 tet_infoline(" utcDaliTextEditorEvent04");
1709 // Checks if the highlight actor is created.
1711 TextEditor editor = TextEditor::New();
1712 DALI_TEST_CHECK( editor );
1714 Stage::GetCurrent().Add( editor );
1716 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1717 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1718 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1719 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1720 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1722 // Avoid a crash when core load gl resources.
1723 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1725 // Render and notify
1726 application.SendNotification();
1727 application.Render();
1729 // Tap on the text editor
1730 TestGenerateTap( application, 3.0f, 25.0f );
1732 // Render and notify
1733 application.SendNotification();
1734 application.Render();
1736 // Move at the end of the text.
1737 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1738 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1740 // Render and notify
1741 application.SendNotification();
1742 application.Render();
1744 for( unsigned int index = 0u; index < 10u; ++index )
1746 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1747 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1749 // Render and notify
1750 application.SendNotification();
1751 application.Render();
1755 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1757 // Render and notify
1758 application.SendNotification();
1759 application.Render();
1761 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1763 // Add some key events
1764 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1765 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
1771 for( unsigned int index = 0u; index < 10u; ++index )
1773 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1774 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1776 // Render and notify
1777 application.SendNotification();
1778 application.Render();
1782 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1788 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1793 int utcDaliTextEditorEvent05(void)
1795 ToolkitTestApplication application;
1796 tet_infoline(" utcDaliTextEditorEvent05");
1798 // Checks if the highlight actor is created.
1800 TextEditor editor = TextEditor::New();
1801 DALI_TEST_CHECK( editor );
1803 Stage::GetCurrent().Add( editor );
1805 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1806 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1807 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
1808 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1809 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1810 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1811 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1812 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1813 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1814 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1816 // Avoid a crash when core load gl resources.
1817 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1819 // Render and notify
1820 application.SendNotification();
1821 application.Render();
1823 // Tap on the text editor
1824 TestGenerateTap( application, 3.0f, 25.0f );
1826 // Render and notify
1827 application.SendNotification();
1828 application.Render();
1830 // Move at the end of the text.
1831 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1832 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1834 // Render and notify
1835 application.SendNotification();
1836 application.Render();
1838 for( unsigned int index = 0u; index < 10u; ++index )
1841 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1847 // Modify duration after scroll is enabled
1848 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1850 // Continuous scroll left to increase coverage
1851 for( unsigned int index = 0u; index < 10u; ++index )
1853 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1855 // Render and notify
1856 application.SendNotification();
1857 application.Render();
1859 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1860 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1861 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1862 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1863 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1865 // Press Escape to increase coverage
1866 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1867 application.SendNotification();
1868 application.Render();
1870 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1875 int utcDaliTextEditorEvent06(void)
1877 ToolkitTestApplication application;
1878 tet_infoline(" utcDaliTextEditorEvent06");
1880 // Checks if the highlight actor is created.
1882 TextEditor editor = TextEditor::New();
1883 DALI_TEST_CHECK( editor );
1885 Stage::GetCurrent().Add( editor );
1887 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1888 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1889 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1890 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1891 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1893 // Avoid a crash when core load gl resources.
1894 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1896 // Render and notify
1897 application.SendNotification();
1898 application.Render();
1900 // Tap on the text editor
1901 TestGenerateTap( application, 3.0f, 25.0f );
1903 // Render and notify
1904 application.SendNotification();
1905 application.Render();
1907 // Move to seconds line of the text.
1908 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 float layoutHeight = editor.GetHeightForWidth( 100.f );
1917 // Add another script characters ( glyph height is defferent )
1918 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1919 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1921 // Delete characters
1922 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1923 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1925 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1927 // Render and notify
1928 application.SendNotification();
1929 application.Render();
1931 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1934 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1935 application.SendNotification();
1936 application.Render();
1938 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1939 application.SendNotification();
1940 application.Render();
1942 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1943 application.SendNotification();
1944 application.Render();
1946 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1947 application.SendNotification();
1948 application.Render();
1950 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1951 application.SendNotification();
1952 application.Render();
1954 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1955 application.SendNotification();
1956 application.Render();
1958 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1959 application.SendNotification();
1960 application.Render();
1965 int utcDaliTextEditorEvent07(void)
1967 ToolkitTestApplication application;
1968 tet_infoline(" utcDaliTextEditorEvent07");
1970 // Checks if the highlight actor is created.
1972 TextEditor editor = TextEditor::New();
1973 DALI_TEST_CHECK( editor );
1975 Stage::GetCurrent().Add( editor );
1977 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1978 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1979 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
1980 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1981 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1983 // Avoid a crash when core load gl resources.
1984 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1986 // Render and notify
1987 application.SendNotification();
1988 application.Render();
1990 // Tap on the text editor
1991 TestGenerateTap( application, 3.0f, 25.0f );
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 // Move to second line of the text.
1998 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2004 // Select some text in the right of the current cursor position
2005 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2008 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2010 // Render and notify
2011 application.SendNotification();
2012 application.Render();
2014 // Cut the selected text
2015 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2016 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 ) );
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2024 // Select some text in the left of the current cursor position
2025 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2028 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2034 // Copy the selected text
2035 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2036 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 ) );
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2042 // Move the cursor to the third line
2043 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2044 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 // Render and notify
2047 application.SendNotification();
2048 application.Render();
2050 // Paste the selected text at the current cursor position
2051 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2052 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 ) );
2054 // Render and notify
2055 application.SendNotification();
2056 application.Render();
2058 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2061 // Disable Shift Selection
2062 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2064 // Test to select some text in the right of the current cursor position
2065 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2068 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 // Render and notify
2071 application.SendNotification();
2072 application.Render();
2074 // Cut the selected text
2075 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2076 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 ) );
2078 // Render and notify
2079 application.SendNotification();
2080 application.Render();
2082 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2083 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2085 // Test to select some text in the left of the current cursor position
2086 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2089 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 // Render and notify
2092 application.SendNotification();
2093 application.Render();
2095 // Copy the selected text
2096 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2097 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 ) );
2099 // Render and notify
2100 application.SendNotification();
2101 application.Render();
2103 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2104 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2109 int utcDaliTextEditorEvent08(void)
2111 ToolkitTestApplication application;
2112 tet_infoline(" utcDaliTextEditorEvent08");
2114 // Checks if the highlight actor is released correctly.
2116 TextEditor editor = TextEditor::New();
2117 DALI_TEST_CHECK( editor );
2119 Stage::GetCurrent().Add( editor );
2121 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2122 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2123 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
2124 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2125 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2127 // Avoid a crash when core load gl resources.
2128 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2130 // Render and notify
2131 application.SendNotification();
2132 application.Render();
2134 // Tap on the text editor
2135 TestGenerateTap( application, 3.0f, 25.0f );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2142 // Test to select some text in the left of the current cursor position
2143 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2146 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 // Render and notify
2149 application.SendNotification();
2150 application.Render();
2152 // Test to the left selection handle position and the right selection handle position
2153 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 // Render and notify
2159 application.SendNotification();
2160 application.Render();
2162 // Test to select full text in the left of the current cursor position
2163 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2168 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2170 // Render and notify
2171 application.SendNotification();
2172 application.Render();
2174 // Test to release the current full text selection
2175 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2176 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2178 // Render and notify
2179 application.SendNotification();
2180 application.Render();
2182 // Test to move the current cursor position correctly
2183 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2185 // Render and notify
2186 application.SendNotification();
2187 application.Render();
2190 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2198 // Test to select some text in the right of the current cursor position
2199 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2201 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // Test the cursor position with right arrow key
2208 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 // Render and notify
2211 application.SendNotification();
2212 application.Render();
2215 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2217 // Render and notify
2218 application.SendNotification();
2219 application.Render();
2221 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2223 // Test to select some text in the left of the current cursor position
2224 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2228 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2230 // Render and notify
2231 application.SendNotification();
2232 application.Render();
2234 // Test the cursor position with left arrow key
2235 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2237 // Render and notify
2238 application.SendNotification();
2239 application.Render();
2242 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2244 // Render and notify
2245 application.SendNotification();
2246 application.Render();
2248 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2250 // Test to select some text in the right of the current cursor position
2251 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2254 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2256 // Render and notify
2257 application.SendNotification();
2258 application.Render();
2260 // Test the cursor position with left arrow key
2261 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2263 // Render and notify
2264 application.SendNotification();
2265 application.Render();
2268 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 // Render and notify
2271 application.SendNotification();
2272 application.Render();
2274 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2276 // Test to select some text in the left of the current cursor position
2277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2280 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 // Render and notify
2283 application.SendNotification();
2284 application.Render();
2286 // Test the cursor position with right arrow key
2287 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 // Render and notify
2290 application.SendNotification();
2291 application.Render();
2294 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2296 // Render and notify
2297 application.SendNotification();
2298 application.Render();
2300 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2305 int utcDaliTextEditorHandles(void)
2307 ToolkitTestApplication application;
2308 tet_infoline(" utcDaliTextEditorHandles");
2310 TextEditor editor = TextEditor::New();
2311 DALI_TEST_CHECK( editor );
2313 Stage::GetCurrent().Add( editor );
2315 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2316 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2317 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2318 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2320 Property::Map imagePropertyMap;
2321 imagePropertyMap["type"] = "BufferImage";
2322 imagePropertyMap["width"] = 40;
2323 imagePropertyMap["height"] = 40;
2325 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2326 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2327 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2328 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2330 editor.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 500.f ) );
2331 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2332 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2334 // Avoid a crash when core load gl resources.
2335 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2337 // Render and notify
2338 application.SendNotification();
2339 application.Render();
2341 // Tap first to get the focus.
2342 TestGenerateTap( application, 3.0f, 25.0f, 100 );
2344 // Render and notify
2345 application.SendNotification();
2346 application.Render();
2348 // Tap to create the grab handle.
2349 TestGenerateTap( application, 3.0f, 25.0f, 700 );
2351 // Render and notify
2352 application.SendNotification();
2353 application.Render();
2355 // Get the active layer where the text's decoration is added.
2356 Actor activeLayer = editor.GetChildAt( 1u );
2358 // Get the handle's actor.
2359 Actor handle = activeLayer.GetChildAt( 1u );
2360 handle.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2366 // Touch the grab handle to set it as pressed.
2367 Vector2 touchPos( 10.0f, 50.0f );
2368 Dali::Integration::TouchEvent event;
2369 event = Dali::Integration::TouchEvent();
2370 event.AddPoint( GetPointDownInside( touchPos ) );
2371 application.ProcessEvent( event );
2373 // Render and notify
2374 application.SendNotification();
2375 application.Render();
2377 // Release the grab handle.
2378 event = Dali::Integration::TouchEvent();
2379 event.AddPoint( GetPointUpInside( touchPos ) );
2380 application.ProcessEvent( event );
2382 // Render and notify
2383 application.SendNotification();
2384 application.Render();
2386 // Tap first to get the focus.
2387 TestGenerateTap( application, 3.0f, 25.0f, 1400 );
2389 // Render and notify
2390 application.SendNotification();
2391 application.Render();
2393 // Double tap to select a word and create the selection handles.
2394 TestGenerateTap( application, 3.0f, 25.0f, 1500 );
2396 // Render and notify
2397 application.SendNotification();
2398 application.Render();
2400 touchPos = Vector2( 10.0f, 50.0f );
2402 // Touch the left selection handle to set it as pressed.
2403 event = Dali::Integration::TouchEvent();
2404 event.AddPoint( GetPointDownInside( touchPos ) );
2405 application.ProcessEvent( event );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // Release the left selection handle.
2412 event = Dali::Integration::TouchEvent();
2413 event.AddPoint( GetPointUpInside( touchPos ) );
2414 application.ProcessEvent( event );
2416 // Render and notify
2417 application.SendNotification();
2418 application.Render();
2423 int utcDaliTextEditorUnderPropertyStringP(void)
2425 ToolkitTestApplication application;
2426 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2427 TextEditor editor = TextEditor::New();
2428 DALI_TEST_CHECK( editor );
2430 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2432 Stage::GetCurrent().Add( editor );
2434 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2435 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2437 tet_infoline("Set underline settings with a map");
2438 // Check the input underline property
2439 Property::Map underlineMapSet;
2440 Property::Map underlineMapGet;
2441 underlineMapSet.Insert( "enable", true );
2442 underlineMapSet.Insert( "color", Color::BLUE );
2443 underlineMapSet.Insert( "height", 2 );
2445 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2446 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2447 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2448 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2450 tet_infoline("Set underline settings with a string");
2451 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2452 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2455 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2457 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2458 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2459 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2460 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2462 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2467 int utcDaliTextEditorShadowPropertyStringP(void)
2469 ToolkitTestApplication application;
2470 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2472 TextEditor editor = TextEditor::New();
2474 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2476 Stage::GetCurrent().Add( editor );
2478 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2480 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2484 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2489 int utcDaliTextEditorFontStylePropertyStringP(void)
2491 ToolkitTestApplication application;
2492 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2494 TextEditor editor = TextEditor::New();
2496 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2498 Stage::GetCurrent().Add( editor );
2500 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2502 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2506 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2511 int utcDaliTextEditorGetPropertyLinecountP(void)
2513 ToolkitTestApplication application;
2515 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2519 TextEditor editor = TextEditor::New();
2520 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2521 editor.SetProperty( TextEditor::Property::TEXT,
2522 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2524 Stage::GetCurrent().Add( editor );
2526 editor.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2527 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2528 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2530 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 100.f ) );
2531 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2532 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2537 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2540 ToolkitTestApplication application;
2541 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2543 TextEditor editor = TextEditor::New();
2544 DALI_TEST_CHECK( editor );
2546 Stage::GetCurrent().Add( editor );
2548 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2549 editor.SetProperty( Actor::Property::SIZE, Vector2( 50.f, 50.f ) );
2550 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2551 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2552 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2553 editor.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
2555 bool startedCalled = false;
2556 bool finishedCalled = false;
2558 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2559 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2561 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2563 // Render and notify
2564 application.SendNotification();
2565 application.Render();
2567 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2568 application.SendNotification();
2569 application.Render(6000);
2571 application.SendNotification();
2572 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2573 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2578 int UtcDaliToolkitTextEditorTextWrapMode(void)
2580 ToolkitTestApplication application;
2581 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2585 TextEditor editor = TextEditor::New();
2586 editor.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ) );
2587 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2589 Stage::GetCurrent().Add( editor );
2591 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2592 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2594 application.SendNotification();
2595 application.Render();
2597 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2598 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2600 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2601 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2603 application.SendNotification();
2604 application.Render();
2606 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2607 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2609 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2610 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2612 application.SendNotification();
2613 application.Render();
2615 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2616 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2618 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2619 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2621 application.SendNotification();
2622 application.Render();
2624 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2625 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2630 int UtcDaliTextEditorSetPaddingProperty(void)
2632 ToolkitTestApplication application;
2633 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2635 TextEditor editor = TextEditor::New();
2636 DALI_TEST_CHECK( editor );
2637 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2638 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2639 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2640 Stage::GetCurrent().Add( editor );
2642 application.SendNotification();
2643 application.Render();
2645 Vector3 originalSize = editor.GetNaturalSize();
2647 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2649 application.SendNotification();
2650 application.Render();
2652 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2654 Vector3 paddingAddedSize = editor.GetNaturalSize();
2656 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2658 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2663 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2665 ToolkitTestApplication application;
2666 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2668 TextEditor editor = TextEditor::New();
2669 DALI_TEST_CHECK( editor );
2670 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2671 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2672 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2673 Stage::GetCurrent().Add( editor );
2675 application.SendNotification();
2676 application.Render();
2678 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2679 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2681 // Check the enable shift selection property
2682 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2683 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2685 application.SendNotification();
2686 application.Render();
2691 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2693 ToolkitTestApplication application;
2694 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2696 TextEditor editor = TextEditor::New();
2697 DALI_TEST_CHECK( editor );
2698 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2699 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2700 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2701 Stage::GetCurrent().Add( editor );
2703 application.SendNotification();
2704 application.Render();
2706 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2707 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2709 // Check the enable grab handle property
2710 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2711 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2713 application.SendNotification();
2714 application.Render();
2719 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2721 ToolkitTestApplication application;
2722 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2724 TextEditor editor = TextEditor::New();
2725 DALI_TEST_CHECK( editor );
2726 editor.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2727 editor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2728 editor.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2729 Stage::GetCurrent().Add( editor );
2731 application.SendNotification();
2732 application.Render();
2734 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2735 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2737 // Check the enable match system language direction property
2738 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2739 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2741 application.SendNotification();
2742 application.Render();
2747 int UtcDaliTextEditorGetInputMethodContext(void)
2749 ToolkitTestApplication application;
2750 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2752 TextEditor editor = TextEditor::New();
2753 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );