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( 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() );
325 if ( valueGet.first.type == Property::Key::INDEX )
327 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
331 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
341 class ScrollStateChangeCallback : public Dali::ConnectionTracker
344 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
345 : mStartedCalled( startedCalled ),
346 mFinishedCalled( finishedCalled )
350 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
352 if( type == TextEditor::Scroll::STARTED )
354 mStartedCalled = true;
356 else if( type == TextEditor::Scroll::FINISHED )
358 mFinishedCalled = true;
362 bool& mStartedCalled;
363 bool& mFinishedCalled;
368 int UtcDaliToolkitTextEditorConstructorP(void)
370 ToolkitTestApplication application;
371 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
372 TextEditor textEditor;
373 DALI_TEST_CHECK( !textEditor );
377 int UtcDaliToolkitTextEditorNewP(void)
379 ToolkitTestApplication application;
380 tet_infoline(" UtcDaliToolkitTextEditorNewP");
381 TextEditor textEditor = TextEditor::New();
382 DALI_TEST_CHECK( textEditor );
386 int UtcDaliToolkitTextEditorDownCastP(void)
388 ToolkitTestApplication application;
389 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
390 TextEditor textEditor1 = TextEditor::New();
391 BaseHandle object( textEditor1 );
393 TextEditor textEditor2 = TextEditor::DownCast( object );
394 DALI_TEST_CHECK( textEditor2 );
396 TextEditor textEditor3 = DownCast< TextEditor >( object );
397 DALI_TEST_CHECK( textEditor3 );
401 int UtcDaliToolkitTextEditorDownCastN(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
405 BaseHandle uninitializedObject;
406 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
407 DALI_TEST_CHECK( !textEditor1 );
409 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
410 DALI_TEST_CHECK( !textEditor2 );
414 int UtcDaliToolkitTextEditorCopyConstructorP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
418 TextEditor textEditor = TextEditor::New();
419 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
421 TextEditor copy( textEditor );
422 DALI_TEST_CHECK( copy );
423 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
427 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
429 ToolkitTestApplication application;
430 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
431 TextEditor textEditor = TextEditor::New();
432 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
434 TextEditor copy = textEditor;
435 DALI_TEST_CHECK( copy );
436 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
440 int UtcDaliTextEditorNewP(void)
442 ToolkitTestApplication application;
443 tet_infoline(" UtcDaliToolkitTextEditorNewP");
444 TextEditor textEditor = TextEditor::New();
445 DALI_TEST_CHECK( textEditor );
449 // Positive test case for a method
450 int UtcDaliTextEditorGetPropertyP(void)
452 ToolkitTestApplication application;
453 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
454 TextEditor editor = TextEditor::New();
455 DALI_TEST_CHECK( editor );
457 // Check Property Indices are correct
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
472 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
473 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
474 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
475 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
476 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
477 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
478 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
479 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
480 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
481 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
482 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
483 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
484 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
485 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
486 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
514 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
517 Property::Map imageMap;
518 imageMap[mapKey] =mapValue;
520 editor.SetProperty( property , imageMap );
521 Property::Value propValue = editor.GetProperty( property );
522 Property::Map* resultMap = propValue.GetMap();
524 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
532 // Positive test case for a method
533 int UtcDaliTextEditorSetPropertyP(void)
535 ToolkitTestApplication application;
536 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
537 TextEditor editor = TextEditor::New();
538 DALI_TEST_CHECK( editor );
539 Stage::GetCurrent().Add( editor );
541 // Note - we can't check the defaults since the stylesheets are platform-specific
543 // Check the render backend property.
544 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
545 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
547 // Check text property.
548 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
549 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
551 // Check text's color property
552 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
553 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
555 // Check font properties.
556 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
557 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
559 Property::Map fontStyleMapSet;
560 Property::Map fontStyleMapGet;
561 Property::Value* slantValue = NULL;
563 fontStyleMapSet.Insert( "weight", "bold" );
564 fontStyleMapSet.Insert( "width", "condensed" );
565 fontStyleMapSet.Insert( "slant", "italic" );
567 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
568 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
569 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
570 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
572 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
573 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
576 fontStyleMapSet.Clear();
577 fontStyleMapSet.Insert( "weight", "normal" );
578 fontStyleMapSet.Insert( "slant", "oblique" );
579 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
580 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
581 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
582 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
584 fontStyleMapSet.Clear();
585 fontStyleMapSet.Insert( "slant", "roman" );
586 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
587 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
589 // Replace 'roman' for 'normal'.
590 slantValue = fontStyleMapGet.Find( "slant" );
591 if( NULL != slantValue )
593 if( "normal" == slantValue->Get<std::string>() )
595 fontStyleMapGet["slant"] = "roman";
598 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
599 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
601 fontStyleMapSet.Clear();
603 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
604 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
605 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
606 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
608 // Check that the Alignment properties can be correctly set
609 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
610 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
612 // Check scroll properties.
613 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
614 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
615 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
616 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
618 // Check cursor properties
619 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
620 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
621 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
622 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
624 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
625 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
626 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
627 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
628 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
629 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
630 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
631 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
633 // Check handle images
634 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
635 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
636 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
637 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
638 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
640 // Check handle images
641 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
642 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
643 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
644 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
645 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
646 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
648 // Check the highlight color
649 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
650 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
652 // Decoration bounding box
653 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
654 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
656 // Check the enable markup property.
657 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
658 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
659 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
661 // Check input color property.
662 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
663 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
665 // Check input font properties.
666 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
667 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
669 fontStyleMapSet.Clear();
670 fontStyleMapSet.Insert( "weight", "bold" );
671 fontStyleMapSet.Insert( "width", "condensed" );
672 fontStyleMapSet.Insert( "slant", "italic" );
674 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
675 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
676 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
677 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
679 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
680 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
682 // Reset input font style.
683 fontStyleMapSet.Clear();
684 fontStyleMapSet.Insert( "weight", "normal" );
685 fontStyleMapSet.Insert( "slant", "oblique" );
687 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
688 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
689 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
690 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
692 fontStyleMapSet.Clear();
693 fontStyleMapSet.Insert( "slant", "roman" );
695 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
696 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
698 // Replace 'roman' for 'normal'.
699 slantValue = fontStyleMapGet.Find( "slant" );
700 if( NULL != slantValue )
702 if( "normal" == slantValue->Get<std::string>() )
704 fontStyleMapGet["slant"] = "roman";
707 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
708 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
710 fontStyleMapSet.Clear();
712 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
713 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
714 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
715 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
717 // Check the line spacing property
718 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
719 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
720 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
722 // Check the input line spacing property
723 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
724 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
725 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
727 // Check the underline property
729 Property::Map underlineMapSet;
730 Property::Map underlineMapGet;
732 underlineMapSet.Insert( "enable", "true" );
733 underlineMapSet.Insert( "color", "red" );
734 underlineMapSet.Insert( "height", "1" );
736 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
738 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
739 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
740 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
742 // Check the input underline property
743 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
744 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
746 // Check the shadow property
747 Property::Map shadowMapSet;
748 Property::Map shadowMapGet;
750 shadowMapSet.Insert( "color", Color::GREEN );
751 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
752 shadowMapSet.Insert( "blurRadius", 3.0f );
754 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
756 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
757 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
758 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
760 // Check the input shadow property
761 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
762 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
764 // Check the emboss property
765 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
766 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
768 // Check the input emboss property
769 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
770 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
772 // Check the outline property
774 // Test string type first
775 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
776 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
777 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
779 // Then test the property map type
780 Property::Map outlineMapSet;
781 Property::Map outlineMapGet;
783 outlineMapSet["color"] = Color::RED;
784 outlineMapSet["width"] = 2.0f;
786 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
788 outlineMapSet["color"] = "red";
789 outlineMapSet["width"] = "2";
790 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
791 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
792 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
794 // Check the input outline property
795 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
796 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
798 // Check the smooth scroll property
799 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
800 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
801 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
803 // Check the smooth scroll duration property
804 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
805 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
807 // Check the scroll bar property
808 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
809 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
810 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
812 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
813 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
814 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
815 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
817 // Check the pixel size of font
818 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
819 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
821 // Check placeholder text properties.
822 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
823 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
825 // Check placeholder text's color property.
826 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
827 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
829 // Check the enable selection property
830 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
831 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
833 // Check the placeholder property with pixel size
834 Property::Map placeholderPixelSizeMapSet;
835 Property::Map placeholderPixelSizeMapGet;
836 Property::Map placeholderFontstyleMap;
837 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
838 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
839 placeholderPixelSizeMapSet["color"] = Color::BLUE;
840 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
841 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
843 placeholderFontstyleMap.Insert( "weight", "bold" );
844 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
845 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
847 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
848 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
850 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
851 Property::Map placeholderConversionMap;
852 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
853 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
854 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
855 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
856 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
857 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
859 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
861 // Check the placeholder property with point size
862 Property::Map placeholderMapSet;
863 Property::Map placeholderMapGet;
864 placeholderMapSet["text"] = "Setting Placeholder Text";
865 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
866 placeholderMapSet["color"] = Color::RED;
867 placeholderMapSet["fontFamily"] = "Arial";
868 placeholderMapSet["pointSize"] = 12.0f;
869 // Check the placeholder font style property
870 placeholderFontstyleMap.Clear();
872 placeholderFontstyleMap.Insert( "weight", "bold" );
873 placeholderFontstyleMap.Insert( "width", "condensed" );
874 placeholderFontstyleMap.Insert( "slant", "italic" );
875 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
876 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
878 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
879 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
881 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
882 placeholderConversionMap.Clear();
883 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
884 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
885 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
886 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
887 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
888 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
889 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
892 placeholderFontstyleMap.Clear();
893 placeholderFontstyleMap.Insert( "weight", "normal" );
894 placeholderFontstyleMap.Insert( "slant", "oblique" );
895 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
896 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
898 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
899 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
900 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
901 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
903 placeholderFontstyleMap.Clear();
904 placeholderFontstyleMap.Insert( "slant", "roman" );
905 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
906 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
908 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
910 placeholderFontstyleMap.Clear();
911 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
913 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
914 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
915 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
916 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
917 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
919 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
920 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
922 application.SendNotification();
923 application.Render();
928 // Positive Atlas Text Renderer test
929 int utcDaliTextEditorAtlasRenderP(void)
931 ToolkitTestApplication application;
932 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
933 StyleManager styleManager = StyleManager::Get();
934 styleManager.ApplyDefaultTheme();
935 TextEditor editor = TextEditor::New();
936 DALI_TEST_CHECK( editor );
938 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
940 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
942 Stage::GetCurrent().Add( editor );
946 // Render some text with the shared atlas backend
947 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
948 application.SendNotification();
949 application.Render();
953 tet_result(TET_FAIL);
958 // Positive test for the textChanged signal.
959 int utcDaliTextEditorTextChangedP(void)
961 ToolkitTestApplication application;
962 tet_infoline(" utcDaliTextEditorTextChangedP");
963 TextEditor editor = TextEditor::New();
964 DALI_TEST_CHECK( editor );
966 Stage::GetCurrent().Add( editor );
968 // connect to the text changed signal.
969 ConnectionTracker* testTracker = new ConnectionTracker();
970 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
971 bool textChangedSignal = false;
972 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
974 gTextChangedCallBackCalled = false;
975 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
976 DALI_TEST_CHECK( gTextChangedCallBackCalled );
977 DALI_TEST_CHECK( textChangedSignal );
979 application.SendNotification();
981 editor.SetKeyInputFocus();
983 gTextChangedCallBackCalled = false;
984 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
985 DALI_TEST_CHECK( gTextChangedCallBackCalled );
990 int utcDaliTextEditorInputStyleChanged01(void)
992 ToolkitTestApplication application;
993 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
995 // The text-editor emits signals when the input style changes. These changes of style are
996 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
997 // can't be emitted during the size negotiation as the callbacks may update the UI.
998 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
999 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1000 application.CreateAdaptor();
1004 char* pathNamePtr = get_current_dir_name();
1005 const std::string pathName( pathNamePtr );
1006 free( pathNamePtr );
1008 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1009 fontClient.SetDpi( 93u, 93u );
1011 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1012 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1014 TextEditor editor = TextEditor::New();
1015 DALI_TEST_CHECK( editor );
1018 editor.SetSize( 300.f, 50.f );
1019 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1020 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1022 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1023 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1025 // connect to the text changed signal.
1026 ConnectionTracker* testTracker = new ConnectionTracker();
1027 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1028 bool inputStyleChangedSignal = false;
1029 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1031 Stage::GetCurrent().Add( editor );
1033 // Render and notify
1034 application.SendNotification();
1035 application.Render();
1037 // Executes the idle callbacks added by the text control on the change of input style.
1038 application.RunIdles();
1040 gInputStyleChangedCallbackCalled = false;
1041 gInputStyleMask = TextEditor::InputStyle::NONE;
1042 inputStyleChangedSignal = false;
1044 // Create a tap event to touch the text editor.
1045 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1046 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1048 // Render and notify
1049 application.SendNotification();
1050 application.Render();
1052 // Executes the idle callbacks added by the text control on the change of input style.
1053 application.RunIdles();
1055 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1056 if( gInputStyleChangedCallbackCalled )
1058 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1060 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1061 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1063 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1064 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1066 DALI_TEST_CHECK( inputStyleChangedSignal );
1068 gInputStyleChangedCallbackCalled = false;
1069 gInputStyleMask = TextEditor::InputStyle::NONE;
1070 inputStyleChangedSignal = false;
1072 // Create a tap event to touch the text editor.
1073 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1074 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1076 // Render and notify
1077 application.SendNotification();
1078 application.Render();
1080 // Executes the idle callbacks added by the text control on the change of input style.
1081 application.RunIdles();
1083 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1084 DALI_TEST_CHECK( !inputStyleChangedSignal );
1086 gInputStyleChangedCallbackCalled = false;
1087 gInputStyleMask = TextEditor::InputStyle::NONE;
1088 inputStyleChangedSignal = false;
1090 // Create a tap event to touch the text editor.
1091 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1092 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1094 // Render and notify
1095 application.SendNotification();
1096 application.Render();
1098 // Executes the idle callbacks added by the text control on the change of input style.
1099 application.RunIdles();
1101 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1102 if( gInputStyleChangedCallbackCalled )
1104 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1106 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1107 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1109 DALI_TEST_CHECK( inputStyleChangedSignal );
1111 gInputStyleChangedCallbackCalled = false;
1112 gInputStyleMask = TextEditor::InputStyle::NONE;
1113 inputStyleChangedSignal = false;
1115 // Create a tap event to touch the text editor.
1116 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1117 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1119 // Render and notify
1120 application.SendNotification();
1121 application.Render();
1123 // Executes the idle callbacks added by the text control on the change of input style.
1124 application.RunIdles();
1126 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1127 if( gInputStyleChangedCallbackCalled )
1129 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1131 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1132 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1134 Property::Map fontStyleMapSet;
1135 Property::Map fontStyleMapGet;
1137 fontStyleMapSet.Insert( "weight", "bold" );
1139 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1140 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1141 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1143 DALI_TEST_CHECK( inputStyleChangedSignal );
1145 gInputStyleChangedCallbackCalled = false;
1146 gInputStyleMask = TextEditor::InputStyle::NONE;
1147 inputStyleChangedSignal = false;
1149 // Create a tap event to touch the text editor.
1150 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1151 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1153 // Render and notify
1154 application.SendNotification();
1155 application.Render();
1157 // Executes the idle callbacks added by the text control on the change of input style.
1158 application.RunIdles();
1160 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1161 DALI_TEST_CHECK( !inputStyleChangedSignal );
1163 gInputStyleChangedCallbackCalled = false;
1164 gInputStyleMask = TextEditor::InputStyle::NONE;
1165 inputStyleChangedSignal = false;
1167 // Create a tap event to touch the text editor.
1168 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1169 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1171 // Render and notify
1172 application.SendNotification();
1173 application.Render();
1175 // Executes the idle callbacks added by the text control on the change of input style.
1176 application.RunIdles();
1178 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1179 if( gInputStyleChangedCallbackCalled )
1181 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1183 Property::Map fontStyleMapSet;
1184 Property::Map fontStyleMapGet;
1186 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1187 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1188 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1190 DALI_TEST_CHECK( inputStyleChangedSignal );
1192 gInputStyleChangedCallbackCalled = false;
1193 gInputStyleMask = TextEditor::InputStyle::NONE;
1194 inputStyleChangedSignal = false;
1196 // Create a tap event to touch the text editor.
1197 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1198 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1200 // Render and notify
1201 application.SendNotification();
1202 application.Render();
1204 // Executes the idle callbacks added by the text control on the change of input style.
1205 application.RunIdles();
1207 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1208 DALI_TEST_CHECK( !inputStyleChangedSignal );
1213 int utcDaliTextEditorInputStyleChanged02(void)
1215 ToolkitTestApplication application;
1216 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1218 // The text-editor emits signals when the input style changes. These changes of style are
1219 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1220 // can't be emitted during the size negotiation as the callbacks may update the UI.
1221 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1222 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1223 application.CreateAdaptor();
1227 char* pathNamePtr = get_current_dir_name();
1228 const std::string pathName( pathNamePtr );
1229 free( pathNamePtr );
1231 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1232 fontClient.SetDpi( 93u, 93u );
1234 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1235 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1237 TextEditor editor = TextEditor::New();
1238 DALI_TEST_CHECK( editor );
1241 editor.SetSize( 300.f, 50.f );
1242 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1243 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1245 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1246 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>" );
1248 // connect to the text changed signal.
1249 ConnectionTracker* testTracker = new ConnectionTracker();
1250 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1251 bool inputStyleChangedSignal = false;
1252 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1254 Stage::GetCurrent().Add( editor );
1256 // Render and notify
1257 application.SendNotification();
1258 application.Render();
1260 // Executes the idle callbacks added by the text control on the change of input style.
1261 application.RunIdles();
1263 gInputStyleChangedCallbackCalled = false;
1264 gInputStyleMask = TextEditor::InputStyle::NONE;
1265 inputStyleChangedSignal = false;
1267 // Create a tap event to touch the text editor.
1268 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1269 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1270 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1271 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1273 // Render and notify
1274 application.SendNotification();
1275 application.Render();
1277 // Executes the idle callbacks added by the text control on the change of input style.
1278 application.RunIdles();
1280 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1281 if( gInputStyleChangedCallbackCalled )
1283 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1284 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1285 TextEditor::InputStyle::POINT_SIZE |
1286 TextEditor::InputStyle::COLOR ),
1289 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1290 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1292 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1293 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1295 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1296 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1298 DALI_TEST_CHECK( inputStyleChangedSignal );
1300 gInputStyleChangedCallbackCalled = false;
1301 gInputStyleMask = TextEditor::InputStyle::NONE;
1302 inputStyleChangedSignal = false;
1304 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Executes the idle callbacks added by the text control on the change of input style.
1311 application.RunIdles();
1313 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1314 if( gInputStyleChangedCallbackCalled )
1316 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1317 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1320 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1321 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1323 DALI_TEST_CHECK( inputStyleChangedSignal );
1325 gInputStyleChangedCallbackCalled = false;
1326 gInputStyleMask = TextEditor::InputStyle::NONE;
1327 inputStyleChangedSignal = false;
1329 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1331 // Render and notify
1332 application.SendNotification();
1333 application.Render();
1335 // Executes the idle callbacks added by the text control on the change of input style.
1336 application.RunIdles();
1338 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1339 DALI_TEST_CHECK( !inputStyleChangedSignal );
1341 gInputStyleChangedCallbackCalled = false;
1342 gInputStyleMask = TextEditor::InputStyle::NONE;
1343 inputStyleChangedSignal = false;
1345 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1347 // Render and notify
1348 application.SendNotification();
1349 application.Render();
1351 // Executes the idle callbacks added by the text control on the change of input style.
1352 application.RunIdles();
1354 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1355 if( gInputStyleChangedCallbackCalled )
1357 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1358 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1361 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1362 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1364 DALI_TEST_CHECK( inputStyleChangedSignal );
1366 gInputStyleChangedCallbackCalled = false;
1367 gInputStyleMask = TextEditor::InputStyle::NONE;
1368 inputStyleChangedSignal = false;
1370 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1372 Property::Map fontStyleMapSet;
1373 fontStyleMapSet.Insert( "weight", "thin" );
1374 fontStyleMapSet.Insert( "width", "condensed" );
1375 fontStyleMapSet.Insert( "slant", "italic" );
1377 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1378 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1379 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1381 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1382 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1383 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1384 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1386 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1388 // Render and notify
1389 application.SendNotification();
1390 application.Render();
1392 // Executes the idle callbacks added by the text control on the change of input style.
1393 application.RunIdles();
1395 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1396 DALI_TEST_CHECK( !inputStyleChangedSignal );
1398 // Create a tap event to touch the text editor.
1399 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1400 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1402 // Render and notify
1403 application.SendNotification();
1404 application.Render();
1406 // Executes the idle callbacks added by the text control on the change of input style.
1407 application.RunIdles();
1409 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1410 if( gInputStyleChangedCallbackCalled )
1412 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1413 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1414 TextEditor::InputStyle::POINT_SIZE |
1415 TextEditor::InputStyle::FONT_STYLE |
1416 TextEditor::InputStyle::LINE_SPACING |
1417 TextEditor::InputStyle::UNDERLINE |
1418 TextEditor::InputStyle::SHADOW |
1419 TextEditor::InputStyle::EMBOSS |
1420 TextEditor::InputStyle::OUTLINE ),
1423 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1424 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1426 DALI_TEST_CHECK( inputStyleChangedSignal );
1428 gInputStyleChangedCallbackCalled = false;
1429 gInputStyleMask = TextEditor::InputStyle::NONE;
1430 inputStyleChangedSignal = false;
1432 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1434 fontStyleMapSet.Clear();
1435 fontStyleMapSet.Insert( "weight", "black" );
1436 fontStyleMapSet.Insert( "width", "expanded" );
1437 fontStyleMapSet.Insert( "slant", "oblique" );
1439 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1441 // Create a tap event to touch the text editor.
1442 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1443 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1445 // Render and notify
1446 application.SendNotification();
1447 application.Render();
1449 // Executes the idle callbacks added by the text control on the change of input style.
1450 application.RunIdles();
1452 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1453 if( gInputStyleChangedCallbackCalled )
1455 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1456 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1457 TextEditor::InputStyle::POINT_SIZE |
1458 TextEditor::InputStyle::FONT_STYLE ),
1461 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1462 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1464 DALI_TEST_CHECK( inputStyleChangedSignal );
1469 int utcDaliTextEditorEvent01(void)
1471 ToolkitTestApplication application;
1472 tet_infoline(" utcDaliTextEditorEvent01");
1474 // Creates a tap event. After creating a tap event the text editor should
1475 // have the focus and add text with key events should be possible.
1477 TextEditor editor = TextEditor::New();
1478 DALI_TEST_CHECK( editor );
1480 Stage::GetCurrent().Add( editor );
1482 editor.SetSize( 300.f, 50.f );
1483 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1484 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1486 // Avoid a crash when core load gl resources.
1487 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1489 // Render and notify
1490 application.SendNotification();
1491 application.Render();
1493 // Add a key event but as the text editor has not the focus it should do nothing.
1494 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1496 // Render and notify
1497 application.SendNotification();
1498 application.Render();
1500 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1502 // Create a tap event to touch the text editor.
1503 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1504 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1506 // Render and notify
1507 application.SendNotification();
1508 application.Render();
1510 // Now the text editor has the focus, so it can handle the key events.
1511 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1512 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1514 // Render and notify
1515 application.SendNotification();
1516 application.Render();
1518 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1520 // Create a second text editor and send key events to it.
1521 TextEditor editor2 = TextEditor::New();
1523 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1524 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1525 editor2.SetSize( 100.f, 100.f );
1526 editor2.SetPosition( 100.f, 100.f );
1528 Stage::GetCurrent().Add( editor2 );
1530 // Render and notify
1531 application.SendNotification();
1532 application.Render();
1534 // Create a tap event on the second text editor.
1535 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1536 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1538 // Render and notify
1539 application.SendNotification();
1540 application.Render();
1542 // The second text editor has the focus. It should handle the key events.
1543 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1544 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1546 // Render and notify
1547 application.SendNotification();
1548 application.Render();
1550 // Check the text has been added to the second text editor.
1551 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1556 int utcDaliTextEditorEvent02(void)
1558 ToolkitTestApplication application;
1559 tet_infoline(" utcDaliTextEditorEvent02");
1561 // Checks if the right number of actors are created.
1563 TextEditor editor = TextEditor::New();
1564 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1565 DALI_TEST_CHECK( editor );
1567 Stage::GetCurrent().Add( editor );
1569 editor.SetSize( 300.f, 50.f );
1570 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1571 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1573 // Avoid a crash when core load gl resources.
1574 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Check there are the expected number of children (the stencil).
1581 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1583 Actor stencil = editor.GetChildAt( 0u );
1585 // Create a tap event to touch the text editor.
1586 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1587 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1589 // Render and notify
1590 application.SendNotification();
1591 application.Render();
1593 Actor layer = editor.GetChildAt( 1u );
1594 DALI_TEST_CHECK( layer.IsLayer() );
1596 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1597 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1599 // Now the text editor has the focus, so it can handle the key events.
1600 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1601 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1603 // Render and notify
1604 application.SendNotification();
1605 application.Render();
1607 // Checks the cursor and the renderer have been created.
1608 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1609 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1611 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1612 DALI_TEST_CHECK( cursor );
1614 // The stencil actor has a container with all the actors which contain the text renderers.
1615 Actor container = stencil.GetChildAt( 0u );
1616 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1618 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1619 DALI_TEST_CHECK( renderer );
1622 // Move the cursor and check the position changes.
1623 Vector3 position1 = cursor.GetCurrentPosition();
1625 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1626 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 Vector3 position2 = cursor.GetCurrentPosition();
1634 DALI_TEST_CHECK( position2.x < position1.x );
1636 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1637 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 Vector3 position3 = cursor.GetCurrentPosition();
1645 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1647 // Send some taps and check the cursor positions.
1649 // Try to tap at the beginning.
1650 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1651 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1653 // Render and notify
1654 application.SendNotification();
1655 application.Render();
1657 // Cursor position should be the same than position1.
1658 Vector3 position4 = cursor.GetCurrentPosition();
1660 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1662 // Tap away from the start position.
1663 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1664 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 Vector3 position5 = cursor.GetCurrentPosition();
1672 DALI_TEST_CHECK( position5.x > position4.x );
1674 // Remove all the text.
1675 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1676 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1677 editor.SetProperty( TextEditor::Property::TEXT, "" );
1679 // Render and notify
1680 application.SendNotification();
1681 application.Render();
1683 // Cursor position should be the same than position2.
1684 Vector3 position6 = cursor.GetCurrentPosition();
1686 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1688 // Should not be a renderer.
1689 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1694 int utcDaliTextEditorEvent03(void)
1696 ToolkitTestApplication application;
1697 tet_infoline(" utcDaliTextEditorEvent03");
1699 // Checks if the highlight actor is created.
1701 TextEditor editor = TextEditor::New();
1702 DALI_TEST_CHECK( editor );
1704 Stage::GetCurrent().Add( editor );
1706 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1707 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1708 editor.SetSize( 30.f, 50.f );
1709 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1710 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1712 // Avoid a crash when core load gl resources.
1713 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Send some taps and check text controller with clipboard window
1720 Dali::Clipboard clipboard = Clipboard::Get();
1721 clipboard.ShowClipboard();
1722 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1723 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1724 clipboard.HideClipboard();
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 // Tap first to get the focus.
1731 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1732 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1734 // Render and notify
1735 application.SendNotification();
1736 application.Render();
1738 // Double tap to select a word.
1739 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1740 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1742 // Render and notify
1743 application.SendNotification();
1744 application.Render();
1746 // The stencil actor should have two actors: the renderer and the highlight actor.
1747 Actor stencil = editor.GetChildAt( 0u );
1749 // Highlight needs to be drawn before text, so should come first in child order
1750 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1751 DALI_TEST_CHECK( highlight );
1753 // The stencil actor has a container with all the actors which contain the text renderers.
1754 Actor container = stencil.GetChildAt( 1u );
1755 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1757 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1758 DALI_TEST_CHECK( renderer );
1761 // Double tap out of bounds
1762 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1763 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 // The stencil actor should have one actors: the renderer actor.
1770 stencil = editor.GetChildAt( 0u );
1772 // The stencil actor has a container with all the actors which contain the text renderers.
1773 container = stencil.GetChildAt( 0u );
1774 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1776 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1777 DALI_TEST_CHECK( renderer );
1781 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1782 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1784 // Render and notify
1785 application.SendNotification();
1786 application.Render();
1791 int utcDaliTextEditorEvent04(void)
1793 ToolkitTestApplication application;
1794 tet_infoline(" utcDaliTextEditorEvent04");
1796 // Checks if the highlight actor is created.
1798 TextEditor editor = TextEditor::New();
1799 DALI_TEST_CHECK( editor );
1801 Stage::GetCurrent().Add( editor );
1803 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1804 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1805 editor.SetSize( 100.f, 50.f );
1806 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1807 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1809 // Avoid a crash when core load gl resources.
1810 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1812 // Render and notify
1813 application.SendNotification();
1814 application.Render();
1816 // Tap on the text editor
1817 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1818 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 // Move at the end of the text.
1825 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1826 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1828 // Render and notify
1829 application.SendNotification();
1830 application.Render();
1832 for( unsigned int index = 0u; index < 10u; ++index )
1834 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1835 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1837 // Render and notify
1838 application.SendNotification();
1839 application.Render();
1843 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1851 // Add some key events
1852 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1853 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 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_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1862 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 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( " ", " ", KEY_WHITE_SPACE_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 );
1881 int utcDaliTextEditorEvent05(void)
1883 ToolkitTestApplication application;
1884 tet_infoline(" utcDaliTextEditorEvent05");
1886 // Checks if the highlight actor is created.
1888 TextEditor editor = TextEditor::New();
1889 DALI_TEST_CHECK( editor );
1891 Stage::GetCurrent().Add( editor );
1893 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1894 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1895 editor.SetSize( 50.f, 50.f );
1896 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1897 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1898 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1899 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1900 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1901 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1902 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1904 // Avoid a crash when core load gl resources.
1905 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1907 // Render and notify
1908 application.SendNotification();
1909 application.Render();
1911 // Tap on the text editor
1912 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1913 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1915 // Render and notify
1916 application.SendNotification();
1917 application.Render();
1919 // Move at the end of the text.
1920 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1921 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1923 // Render and notify
1924 application.SendNotification();
1925 application.Render();
1927 for( unsigned int index = 0u; index < 10u; ++index )
1930 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1932 // Render and notify
1933 application.SendNotification();
1934 application.Render();
1936 // Modify duration after scroll is enabled
1937 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1939 // Continuous scroll left to increase coverage
1940 for( unsigned int index = 0u; index < 10u; ++index )
1942 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1944 // Render and notify
1945 application.SendNotification();
1946 application.Render();
1948 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1949 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1950 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1951 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1952 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1954 // Press Escape to increase coverage
1955 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1956 application.SendNotification();
1957 application.Render();
1959 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1964 int utcDaliTextEditorEvent06(void)
1966 ToolkitTestApplication application;
1967 tet_infoline(" utcDaliTextEditorEvent06");
1969 // Checks if the highlight actor is created.
1971 TextEditor editor = TextEditor::New();
1972 DALI_TEST_CHECK( editor );
1974 Stage::GetCurrent().Add( editor );
1976 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1977 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1978 editor.SetSize( 100.f, 50.f );
1979 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1980 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1982 // Avoid a crash when core load gl resources.
1983 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1985 // Render and notify
1986 application.SendNotification();
1987 application.Render();
1989 // Tap on the text editor
1990 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1991 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1993 // Render and notify
1994 application.SendNotification();
1995 application.Render();
1997 // Move to seconds line of the text.
1998 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2000 // Render and notify
2001 application.SendNotification();
2002 application.Render();
2004 float layoutHeight = editor.GetHeightForWidth( 100.f );
2007 // Add another script characters ( glyph height is defferent )
2008 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2009 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2011 // Delete characters
2012 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2013 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2015 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2017 // Render and notify
2018 application.SendNotification();
2019 application.Render();
2021 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2024 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2025 application.SendNotification();
2026 application.Render();
2028 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2029 application.SendNotification();
2030 application.Render();
2032 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2033 application.SendNotification();
2034 application.Render();
2036 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2037 application.SendNotification();
2038 application.Render();
2040 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2041 application.SendNotification();
2042 application.Render();
2044 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 application.SendNotification();
2046 application.Render();
2048 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2049 application.SendNotification();
2050 application.Render();
2055 int utcDaliTextEditorEvent07(void)
2057 ToolkitTestApplication application;
2058 tet_infoline(" utcDaliTextEditorEvent07");
2060 // Checks if the highlight actor is created.
2062 TextEditor editor = TextEditor::New();
2063 DALI_TEST_CHECK( editor );
2065 Stage::GetCurrent().Add( editor );
2067 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2068 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2069 editor.SetSize( 100.f, 50.f );
2070 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2071 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2073 // Avoid a crash when core load gl resources.
2074 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2076 // Render and notify
2077 application.SendNotification();
2078 application.Render();
2080 // Tap on the text editor
2081 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2082 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2084 // Render and notify
2085 application.SendNotification();
2086 application.Render();
2088 // Move to second line of the text.
2089 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091 // Render and notify
2092 application.SendNotification();
2093 application.Render();
2095 // Select some text in the right of the current cursor position
2096 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2097 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2098 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2099 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2101 // Render and notify
2102 application.SendNotification();
2103 application.Render();
2105 // Cut the selected text
2106 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2113 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2115 // Select some text in the left of the current cursor position
2116 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2117 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2118 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2119 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2125 // Copy the selected text
2126 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2127 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 // Render and notify
2130 application.SendNotification();
2131 application.Render();
2133 // Move the cursor to the third line
2134 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2135 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 // Paste the selected text at the current cursor position
2142 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2143 application.ProcessEvent( GenerateKey( "v", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2149 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2154 int utcDaliTextEditorHandles(void)
2156 ToolkitTestApplication application;
2157 tet_infoline(" utcDaliTextEditorHandles");
2159 TextEditor editor = TextEditor::New();
2160 DALI_TEST_CHECK( editor );
2162 Stage::GetCurrent().Add( editor );
2164 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2165 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2166 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2167 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2169 editor.SetSize( 30.f, 500.f );
2170 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2171 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2173 // Avoid a crash when core load gl resources.
2174 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2176 // Render and notify
2177 application.SendNotification();
2178 application.Render();
2180 // Tap first to get the focus.
2181 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2182 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2184 // Render and notify
2185 application.SendNotification();
2186 application.Render();
2188 // Tap to create the grab handle.
2189 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2190 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 // Get the active layer where the text's decoration is added.
2197 Actor activeLayer = editor.GetChildAt( 1u );
2199 // Get the handle's actor.
2200 Actor handle = activeLayer.GetChildAt( 1u );
2201 handle.SetSize( 100.f, 100.f );
2203 // Render and notify
2204 application.SendNotification();
2205 application.Render();
2207 // Touch the grab handle to set it as pressed.
2208 Vector2 touchPos( 10.0f, 50.0f );
2209 Dali::Integration::TouchEvent event;
2210 event = Dali::Integration::TouchEvent();
2211 event.AddPoint( GetPointDownInside( touchPos ) );
2212 application.ProcessEvent( event );
2214 // Render and notify
2215 application.SendNotification();
2216 application.Render();
2218 // drag grab handle right
2219 SendPan(application, Gesture::Possible, touchPos);
2220 SendPan(application, Gesture::Started, touchPos);
2222 Wait(application, 100);
2224 for(int i = 0;i<20;i++)
2226 SendPan(application, Gesture::Continuing, touchPos);
2231 SendPan(application, Gesture::Finished, touchPos);
2234 // Release the grab handle.
2235 event = Dali::Integration::TouchEvent();
2236 event.AddPoint( GetPointUpInside( touchPos ) );
2237 application.ProcessEvent( event );
2239 // Render and notify
2240 application.SendNotification();
2241 application.Render();
2247 int utcDaliTextEditorUnderPropertyStringP(void)
2249 ToolkitTestApplication application;
2250 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2251 TextEditor editor = TextEditor::New();
2252 DALI_TEST_CHECK( editor );
2254 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2256 Stage::GetCurrent().Add( editor );
2258 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2259 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2261 tet_infoline("Set underline settings with a map");
2262 // Check the input underline property
2263 Property::Map underlineMapSet;
2264 Property::Map underlineMapGet;
2265 underlineMapSet.Insert( "enable", "true" );
2266 underlineMapSet.Insert( "color", "blue" );
2267 underlineMapSet.Insert( "height", "2" );
2269 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2270 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2271 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2272 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2274 tet_infoline("Set underline settings with a string");
2275 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2276 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2279 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2281 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2282 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2283 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2284 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2286 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2291 int utcDaliTextEditorShadowPropertyStringP(void)
2293 ToolkitTestApplication application;
2294 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2296 TextEditor editor = TextEditor::New();
2298 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2300 Stage::GetCurrent().Add( editor );
2302 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2304 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2308 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2313 int utcDaliTextEditorFontStylePropertyStringP(void)
2315 ToolkitTestApplication application;
2316 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2318 TextEditor editor = TextEditor::New();
2320 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2322 Stage::GetCurrent().Add( editor );
2324 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2326 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2330 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2335 int utcDaliTextEditorGetPropertyLinecountP(void)
2337 ToolkitTestApplication application;
2339 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2343 TextEditor editor = TextEditor::New();
2344 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2345 editor.SetProperty( TextEditor::Property::TEXT,
2346 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2348 Stage::GetCurrent().Add( editor );
2350 editor.SetSize( 100.0f, 100.0f );
2351 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2352 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2354 editor.SetSize( 50.0f, 100.0f );
2355 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2356 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2361 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2364 ToolkitTestApplication application;
2365 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2367 TextEditor editor = TextEditor::New();
2368 DALI_TEST_CHECK( editor );
2370 Stage::GetCurrent().Add( editor );
2372 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2373 editor.SetSize( 50.f, 50.f );
2374 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2375 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2376 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2377 editor.SetKeyboardFocusable(true);
2379 bool startedCalled = false;
2380 bool finishedCalled = false;
2382 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2383 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2385 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2387 // Render and notify
2388 application.SendNotification();
2389 application.Render();
2391 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2392 application.SendNotification();
2393 application.Render(6000);
2395 application.SendNotification();
2396 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2397 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2402 int UtcDaliToolkitTextEditorTextWrapMode(void)
2404 ToolkitTestApplication application;
2405 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2409 TextEditor editor = TextEditor::New();
2410 editor.SetSize( 150.0f, 300.f );
2411 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2413 Stage::GetCurrent().Add( editor );
2415 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2416 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2418 application.SendNotification();
2419 application.Render();
2421 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2422 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2424 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2425 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2427 application.SendNotification();
2428 application.Render();
2430 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2431 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2433 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2434 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2436 application.SendNotification();
2437 application.Render();
2439 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2440 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2442 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2443 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2445 application.SendNotification();
2446 application.Render();
2448 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2449 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2454 int UtcDaliTextEditorSetPaddingProperty(void)
2456 ToolkitTestApplication application;
2457 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2459 TextEditor editor = TextEditor::New();
2460 DALI_TEST_CHECK( editor );
2461 editor.SetSize( 300.f, 50.f );
2462 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2463 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2464 Stage::GetCurrent().Add( editor );
2466 application.SendNotification();
2467 application.Render();
2469 Vector3 originalSize = editor.GetNaturalSize();
2471 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2473 application.SendNotification();
2474 application.Render();
2476 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2478 Vector3 paddingAddedSize = editor.GetNaturalSize();
2480 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2482 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );