2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali/integration-api/events/long-press-gesture-event.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
103 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
105 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
106 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
108 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
109 const float TO_MILLISECONDS = 1000.f;
110 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
111 const float RENDER_FRAME_INTERVAL = 16.66f;
113 const float SCROLL_THRESHOLD = 10.f;
114 const float SCROLL_SPEED = 300.f;
116 const unsigned int DEFAULT_FONT_SIZE = 1152u;
117 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119 const int KEY_A_CODE = 38;
120 const int KEY_D_CODE = 40;
121 const int KEY_C_CODE = 54;
122 const int KEY_V_CODE = 55;
123 const int KEY_X_CODE = 53;
124 const int KEY_WHITE_SPACE_CODE = 65;
126 const int KEY_SHIFT_MODIFIER = 257;
127 const int KEY_CONTROL_MODIFIER = 258;
129 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
131 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
133 static bool gTextChangedCallBackCalled;
134 static bool gInputStyleChangedCallbackCalled;
135 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
137 struct CallbackFunctor
139 CallbackFunctor(bool* callbackFlag)
140 : mCallbackFlag( callbackFlag )
146 *mCallbackFlag = true;
151 static void TestTextChangedCallback( TextEditor control )
153 tet_infoline(" TestTextChangedCallback");
155 gTextChangedCallBackCalled = true;
158 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
160 tet_infoline(" TestInputStyleChangedCallback");
162 gInputStyleChangedCallbackCalled = true;
163 gInputStyleMask = mask;
166 // Generate a TapGestureEvent to send to Core.
167 Integration::TapGestureEvent GenerateTap(
168 Gesture::State state,
169 unsigned int numberOfTaps,
170 unsigned int numberOfTouches,
173 Integration::TapGestureEvent tap( state );
175 tap.numberOfTaps = numberOfTaps;
176 tap.numberOfTouches = numberOfTouches;
182 Integration::LongPressGestureEvent GenerateLongPress(
183 Gesture::State state,
184 unsigned int numberOfTouches,
187 Integration::LongPressGestureEvent longPress( state );
189 longPress.numberOfTouches = numberOfTouches;
190 longPress.point = point;
194 // Generate a PanGestureEvent to send to Core
195 Integration::PanGestureEvent GeneratePan( Gesture::State state,
196 const Vector2& previousPosition,
197 const Vector2& currentPosition,
198 unsigned long timeDelta,
199 unsigned int numberOfTouches = 1u )
201 Integration::PanGestureEvent pan(state);
203 pan.previousPosition = previousPosition;
204 pan.currentPosition = currentPosition;
205 pan.timeDelta = timeDelta;
206 pan.numberOfTouches = numberOfTouches;
211 // Generate a KeyEvent to send to Core.
212 Integration::KeyEvent GenerateKey( const std::string& keyName,
213 const std::string& keyString,
216 unsigned long timeStamp,
217 const Integration::KeyEvent::State& keyState,
218 const std::string& deviceName = DEFAULT_DEVICE_NAME,
219 const Device::Class::Type& deviceClass = Device::Class::NONE,
220 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
222 return Integration::KeyEvent( keyName,
234 * Helper to generate PanGestureEvent
236 * @param[in] application Application instance
237 * @param[in] state The Gesture State
238 * @param[in] pos The current position of touch.
240 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
244 if( (state == Gesture::Started) ||
245 (state == Gesture::Possible) )
251 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
258 * Simulate time passed by.
260 * @note this will always process at least 1 frame (1/60 sec)
262 * @param application Test application instance
263 * @param duration Time to pass in milliseconds.
264 * @return The actual time passed in milliseconds
266 static int Wait(ToolkitTestApplication& application, int duration = 0)
270 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
272 application.SendNotification();
273 application.Render(RENDER_FRAME_INTERVAL);
274 time += RENDER_FRAME_INTERVAL;
280 Dali::Integration::Point GetPointDownInside( Vector2& pos )
282 Dali::Integration::Point point;
283 point.SetState( PointState::DOWN );
284 point.SetScreenPosition( pos );
288 Dali::Integration::Point GetPointUpInside( Vector2& pos )
290 Dali::Integration::Point point;
291 point.SetState( PointState::UP );
292 point.SetScreenPosition( pos );
296 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
298 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
300 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
302 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
304 Property::Value* valueSet = NULL;
305 if ( valueGet.first.type == Property::Key::INDEX )
307 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
311 // Get Key is a string so searching Set Map for a string key
312 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
315 if( NULL != valueSet )
317 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
319 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
322 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
324 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
327 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
329 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
332 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
334 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
337 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
339 Vector2 vector2Get = valueGet.second.Get<Vector2>();
340 Vector2 vector2Set = valueSet->Get<Vector2>();
341 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
344 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
346 Vector4 vector4Get = valueGet.second.Get<Vector4>();
347 Vector4 vector4Set = valueSet->Get<Vector4>();
348 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 );
354 if ( valueGet.first.type == Property::Key::INDEX )
356 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
360 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
370 class ScrollStateChangeCallback : public Dali::ConnectionTracker
373 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
374 : mStartedCalled( startedCalled ),
375 mFinishedCalled( finishedCalled )
379 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
381 if( type == TextEditor::Scroll::STARTED )
383 mStartedCalled = true;
385 else if( type == TextEditor::Scroll::FINISHED )
387 mFinishedCalled = true;
391 bool& mStartedCalled;
392 bool& mFinishedCalled;
397 int UtcDaliToolkitTextEditorConstructorP(void)
399 ToolkitTestApplication application;
400 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
401 TextEditor textEditor;
402 DALI_TEST_CHECK( !textEditor );
406 int UtcDaliToolkitTextEditorNewP(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliToolkitTextEditorNewP");
410 TextEditor textEditor = TextEditor::New();
411 DALI_TEST_CHECK( textEditor );
415 int UtcDaliToolkitTextEditorDownCastP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
419 TextEditor textEditor1 = TextEditor::New();
420 BaseHandle object( textEditor1 );
422 TextEditor textEditor2 = TextEditor::DownCast( object );
423 DALI_TEST_CHECK( textEditor2 );
425 TextEditor textEditor3 = DownCast< TextEditor >( object );
426 DALI_TEST_CHECK( textEditor3 );
430 int UtcDaliToolkitTextEditorDownCastN(void)
432 ToolkitTestApplication application;
433 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
434 BaseHandle uninitializedObject;
435 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
436 DALI_TEST_CHECK( !textEditor1 );
438 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
439 DALI_TEST_CHECK( !textEditor2 );
443 int UtcDaliToolkitTextEditorCopyConstructorP(void)
445 ToolkitTestApplication application;
446 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
447 TextEditor textEditor = TextEditor::New();
448 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
450 TextEditor copy( textEditor );
451 DALI_TEST_CHECK( copy );
452 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
456 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
460 TextEditor textEditor = TextEditor::New();
461 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
463 TextEditor copy = textEditor;
464 DALI_TEST_CHECK( copy );
465 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
469 int UtcDaliTextEditorNewP(void)
471 ToolkitTestApplication application;
472 tet_infoline(" UtcDaliToolkitTextEditorNewP");
473 TextEditor textEditor = TextEditor::New();
474 DALI_TEST_CHECK( textEditor );
478 // Positive test case for a method
479 int UtcDaliTextEditorGetPropertyP(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
483 TextEditor editor = TextEditor::New();
484 DALI_TEST_CHECK( editor );
486 // Check Property Indices are correct
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
543 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
546 Property::Map imageMap;
547 imageMap[mapKey] =mapValue;
549 editor.SetProperty( property , imageMap );
550 Property::Value propValue = editor.GetProperty( property );
551 Property::Map* resultMap = propValue.GetMap();
553 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
561 // Positive test case for a method
562 int UtcDaliTextEditorSetPropertyP(void)
564 ToolkitTestApplication application;
565 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
566 TextEditor editor = TextEditor::New();
567 DALI_TEST_CHECK( editor );
568 Stage::GetCurrent().Add( editor );
570 // Note - we can't check the defaults since the stylesheets are platform-specific
572 // Check the render backend property.
573 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
574 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
576 // Check text property.
577 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
578 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
580 // Check text's color property
581 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
582 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
584 // Check font properties.
585 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
586 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
588 Property::Map fontStyleMapSet;
589 Property::Map fontStyleMapGet;
590 Property::Value* slantValue = NULL;
592 fontStyleMapSet.Insert( "weight", "bold" );
593 fontStyleMapSet.Insert( "width", "condensed" );
594 fontStyleMapSet.Insert( "slant", "italic" );
596 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
597 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
598 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
599 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
601 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
602 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
605 fontStyleMapSet.Clear();
606 fontStyleMapSet.Insert( "weight", "normal" );
607 fontStyleMapSet.Insert( "slant", "oblique" );
608 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
609 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
610 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
611 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
613 fontStyleMapSet.Clear();
614 fontStyleMapSet.Insert( "slant", "roman" );
615 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
616 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
618 // Replace 'roman' for 'normal'.
619 slantValue = fontStyleMapGet.Find( "slant" );
620 if( NULL != slantValue )
622 if( "normal" == slantValue->Get<std::string>() )
624 fontStyleMapGet["slant"] = "roman";
627 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
628 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
630 fontStyleMapSet.Clear();
632 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
633 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
634 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
635 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
637 // Check that the Alignment properties can be correctly set
638 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
639 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
641 // Check scroll properties.
642 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
643 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
644 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
645 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
647 // Check cursor properties
648 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
649 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
650 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
651 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
653 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
654 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
655 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
656 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
657 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
658 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
660 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
662 // Check handle images
663 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
664 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
665 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
666 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
667 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
669 // Check handle images
670 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
671 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
672 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
677 // Check the highlight color
678 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
679 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
681 // Decoration bounding box
682 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
683 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
685 // Check the enable markup property.
686 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
687 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
688 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
690 // Check input color property.
691 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
692 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
694 // Check input font properties.
695 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
696 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
698 fontStyleMapSet.Clear();
699 fontStyleMapSet.Insert( "weight", "bold" );
700 fontStyleMapSet.Insert( "width", "condensed" );
701 fontStyleMapSet.Insert( "slant", "italic" );
703 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
704 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
705 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
706 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
708 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
709 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
711 // Reset input font style.
712 fontStyleMapSet.Clear();
713 fontStyleMapSet.Insert( "weight", "normal" );
714 fontStyleMapSet.Insert( "slant", "oblique" );
716 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
717 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
718 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
719 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
721 fontStyleMapSet.Clear();
722 fontStyleMapSet.Insert( "slant", "roman" );
724 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
725 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
727 // Replace 'roman' for 'normal'.
728 slantValue = fontStyleMapGet.Find( "slant" );
729 if( NULL != slantValue )
731 if( "normal" == slantValue->Get<std::string>() )
733 fontStyleMapGet["slant"] = "roman";
736 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
737 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
739 fontStyleMapSet.Clear();
741 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
742 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
743 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
744 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
746 // Check the line spacing property
747 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
748 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
749 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
751 // Check the input line spacing property
752 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
753 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
754 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
756 // Check the underline property
758 Property::Map underlineMapSet;
759 Property::Map underlineMapGet;
761 underlineMapSet.Insert( "enable", "true" );
762 underlineMapSet.Insert( "color", "red" );
763 underlineMapSet.Insert( "height", "1" );
765 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
767 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
768 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
769 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
771 // Check the input underline property
772 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
773 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
775 // Check the shadow property
776 Property::Map shadowMapSet;
777 Property::Map shadowMapGet;
779 shadowMapSet.Insert( "color", Color::GREEN );
780 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
781 shadowMapSet.Insert( "blurRadius", 3.0f );
783 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
785 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
786 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
787 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
789 // Check the input shadow property
790 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
791 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
793 // Check the emboss property
794 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
795 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
797 // Check the input emboss property
798 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
799 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
801 // Check the outline property
803 // Test string type first
804 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
805 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
806 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
808 // Then test the property map type
809 Property::Map outlineMapSet;
810 Property::Map outlineMapGet;
812 outlineMapSet["color"] = Color::RED;
813 outlineMapSet["width"] = 2.0f;
815 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
817 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
818 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
819 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
821 // Check the input outline property
822 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
823 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
825 // Check the smooth scroll property
826 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
827 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
828 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
830 // Check the smooth scroll duration property
831 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
832 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
834 // Check the scroll bar property
835 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
836 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
837 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
839 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
840 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
841 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
842 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
844 // Check the pixel size of font
845 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
846 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
848 // Check placeholder text properties.
849 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
850 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
852 // Check placeholder text's color property.
853 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
854 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
856 // Check the enable selection property
857 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
858 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
860 // Check the placeholder property with pixel size
861 Property::Map placeholderPixelSizeMapSet;
862 Property::Map placeholderPixelSizeMapGet;
863 Property::Map placeholderFontstyleMap;
864 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
865 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
866 placeholderPixelSizeMapSet["color"] = Color::BLUE;
867 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
868 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
870 placeholderFontstyleMap.Insert( "weight", "bold" );
871 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
872 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
874 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
875 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
877 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
878 Property::Map placeholderConversionMap;
879 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
880 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
881 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
882 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
883 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
884 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
886 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
888 // Check the placeholder property with point size
889 Property::Map placeholderMapSet;
890 Property::Map placeholderMapGet;
891 placeholderMapSet["text"] = "Setting Placeholder Text";
892 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
893 placeholderMapSet["color"] = Color::RED;
894 placeholderMapSet["fontFamily"] = "Arial";
895 placeholderMapSet["pointSize"] = 12.0f;
896 // Check the placeholder font style property
897 placeholderFontstyleMap.Clear();
899 placeholderFontstyleMap.Insert( "weight", "bold" );
900 placeholderFontstyleMap.Insert( "width", "condensed" );
901 placeholderFontstyleMap.Insert( "slant", "italic" );
902 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
903 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
905 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
906 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
908 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
909 placeholderConversionMap.Clear();
910 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
911 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
912 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
913 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
916 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
919 placeholderFontstyleMap.Clear();
920 placeholderFontstyleMap.Insert( "weight", "normal" );
921 placeholderFontstyleMap.Insert( "slant", "oblique" );
922 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
923 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
925 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
926 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
927 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
928 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
930 placeholderFontstyleMap.Clear();
931 placeholderFontstyleMap.Insert( "slant", "roman" );
932 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
933 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
935 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
937 placeholderFontstyleMap.Clear();
938 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
940 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
941 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
942 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
943 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
944 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
946 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
947 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
949 application.SendNotification();
950 application.Render();
955 // Positive Atlas Text Renderer test
956 int utcDaliTextEditorAtlasRenderP(void)
958 ToolkitTestApplication application;
959 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
960 StyleManager styleManager = StyleManager::Get();
961 styleManager.ApplyDefaultTheme();
962 TextEditor editor = TextEditor::New();
963 DALI_TEST_CHECK( editor );
965 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
967 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
969 Stage::GetCurrent().Add( editor );
973 // Render some text with the shared atlas backend
974 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
975 application.SendNotification();
976 application.Render();
980 tet_result(TET_FAIL);
985 // Positive test for the textChanged signal.
986 int utcDaliTextEditorTextChangedP(void)
988 ToolkitTestApplication application;
989 tet_infoline(" utcDaliTextEditorTextChangedP");
990 TextEditor editor = TextEditor::New();
991 DALI_TEST_CHECK( editor );
993 Stage::GetCurrent().Add( editor );
995 // connect to the text changed signal.
996 ConnectionTracker* testTracker = new ConnectionTracker();
997 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
998 bool textChangedSignal = false;
999 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1001 gTextChangedCallBackCalled = false;
1002 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1003 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1004 DALI_TEST_CHECK( textChangedSignal );
1006 application.SendNotification();
1008 editor.SetKeyInputFocus();
1010 gTextChangedCallBackCalled = false;
1011 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1012 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1017 int utcDaliTextEditorInputStyleChanged01(void)
1019 ToolkitTestApplication application;
1020 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1022 // The text-editor emits signals when the input style changes. These changes of style are
1023 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1024 // can't be emitted during the size negotiation as the callbacks may update the UI.
1025 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1026 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1027 application.CreateAdaptor();
1031 char* pathNamePtr = get_current_dir_name();
1032 const std::string pathName( pathNamePtr );
1033 free( pathNamePtr );
1035 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1036 fontClient.SetDpi( 93u, 93u );
1038 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1039 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1041 TextEditor editor = TextEditor::New();
1042 DALI_TEST_CHECK( editor );
1045 editor.SetSize( 300.f, 50.f );
1046 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1047 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1049 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1050 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1052 // connect to the text changed signal.
1053 ConnectionTracker* testTracker = new ConnectionTracker();
1054 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1055 bool inputStyleChangedSignal = false;
1056 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1058 Stage::GetCurrent().Add( editor );
1060 // Render and notify
1061 application.SendNotification();
1062 application.Render();
1064 // Executes the idle callbacks added by the text control on the change of input style.
1065 application.RunIdles();
1067 gInputStyleChangedCallbackCalled = false;
1068 gInputStyleMask = TextEditor::InputStyle::NONE;
1069 inputStyleChangedSignal = false;
1071 // Create a tap event to touch the text editor.
1072 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1073 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1075 // Render and notify
1076 application.SendNotification();
1077 application.Render();
1079 // Executes the idle callbacks added by the text control on the change of input style.
1080 application.RunIdles();
1082 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1083 if( gInputStyleChangedCallbackCalled )
1085 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1087 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1088 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1090 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1091 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1093 DALI_TEST_CHECK( inputStyleChangedSignal );
1095 gInputStyleChangedCallbackCalled = false;
1096 gInputStyleMask = TextEditor::InputStyle::NONE;
1097 inputStyleChangedSignal = false;
1099 // Create a tap event to touch the text editor.
1100 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1101 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1103 // Render and notify
1104 application.SendNotification();
1105 application.Render();
1107 // Executes the idle callbacks added by the text control on the change of input style.
1108 application.RunIdles();
1110 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1111 DALI_TEST_CHECK( !inputStyleChangedSignal );
1113 gInputStyleChangedCallbackCalled = false;
1114 gInputStyleMask = TextEditor::InputStyle::NONE;
1115 inputStyleChangedSignal = false;
1117 // Create a tap event to touch the text editor.
1118 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1119 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1121 // Render and notify
1122 application.SendNotification();
1123 application.Render();
1125 // Executes the idle callbacks added by the text control on the change of input style.
1126 application.RunIdles();
1128 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1129 if( gInputStyleChangedCallbackCalled )
1131 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1133 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1134 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1136 DALI_TEST_CHECK( inputStyleChangedSignal );
1138 gInputStyleChangedCallbackCalled = false;
1139 gInputStyleMask = TextEditor::InputStyle::NONE;
1140 inputStyleChangedSignal = false;
1142 // Create a tap event to touch the text editor.
1143 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1144 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1146 // Render and notify
1147 application.SendNotification();
1148 application.Render();
1150 // Executes the idle callbacks added by the text control on the change of input style.
1151 application.RunIdles();
1153 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1154 if( gInputStyleChangedCallbackCalled )
1156 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1158 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1159 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1161 Property::Map fontStyleMapSet;
1162 Property::Map fontStyleMapGet;
1164 fontStyleMapSet.Insert( "weight", "bold" );
1166 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1167 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1168 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1170 DALI_TEST_CHECK( inputStyleChangedSignal );
1172 gInputStyleChangedCallbackCalled = false;
1173 gInputStyleMask = TextEditor::InputStyle::NONE;
1174 inputStyleChangedSignal = false;
1176 // Create a tap event to touch the text editor.
1177 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1178 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1180 // Render and notify
1181 application.SendNotification();
1182 application.Render();
1184 // Executes the idle callbacks added by the text control on the change of input style.
1185 application.RunIdles();
1187 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1188 DALI_TEST_CHECK( !inputStyleChangedSignal );
1190 gInputStyleChangedCallbackCalled = false;
1191 gInputStyleMask = TextEditor::InputStyle::NONE;
1192 inputStyleChangedSignal = false;
1194 // Create a tap event to touch the text editor.
1195 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1196 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1198 // Render and notify
1199 application.SendNotification();
1200 application.Render();
1202 // Executes the idle callbacks added by the text control on the change of input style.
1203 application.RunIdles();
1205 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1206 if( gInputStyleChangedCallbackCalled )
1208 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1210 Property::Map fontStyleMapSet;
1211 Property::Map fontStyleMapGet;
1213 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1214 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1215 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1217 DALI_TEST_CHECK( inputStyleChangedSignal );
1219 gInputStyleChangedCallbackCalled = false;
1220 gInputStyleMask = TextEditor::InputStyle::NONE;
1221 inputStyleChangedSignal = false;
1223 // Create a tap event to touch the text editor.
1224 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1225 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Executes the idle callbacks added by the text control on the change of input style.
1232 application.RunIdles();
1234 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1235 DALI_TEST_CHECK( !inputStyleChangedSignal );
1240 int utcDaliTextEditorInputStyleChanged02(void)
1242 ToolkitTestApplication application;
1243 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1245 // The text-editor emits signals when the input style changes. These changes of style are
1246 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1247 // can't be emitted during the size negotiation as the callbacks may update the UI.
1248 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1249 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1250 application.CreateAdaptor();
1254 char* pathNamePtr = get_current_dir_name();
1255 const std::string pathName( pathNamePtr );
1256 free( pathNamePtr );
1258 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1259 fontClient.SetDpi( 93u, 93u );
1261 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1262 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1264 TextEditor editor = TextEditor::New();
1265 DALI_TEST_CHECK( editor );
1268 editor.SetSize( 300.f, 50.f );
1269 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1270 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1272 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1273 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>" );
1275 // connect to the text changed signal.
1276 ConnectionTracker* testTracker = new ConnectionTracker();
1277 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1278 bool inputStyleChangedSignal = false;
1279 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1281 Stage::GetCurrent().Add( editor );
1283 // Render and notify
1284 application.SendNotification();
1285 application.Render();
1287 // Executes the idle callbacks added by the text control on the change of input style.
1288 application.RunIdles();
1290 gInputStyleChangedCallbackCalled = false;
1291 gInputStyleMask = TextEditor::InputStyle::NONE;
1292 inputStyleChangedSignal = false;
1294 // Create a tap event to touch the text editor.
1295 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1296 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1297 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1298 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1300 // Render and notify
1301 application.SendNotification();
1302 application.Render();
1304 // Executes the idle callbacks added by the text control on the change of input style.
1305 application.RunIdles();
1307 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1308 if( gInputStyleChangedCallbackCalled )
1310 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1311 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1312 TextEditor::InputStyle::POINT_SIZE |
1313 TextEditor::InputStyle::COLOR ),
1316 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1317 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1319 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1320 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1322 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1323 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1325 DALI_TEST_CHECK( inputStyleChangedSignal );
1327 gInputStyleChangedCallbackCalled = false;
1328 gInputStyleMask = TextEditor::InputStyle::NONE;
1329 inputStyleChangedSignal = false;
1331 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1333 // Render and notify
1334 application.SendNotification();
1335 application.Render();
1337 // Executes the idle callbacks added by the text control on the change of input style.
1338 application.RunIdles();
1340 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1341 if( gInputStyleChangedCallbackCalled )
1343 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1344 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1347 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1348 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1350 DALI_TEST_CHECK( inputStyleChangedSignal );
1352 gInputStyleChangedCallbackCalled = false;
1353 gInputStyleMask = TextEditor::InputStyle::NONE;
1354 inputStyleChangedSignal = false;
1356 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1358 // Render and notify
1359 application.SendNotification();
1360 application.Render();
1362 // Executes the idle callbacks added by the text control on the change of input style.
1363 application.RunIdles();
1365 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1366 DALI_TEST_CHECK( !inputStyleChangedSignal );
1368 gInputStyleChangedCallbackCalled = false;
1369 gInputStyleMask = TextEditor::InputStyle::NONE;
1370 inputStyleChangedSignal = false;
1372 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Executes the idle callbacks added by the text control on the change of input style.
1379 application.RunIdles();
1381 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1382 if( gInputStyleChangedCallbackCalled )
1384 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1385 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1388 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1389 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1391 DALI_TEST_CHECK( inputStyleChangedSignal );
1393 gInputStyleChangedCallbackCalled = false;
1394 gInputStyleMask = TextEditor::InputStyle::NONE;
1395 inputStyleChangedSignal = false;
1397 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1399 Property::Map fontStyleMapSet;
1400 fontStyleMapSet.Insert( "weight", "thin" );
1401 fontStyleMapSet.Insert( "width", "condensed" );
1402 fontStyleMapSet.Insert( "slant", "italic" );
1404 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1405 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1406 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1408 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1409 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1410 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1411 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1413 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1415 // Render and notify
1416 application.SendNotification();
1417 application.Render();
1419 // Executes the idle callbacks added by the text control on the change of input style.
1420 application.RunIdles();
1422 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1423 DALI_TEST_CHECK( !inputStyleChangedSignal );
1425 // Create a tap event to touch the text editor.
1426 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1427 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1429 // Render and notify
1430 application.SendNotification();
1431 application.Render();
1433 // Executes the idle callbacks added by the text control on the change of input style.
1434 application.RunIdles();
1436 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1437 if( gInputStyleChangedCallbackCalled )
1439 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1440 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1441 TextEditor::InputStyle::POINT_SIZE |
1442 TextEditor::InputStyle::FONT_STYLE |
1443 TextEditor::InputStyle::LINE_SPACING |
1444 TextEditor::InputStyle::UNDERLINE |
1445 TextEditor::InputStyle::SHADOW |
1446 TextEditor::InputStyle::EMBOSS |
1447 TextEditor::InputStyle::OUTLINE ),
1450 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1451 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1453 DALI_TEST_CHECK( inputStyleChangedSignal );
1455 gInputStyleChangedCallbackCalled = false;
1456 gInputStyleMask = TextEditor::InputStyle::NONE;
1457 inputStyleChangedSignal = false;
1459 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1461 fontStyleMapSet.Clear();
1462 fontStyleMapSet.Insert( "weight", "black" );
1463 fontStyleMapSet.Insert( "width", "expanded" );
1464 fontStyleMapSet.Insert( "slant", "oblique" );
1466 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1468 // Create a tap event to touch the text editor.
1469 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1470 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1472 // Render and notify
1473 application.SendNotification();
1474 application.Render();
1476 // Executes the idle callbacks added by the text control on the change of input style.
1477 application.RunIdles();
1479 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1480 if( gInputStyleChangedCallbackCalled )
1482 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1483 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1484 TextEditor::InputStyle::POINT_SIZE |
1485 TextEditor::InputStyle::FONT_STYLE ),
1488 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1489 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1491 DALI_TEST_CHECK( inputStyleChangedSignal );
1496 int utcDaliTextEditorEvent01(void)
1498 ToolkitTestApplication application;
1499 tet_infoline(" utcDaliTextEditorEvent01");
1501 // Creates a tap event. After creating a tap event the text editor should
1502 // have the focus and add text with key events should be possible.
1504 TextEditor editor = TextEditor::New();
1505 DALI_TEST_CHECK( editor );
1507 Stage::GetCurrent().Add( editor );
1509 editor.SetSize( 300.f, 50.f );
1510 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1511 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1513 // Avoid a crash when core load gl resources.
1514 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1516 // Render and notify
1517 application.SendNotification();
1518 application.Render();
1520 // Add a key event but as the text editor has not the focus it should do nothing.
1521 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1523 // Render and notify
1524 application.SendNotification();
1525 application.Render();
1527 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1529 // Create a tap event to touch the text editor.
1530 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1531 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1533 // Render and notify
1534 application.SendNotification();
1535 application.Render();
1537 // Now the text editor has the focus, so it can handle the key events.
1538 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1539 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1541 // Render and notify
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1547 // Create a second text editor and send key events to it.
1548 TextEditor editor2 = TextEditor::New();
1550 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1551 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1552 editor2.SetSize( 100.f, 100.f );
1553 editor2.SetPosition( 100.f, 100.f );
1555 Stage::GetCurrent().Add( editor2 );
1557 // Render and notify
1558 application.SendNotification();
1559 application.Render();
1561 // Create a tap event on the second text editor.
1562 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1563 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1565 // Render and notify
1566 application.SendNotification();
1567 application.Render();
1569 // The second text editor has the focus. It should handle the key events.
1570 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1571 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1573 // Render and notify
1574 application.SendNotification();
1575 application.Render();
1577 // Check the text has been added to the second text editor.
1578 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1583 int utcDaliTextEditorEvent02(void)
1585 ToolkitTestApplication application;
1586 tet_infoline(" utcDaliTextEditorEvent02");
1588 // Checks if the right number of actors are created.
1590 TextEditor editor = TextEditor::New();
1591 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1592 DALI_TEST_CHECK( editor );
1594 Stage::GetCurrent().Add( editor );
1596 editor.SetSize( 300.f, 50.f );
1597 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1598 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1600 // Avoid a crash when core load gl resources.
1601 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 // Check there are the expected number of children (the stencil).
1608 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1610 Actor stencil = editor.GetChildAt( 0u );
1612 // Create a tap event to touch the text editor.
1613 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1614 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 Actor layer = editor.GetChildAt( 1u );
1621 DALI_TEST_CHECK( layer.IsLayer() );
1623 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1624 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1626 // Now the text editor has the focus, so it can handle the key events.
1627 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1630 // Render and notify
1631 application.SendNotification();
1632 application.Render();
1634 // Checks the cursor and the renderer have been created.
1635 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1636 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1638 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1639 DALI_TEST_CHECK( cursor );
1641 // The stencil actor has a container with all the actors which contain the text renderers.
1642 Actor container = stencil.GetChildAt( 0u );
1643 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1645 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1646 DALI_TEST_CHECK( renderer );
1649 // Move the cursor and check the position changes.
1650 Vector3 position1 = cursor.GetCurrentPosition();
1652 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1653 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 Vector3 position2 = cursor.GetCurrentPosition();
1661 DALI_TEST_CHECK( position2.x < position1.x );
1663 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1664 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 Vector3 position3 = cursor.GetCurrentPosition();
1672 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1674 // Send some taps and check the cursor positions.
1676 // Try to tap at the beginning.
1677 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1678 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1680 // Render and notify
1681 application.SendNotification();
1682 application.Render();
1684 // Cursor position should be the same than position1.
1685 Vector3 position4 = cursor.GetCurrentPosition();
1687 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1689 // Tap away from the start position.
1690 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1691 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1693 // Render and notify
1694 application.SendNotification();
1695 application.Render();
1697 Vector3 position5 = cursor.GetCurrentPosition();
1699 DALI_TEST_CHECK( position5.x > position4.x );
1701 // Remove all the text.
1702 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1703 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1704 editor.SetProperty( TextEditor::Property::TEXT, "" );
1706 // Render and notify
1707 application.SendNotification();
1708 application.Render();
1710 // Cursor position should be the same than position2.
1711 Vector3 position6 = cursor.GetCurrentPosition();
1713 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1715 // Should not be a renderer.
1716 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1721 int utcDaliTextEditorEvent03(void)
1723 ToolkitTestApplication application;
1724 tet_infoline(" utcDaliTextEditorEvent03");
1726 // Checks if the highlight actor is created.
1728 TextEditor editor = TextEditor::New();
1729 DALI_TEST_CHECK( editor );
1731 Stage::GetCurrent().Add( editor );
1733 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1734 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1735 editor.SetSize( 30.f, 50.f );
1736 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1737 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1739 // Avoid a crash when core load gl resources.
1740 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1746 // Send some taps and check text controller with clipboard window
1747 Dali::Clipboard clipboard = Clipboard::Get();
1748 clipboard.ShowClipboard();
1749 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1750 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1751 clipboard.HideClipboard();
1753 // Render and notify
1754 application.SendNotification();
1755 application.Render();
1757 // Tap first to get the focus.
1758 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1759 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1761 // Render and notify
1762 application.SendNotification();
1763 application.Render();
1765 // Double tap to select a word.
1766 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1767 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1769 // Render and notify
1770 application.SendNotification();
1771 application.Render();
1773 // The stencil actor should have two actors: the renderer and the highlight actor.
1774 Actor stencil = editor.GetChildAt( 0u );
1776 // Highlight needs to be drawn before text, so should come first in child order
1777 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1778 DALI_TEST_CHECK( highlight );
1780 // The stencil actor has a container with all the actors which contain the text renderers.
1781 Actor container = stencil.GetChildAt( 1u );
1782 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1784 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1785 DALI_TEST_CHECK( renderer );
1788 // Double tap out of bounds
1789 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1790 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1792 // Render and notify
1793 application.SendNotification();
1794 application.Render();
1796 // The stencil actor should have one actors: the renderer actor.
1797 stencil = editor.GetChildAt( 0u );
1799 // The stencil actor has a container with all the actors which contain the text renderers.
1800 container = stencil.GetChildAt( 0u );
1801 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1803 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1804 DALI_TEST_CHECK( renderer );
1808 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1809 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1811 // Render and notify
1812 application.SendNotification();
1813 application.Render();
1818 int utcDaliTextEditorEvent04(void)
1820 ToolkitTestApplication application;
1821 tet_infoline(" utcDaliTextEditorEvent04");
1823 // Checks if the highlight actor is created.
1825 TextEditor editor = TextEditor::New();
1826 DALI_TEST_CHECK( editor );
1828 Stage::GetCurrent().Add( editor );
1830 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1831 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1832 editor.SetSize( 100.f, 50.f );
1833 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1834 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1836 // Avoid a crash when core load gl resources.
1837 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1839 // Render and notify
1840 application.SendNotification();
1841 application.Render();
1843 // Tap on the text editor
1844 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1845 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1847 // Render and notify
1848 application.SendNotification();
1849 application.Render();
1851 // Move at the end of the text.
1852 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1853 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 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 for( unsigned int index = 0u; index < 10u; ++index )
1861 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1862 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1864 // Render and notify
1865 application.SendNotification();
1866 application.Render();
1870 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1872 // Render and notify
1873 application.SendNotification();
1874 application.Render();
1876 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1878 // Add some key events
1879 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1880 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1882 // Render and notify
1883 application.SendNotification();
1884 application.Render();
1886 for( unsigned int index = 0u; index < 10u; ++index )
1888 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1889 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1891 // Render and notify
1892 application.SendNotification();
1893 application.Render();
1897 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1899 // Render and notify
1900 application.SendNotification();
1901 application.Render();
1903 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1908 int utcDaliTextEditorEvent05(void)
1910 ToolkitTestApplication application;
1911 tet_infoline(" utcDaliTextEditorEvent05");
1913 // Checks if the highlight actor is created.
1915 TextEditor editor = TextEditor::New();
1916 DALI_TEST_CHECK( editor );
1918 Stage::GetCurrent().Add( editor );
1920 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1921 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1922 editor.SetSize( 50.f, 50.f );
1923 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1924 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1925 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1926 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1927 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1928 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1929 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1931 // Avoid a crash when core load gl resources.
1932 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1934 // Render and notify
1935 application.SendNotification();
1936 application.Render();
1938 // Tap on the text editor
1939 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1940 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1942 // Render and notify
1943 application.SendNotification();
1944 application.Render();
1946 // Move at the end of the text.
1947 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1948 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1950 // Render and notify
1951 application.SendNotification();
1952 application.Render();
1954 for( unsigned int index = 0u; index < 10u; ++index )
1957 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1963 // Modify duration after scroll is enabled
1964 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1966 // Continuous scroll left to increase coverage
1967 for( unsigned int index = 0u; index < 10u; ++index )
1969 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1976 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1977 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1978 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1979 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1981 // Press Escape to increase coverage
1982 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1983 application.SendNotification();
1984 application.Render();
1986 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1991 int utcDaliTextEditorEvent06(void)
1993 ToolkitTestApplication application;
1994 tet_infoline(" utcDaliTextEditorEvent06");
1996 // Checks if the highlight actor is created.
1998 TextEditor editor = TextEditor::New();
1999 DALI_TEST_CHECK( editor );
2001 Stage::GetCurrent().Add( editor );
2003 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2004 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2005 editor.SetSize( 100.f, 50.f );
2006 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2007 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2009 // Avoid a crash when core load gl resources.
2010 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2012 // Render and notify
2013 application.SendNotification();
2014 application.Render();
2016 // Tap on the text editor
2017 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2018 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2020 // Render and notify
2021 application.SendNotification();
2022 application.Render();
2024 // Move to seconds line of the text.
2025 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2027 // Render and notify
2028 application.SendNotification();
2029 application.Render();
2031 float layoutHeight = editor.GetHeightForWidth( 100.f );
2034 // Add another script characters ( glyph height is defferent )
2035 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2036 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2038 // Delete characters
2039 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2040 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2044 // Render and notify
2045 application.SendNotification();
2046 application.Render();
2048 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2051 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2052 application.SendNotification();
2053 application.Render();
2055 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2056 application.SendNotification();
2057 application.Render();
2059 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2060 application.SendNotification();
2061 application.Render();
2063 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2064 application.SendNotification();
2065 application.Render();
2067 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2068 application.SendNotification();
2069 application.Render();
2071 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 application.SendNotification();
2073 application.Render();
2075 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2076 application.SendNotification();
2077 application.Render();
2082 int utcDaliTextEditorEvent07(void)
2084 ToolkitTestApplication application;
2085 tet_infoline(" utcDaliTextEditorEvent07");
2087 // Checks if the highlight actor is created.
2089 TextEditor editor = TextEditor::New();
2090 DALI_TEST_CHECK( editor );
2092 Stage::GetCurrent().Add( editor );
2094 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2095 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2096 editor.SetSize( 100.f, 50.f );
2097 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2098 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2100 // Avoid a crash when core load gl resources.
2101 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2103 // Render and notify
2104 application.SendNotification();
2105 application.Render();
2107 // Tap on the text editor
2108 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2109 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2111 // Render and notify
2112 application.SendNotification();
2113 application.Render();
2115 // Move to second line of the text.
2116 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2118 // Render and notify
2119 application.SendNotification();
2120 application.Render();
2122 // Select some text in the right of the current cursor position
2123 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2124 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2125 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2126 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 // Render and notify
2129 application.SendNotification();
2130 application.Render();
2132 // Cut the selected text
2133 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2136 // Render and notify
2137 application.SendNotification();
2138 application.Render();
2140 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2142 // 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 // Copy the selected text
2153 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2154 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2156 // Render and notify
2157 application.SendNotification();
2158 application.Render();
2160 // Move the cursor to the third line
2161 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2162 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2164 // Render and notify
2165 application.SendNotification();
2166 application.Render();
2168 // Paste the selected text at the current cursor position
2169 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2170 application.ProcessEvent( GenerateKey( "v", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2172 // Render and notify
2173 application.SendNotification();
2174 application.Render();
2176 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2181 int utcDaliTextEditorHandles(void)
2183 ToolkitTestApplication application;
2184 tet_infoline(" utcDaliTextEditorHandles");
2186 TextEditor editor = TextEditor::New();
2187 DALI_TEST_CHECK( editor );
2189 Stage::GetCurrent().Add( editor );
2191 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2192 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2193 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2194 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2196 editor.SetSize( 30.f, 500.f );
2197 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2198 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2200 // Avoid a crash when core load gl resources.
2201 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // Tap first to get the focus.
2208 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2209 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2211 // Render and notify
2212 application.SendNotification();
2213 application.Render();
2215 // Tap to create the grab handle.
2216 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2217 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2219 // Render and notify
2220 application.SendNotification();
2221 application.Render();
2223 // Get the active layer where the text's decoration is added.
2224 Actor activeLayer = editor.GetChildAt( 1u );
2226 // Get the handle's actor.
2227 Actor handle = activeLayer.GetChildAt( 1u );
2228 handle.SetSize( 100.f, 100.f );
2230 // Render and notify
2231 application.SendNotification();
2232 application.Render();
2234 // Touch the grab handle to set it as pressed.
2235 Vector2 touchPos( 10.0f, 50.0f );
2236 Dali::Integration::TouchEvent event;
2237 event = Dali::Integration::TouchEvent();
2238 event.AddPoint( GetPointDownInside( touchPos ) );
2239 application.ProcessEvent( event );
2241 // Render and notify
2242 application.SendNotification();
2243 application.Render();
2245 // drag grab handle right
2246 SendPan(application, Gesture::Possible, touchPos);
2247 SendPan(application, Gesture::Started, touchPos);
2249 Wait(application, 100);
2251 for(int i = 0;i<20;i++)
2253 SendPan(application, Gesture::Continuing, touchPos);
2258 SendPan(application, Gesture::Finished, touchPos);
2261 // Release the grab handle.
2262 event = Dali::Integration::TouchEvent();
2263 event.AddPoint( GetPointUpInside( touchPos ) );
2264 application.ProcessEvent( event );
2266 // Render and notify
2267 application.SendNotification();
2268 application.Render();
2274 int utcDaliTextEditorUnderPropertyStringP(void)
2276 ToolkitTestApplication application;
2277 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2278 TextEditor editor = TextEditor::New();
2279 DALI_TEST_CHECK( editor );
2281 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2283 Stage::GetCurrent().Add( editor );
2285 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2286 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2288 tet_infoline("Set underline settings with a map");
2289 // Check the input underline property
2290 Property::Map underlineMapSet;
2291 Property::Map underlineMapGet;
2292 underlineMapSet.Insert( "enable", "true" );
2293 underlineMapSet.Insert( "color", "blue" );
2294 underlineMapSet.Insert( "height", "2" );
2296 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2297 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2298 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2299 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2301 tet_infoline("Set underline settings with a string");
2302 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2303 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2306 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2308 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2309 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2310 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2311 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2313 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2318 int utcDaliTextEditorShadowPropertyStringP(void)
2320 ToolkitTestApplication application;
2321 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2323 TextEditor editor = TextEditor::New();
2325 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2327 Stage::GetCurrent().Add( editor );
2329 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2331 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2335 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2340 int utcDaliTextEditorFontStylePropertyStringP(void)
2342 ToolkitTestApplication application;
2343 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2345 TextEditor editor = TextEditor::New();
2347 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2349 Stage::GetCurrent().Add( editor );
2351 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2353 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2357 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2362 int utcDaliTextEditorGetPropertyLinecountP(void)
2364 ToolkitTestApplication application;
2366 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2370 TextEditor editor = TextEditor::New();
2371 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2372 editor.SetProperty( TextEditor::Property::TEXT,
2373 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2375 Stage::GetCurrent().Add( editor );
2377 editor.SetSize( 100.0f, 100.0f );
2378 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2379 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2381 editor.SetSize( 50.0f, 100.0f );
2382 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2383 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2388 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2391 ToolkitTestApplication application;
2392 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2394 TextEditor editor = TextEditor::New();
2395 DALI_TEST_CHECK( editor );
2397 Stage::GetCurrent().Add( editor );
2399 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2400 editor.SetSize( 50.f, 50.f );
2401 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2402 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2403 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2404 editor.SetKeyboardFocusable(true);
2406 bool startedCalled = false;
2407 bool finishedCalled = false;
2409 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2410 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2412 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2414 // Render and notify
2415 application.SendNotification();
2416 application.Render();
2418 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2419 application.SendNotification();
2420 application.Render(6000);
2422 application.SendNotification();
2423 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2424 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2429 int UtcDaliToolkitTextEditorTextWrapMode(void)
2431 ToolkitTestApplication application;
2432 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2436 TextEditor editor = TextEditor::New();
2437 editor.SetSize( 150.0f, 300.f );
2438 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2440 Stage::GetCurrent().Add( editor );
2442 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2443 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2445 application.SendNotification();
2446 application.Render();
2448 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2449 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2451 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2452 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2454 application.SendNotification();
2455 application.Render();
2457 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2458 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2460 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2461 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2463 application.SendNotification();
2464 application.Render();
2466 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2467 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2469 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2470 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2472 application.SendNotification();
2473 application.Render();
2475 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2476 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2481 int UtcDaliTextEditorSetPaddingProperty(void)
2483 ToolkitTestApplication application;
2484 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2486 TextEditor editor = TextEditor::New();
2487 DALI_TEST_CHECK( editor );
2488 editor.SetSize( 300.f, 50.f );
2489 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2490 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2491 Stage::GetCurrent().Add( editor );
2493 application.SendNotification();
2494 application.Render();
2496 Vector3 originalSize = editor.GetNaturalSize();
2498 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2500 application.SendNotification();
2501 application.Render();
2503 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2505 Vector3 paddingAddedSize = editor.GetNaturalSize();
2507 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2509 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );