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/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25 #include <dali/integration-api/events/tap-gesture-event.h>
26 #include <dali/integration-api/events/pan-gesture-event.h>
27 #include <dali-toolkit-test-suite-utils.h>
28 #include <dali-toolkit/dali-toolkit.h>
29 #include <dali-toolkit/devel-api/controls/control-devel.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
33 using namespace Toolkit;
35 void dali_texteditor_startup(void)
37 test_return_value = TET_UNDEF;
40 void dali_texteditor_cleanup(void)
42 test_return_value = TET_PASS;
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
56 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
57 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
58 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
59 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
60 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
62 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
63 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
71 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
72 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
73 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
74 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
75 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
76 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
77 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
79 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
80 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
81 const char* const PROPERTY_NAME_UNDERLINE = "underline";
82 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
83 const char* const PROPERTY_NAME_SHADOW = "shadow";
84 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
85 const char* const PROPERTY_NAME_EMBOSS = "emboss";
86 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
87 const char* const PROPERTY_NAME_OUTLINE = "outline";
88 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
90 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
92 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
93 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
94 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
95 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
96 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
97 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
99 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
100 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
104 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
105 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
107 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
108 const float TO_MILLISECONDS = 1000.f;
109 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const float SCROLL_THRESHOLD = 10.f;
113 const float SCROLL_SPEED = 300.f;
115 const unsigned int DEFAULT_FONT_SIZE = 1152u;
116 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
118 const int KEY_A_CODE = 38;
119 const int KEY_D_CODE = 40;
120 const int KEY_WHITE_SPACE_CODE = 65;
122 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
124 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126 static bool gTextChangedCallBackCalled;
127 static bool gInputStyleChangedCallbackCalled;
128 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
130 struct CallbackFunctor
132 CallbackFunctor(bool* callbackFlag)
133 : mCallbackFlag( callbackFlag )
139 *mCallbackFlag = true;
144 static void TestTextChangedCallback( TextEditor control )
146 tet_infoline(" TestTextChangedCallback");
148 gTextChangedCallBackCalled = true;
151 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
153 tet_infoline(" TestInputStyleChangedCallback");
155 gInputStyleChangedCallbackCalled = true;
156 gInputStyleMask = mask;
159 // Generate a TapGestureEvent to send to Core.
160 Integration::TapGestureEvent GenerateTap(
161 Gesture::State state,
162 unsigned int numberOfTaps,
163 unsigned int numberOfTouches,
166 Integration::TapGestureEvent tap( state );
168 tap.numberOfTaps = numberOfTaps;
169 tap.numberOfTouches = numberOfTouches;
175 // Generate a PanGestureEvent to send to Core
176 Integration::PanGestureEvent GeneratePan( Gesture::State state,
177 const Vector2& previousPosition,
178 const Vector2& currentPosition,
179 unsigned long timeDelta,
180 unsigned int numberOfTouches = 1u )
182 Integration::PanGestureEvent pan(state);
184 pan.previousPosition = previousPosition;
185 pan.currentPosition = currentPosition;
186 pan.timeDelta = timeDelta;
187 pan.numberOfTouches = numberOfTouches;
192 // Generate a KeyEvent to send to Core.
193 Integration::KeyEvent GenerateKey( const std::string& keyName,
194 const std::string& keyString,
197 unsigned long timeStamp,
198 const Integration::KeyEvent::State& keyState,
199 const std::string& deviceName,
200 const DevelKeyEvent::DeviceClass::Type& deviceClass )
202 return Integration::KeyEvent( keyName,
213 * Helper to generate PanGestureEvent
215 * @param[in] application Application instance
216 * @param[in] state The Gesture State
217 * @param[in] pos The current position of touch.
219 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
223 if( (state == Gesture::Started) ||
224 (state == Gesture::Possible) )
230 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
237 * Simulate time passed by.
239 * @note this will always process at least 1 frame (1/60 sec)
241 * @param application Test application instance
242 * @param duration Time to pass in milliseconds.
243 * @return The actual time passed in milliseconds
245 static int Wait(ToolkitTestApplication& application, int duration = 0)
249 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
251 application.SendNotification();
252 application.Render(RENDER_FRAME_INTERVAL);
253 time += RENDER_FRAME_INTERVAL;
259 Dali::Integration::Point GetPointDownInside( Vector2& pos )
261 Dali::Integration::Point point;
262 point.SetState( PointState::DOWN );
263 point.SetScreenPosition( pos );
267 Dali::Integration::Point GetPointUpInside( Vector2& pos )
269 Dali::Integration::Point point;
270 point.SetState( PointState::UP );
271 point.SetScreenPosition( pos );
275 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
277 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
279 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
281 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
283 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
284 if( NULL != valueSet )
286 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
288 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
294 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
303 class ScrollStateChangeCallback : public Dali::ConnectionTracker
306 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
307 : mStartedCalled( startedCalled ),
308 mFinishedCalled( finishedCalled )
312 void Callback( TextEditor editor, DevelTextEditor::Scroll::Type type )
314 if( type == DevelTextEditor::Scroll::STARTED )
316 mStartedCalled = true;
318 else if( type == DevelTextEditor::Scroll::FINISHED )
320 mFinishedCalled = true;
324 bool& mStartedCalled;
325 bool& mFinishedCalled;
330 int UtcDaliToolkitTextEditorConstructorP(void)
332 ToolkitTestApplication application;
333 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
334 TextEditor textEditor;
335 DALI_TEST_CHECK( !textEditor );
339 int UtcDaliToolkitTextEditorNewP(void)
341 ToolkitTestApplication application;
342 tet_infoline(" UtcDaliToolkitTextEditorNewP");
343 TextEditor textEditor = TextEditor::New();
344 DALI_TEST_CHECK( textEditor );
348 int UtcDaliToolkitTextEditorDownCastP(void)
350 ToolkitTestApplication application;
351 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
352 TextEditor textEditor1 = TextEditor::New();
353 BaseHandle object( textEditor1 );
355 TextEditor textEditor2 = TextEditor::DownCast( object );
356 DALI_TEST_CHECK( textEditor2 );
358 TextEditor textEditor3 = DownCast< TextEditor >( object );
359 DALI_TEST_CHECK( textEditor3 );
363 int UtcDaliToolkitTextEditorDownCastN(void)
365 ToolkitTestApplication application;
366 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
367 BaseHandle uninitializedObject;
368 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
369 DALI_TEST_CHECK( !textEditor1 );
371 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
372 DALI_TEST_CHECK( !textEditor2 );
376 int UtcDaliToolkitTextEditorCopyConstructorP(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
380 TextEditor textEditor = TextEditor::New();
381 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
383 TextEditor copy( textEditor );
384 DALI_TEST_CHECK( copy );
385 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
389 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
391 ToolkitTestApplication application;
392 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
393 TextEditor textEditor = TextEditor::New();
394 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
396 TextEditor copy = textEditor;
397 DALI_TEST_CHECK( copy );
398 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
402 int UtcDaliTextEditorNewP(void)
404 ToolkitTestApplication application;
405 tet_infoline(" UtcDaliToolkitTextEditorNewP");
406 TextEditor textEditor = TextEditor::New();
407 DALI_TEST_CHECK( textEditor );
411 // Positive test case for a method
412 int UtcDaliTextEditorGetPropertyP(void)
414 ToolkitTestApplication application;
415 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
416 TextEditor editor = TextEditor::New();
417 DALI_TEST_CHECK( editor );
419 // Check Property Indices are correct
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
444 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
445 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
446 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
447 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
448 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
449 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
451 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
452 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
453 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
454 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
455 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
456 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
457 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
458 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
459 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
460 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
461 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
462 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
463 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
464 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
465 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
466 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
467 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
468 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
469 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
470 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == DevelTextEditor::Property::ENABLE_SELECTION );
471 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == DevelTextEditor::Property::PLACEHOLDER );
476 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
479 Property::Map imageMap;
480 imageMap[mapKey] =mapValue;
482 editor.SetProperty( property , imageMap );
483 Property::Value propValue = editor.GetProperty( property );
484 Property::Map* resultMap = propValue.GetMap();
486 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
494 // Positive test case for a method
495 int UtcDaliTextEditorSetPropertyP(void)
497 ToolkitTestApplication application;
498 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
499 TextEditor editor = TextEditor::New();
500 DALI_TEST_CHECK( editor );
501 Stage::GetCurrent().Add( editor );
503 // Note - we can't check the defaults since the stylesheets are platform-specific
505 // Check the render backend property.
506 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
507 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
509 // Check text property.
510 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
511 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
513 // Check text's color property
514 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
515 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
517 // Check font properties.
518 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
519 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
521 Property::Map fontStyleMapSet;
522 Property::Map fontStyleMapGet;
523 Property::Value* slantValue = NULL;
525 fontStyleMapSet.Insert( "weight", "bold" );
526 fontStyleMapSet.Insert( "width", "condensed" );
527 fontStyleMapSet.Insert( "slant", "italic" );
529 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
530 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
531 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
532 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
534 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
535 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
538 fontStyleMapSet.Clear();
539 fontStyleMapSet.Insert( "weight", "normal" );
540 fontStyleMapSet.Insert( "slant", "oblique" );
541 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
542 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
543 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
544 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
546 fontStyleMapSet.Clear();
547 fontStyleMapSet.Insert( "slant", "roman" );
548 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
549 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
551 // Replace 'roman' for 'normal'.
552 slantValue = fontStyleMapGet.Find( "slant" );
553 if( NULL != slantValue )
555 if( "normal" == slantValue->Get<std::string>() )
557 fontStyleMapGet["slant"] = "roman";
560 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
561 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
563 fontStyleMapSet.Clear();
565 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
566 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
567 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
568 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
570 // Check that the Alignment properties can be correctly set
571 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
572 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
574 // Check scroll properties.
575 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
576 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
577 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
578 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
580 // Check cursor properties
581 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
582 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
583 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
584 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
586 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
587 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
588 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
589 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
590 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
591 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
592 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
593 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
595 // Check handle images
596 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
597 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
598 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
599 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
600 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
602 // Check handle images
603 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
604 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
605 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
606 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
607 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
608 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
610 // Check the highlight color
611 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
612 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
614 // Decoration bounding box
615 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
616 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
618 // Check the enable markup property.
619 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
620 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
621 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
623 // Check input color property.
624 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
625 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
627 // Check input font properties.
628 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
629 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
631 fontStyleMapSet.Clear();
632 fontStyleMapSet.Insert( "weight", "bold" );
633 fontStyleMapSet.Insert( "width", "condensed" );
634 fontStyleMapSet.Insert( "slant", "italic" );
636 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
637 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
638 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
639 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
641 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
642 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
644 // Reset input font style.
645 fontStyleMapSet.Clear();
646 fontStyleMapSet.Insert( "weight", "normal" );
647 fontStyleMapSet.Insert( "slant", "oblique" );
649 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
650 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
651 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
652 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
654 fontStyleMapSet.Clear();
655 fontStyleMapSet.Insert( "slant", "roman" );
657 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
658 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
660 // Replace 'roman' for 'normal'.
661 slantValue = fontStyleMapGet.Find( "slant" );
662 if( NULL != slantValue )
664 if( "normal" == slantValue->Get<std::string>() )
666 fontStyleMapGet["slant"] = "roman";
669 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
670 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
672 fontStyleMapSet.Clear();
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 // Check the line spacing property
680 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
681 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
682 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
684 // Check the input line spacing property
685 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
686 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
687 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
689 // Check the underline property
691 Property::Map underlineMapSet;
692 Property::Map underlineMapGet;
694 underlineMapSet.Insert( "enable", "true" );
695 underlineMapSet.Insert( "color", "red" );
696 underlineMapSet.Insert( "height", "1" );
698 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
700 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
701 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
702 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
704 // Check the input underline property
705 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
706 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
708 // Check the shadow property
709 Property::Map shadowMapSet;
710 Property::Map shadowMapGet;
712 shadowMapSet.Insert( "color", "green" );
713 shadowMapSet.Insert( "offset", "2 2" );
715 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
717 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
718 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
719 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
721 // Check the input shadow property
722 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
723 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
725 // Check the emboss property
726 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
727 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
729 // Check the input emboss property
730 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
731 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
733 // Check the outline property
734 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
735 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
737 // Check the input outline property
738 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
739 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
741 // Check the smooth scroll property
742 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
743 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
744 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
746 // Check the smooth scroll duration property
747 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
748 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
750 // Check the scroll bar property
751 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
752 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
753 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
755 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
756 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
757 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
758 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
760 // Check the pixel size of font
761 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
762 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
764 // Check placeholder text properties.
765 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
766 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
768 // Check placeholder text properties when focused.
769 editor.SetProperty( DevelControl::Property::STATE, "FOCUSED" );
770 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Focused Placeholder Text" );
771 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelControl::Property::STATE ), (int)DevelControl::FOCUSED, TEST_LOCATION );
772 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Focused Placeholder Text"), TEST_LOCATION );
774 // Check placeholder text's color property.
775 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
776 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
778 // Check the enable selection property
779 editor.SetProperty( DevelTextEditor::Property::ENABLE_SELECTION, false );
780 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
782 // Check the placeholder property with pixel size
783 Property::Map placeholderPixelSizeMapSet;
784 Property::Map placeholderPixelSizeMapGet;
785 Property::Map placeholderFontstyleMap;
786 placeholderPixelSizeMapSet["placeholderText"] = "Setting Placeholder Text";
787 placeholderPixelSizeMapSet["placeholderColor"] = Color::BLUE;
788 placeholderPixelSizeMapSet["placeholderFontFamily"] = "Arial";
789 placeholderPixelSizeMapSet["placeholderPixelSize"] = 15.0f;
791 placeholderFontstyleMap.Insert( "weight", "bold" );
792 placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
793 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
795 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
796 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
797 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
799 // Check the placeholder property with point size
800 Property::Map placeholderMapSet;
801 Property::Map placeholderMapGet;
802 placeholderMapSet["placeholderText"] = "Setting Placeholder Text";
803 placeholderMapSet["placeholderColor"] = Color::RED;
804 placeholderMapSet["placeholderFontFamily"] = "Arial";
805 placeholderMapSet["placeholderPointSize"] = 12.0f;
807 // Check the placeholder font style property
808 placeholderFontstyleMap.Clear();
810 placeholderFontstyleMap.Insert( "weight", "bold" );
811 placeholderFontstyleMap.Insert( "width", "condensed" );
812 placeholderFontstyleMap.Insert( "slant", "italic" );
813 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
814 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
816 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
817 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
818 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
821 placeholderFontstyleMap.Clear();
822 placeholderFontstyleMap.Insert( "weight", "normal" );
823 placeholderFontstyleMap.Insert( "slant", "oblique" );
824 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
825 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
827 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
828 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
829 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
831 placeholderFontstyleMap.Clear();
832 placeholderFontstyleMap.Insert( "slant", "roman" );
833 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
834 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
836 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
838 placeholderFontstyleMap.Clear();
839 placeholderMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
841 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER, placeholderMapSet );
842 placeholderMapGet = editor.GetProperty<Property::Map>( DevelTextEditor::Property::PLACEHOLDER );
843 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
844 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
849 // Positive Atlas Text Renderer test
850 int utcDaliTextEditorAtlasRenderP(void)
852 ToolkitTestApplication application;
853 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
854 StyleManager styleManager = StyleManager::Get();
855 styleManager.ApplyDefaultTheme();
856 TextEditor editor = TextEditor::New();
857 DALI_TEST_CHECK( editor );
859 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
861 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
863 Stage::GetCurrent().Add( editor );
867 // Render some text with the shared atlas backend
868 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
869 application.SendNotification();
870 application.Render();
874 tet_result(TET_FAIL);
879 // Positive test for the textChanged signal.
880 int utcDaliTextEditorTextChangedP(void)
882 ToolkitTestApplication application;
883 tet_infoline(" utcDaliTextEditorTextChangedP");
884 TextEditor editor = TextEditor::New();
885 DALI_TEST_CHECK( editor );
887 Stage::GetCurrent().Add( editor );
889 // connect to the text changed signal.
890 ConnectionTracker* testTracker = new ConnectionTracker();
891 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
892 bool textChangedSignal = false;
893 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
895 gTextChangedCallBackCalled = false;
896 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
897 DALI_TEST_CHECK( gTextChangedCallBackCalled );
898 DALI_TEST_CHECK( textChangedSignal );
900 application.SendNotification();
902 editor.SetKeyInputFocus();
904 gTextChangedCallBackCalled = false;
905 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
906 DALI_TEST_CHECK( gTextChangedCallBackCalled );
911 int utcDaliTextEditorInputStyleChanged01(void)
913 ToolkitTestApplication application;
914 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
916 // The text-editor emits signals when the input style changes. These changes of style are
917 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
918 // can't be emitted during the size negotiation as the callbacks may update the UI.
919 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
920 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
921 application.CreateAdaptor();
925 char* pathNamePtr = get_current_dir_name();
926 const std::string pathName( pathNamePtr );
929 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
930 fontClient.SetDpi( 93u, 93u );
932 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
933 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
935 TextEditor editor = TextEditor::New();
936 DALI_TEST_CHECK( editor );
939 editor.SetSize( 300.f, 50.f );
940 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
941 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
943 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
944 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
946 // connect to the text changed signal.
947 ConnectionTracker* testTracker = new ConnectionTracker();
948 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
949 bool inputStyleChangedSignal = false;
950 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
952 Stage::GetCurrent().Add( editor );
955 application.SendNotification();
956 application.Render();
958 // Executes the idle callbacks added by the text control on the change of input style.
959 application.RunIdles();
961 gInputStyleChangedCallbackCalled = false;
962 gInputStyleMask = TextEditor::InputStyle::NONE;
963 inputStyleChangedSignal = false;
965 // Create a tap event to touch the text editor.
966 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
967 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
970 application.SendNotification();
971 application.Render();
973 // Executes the idle callbacks added by the text control on the change of input style.
974 application.RunIdles();
976 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
977 if( gInputStyleChangedCallbackCalled )
979 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
981 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
982 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
984 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
985 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
987 DALI_TEST_CHECK( inputStyleChangedSignal );
989 gInputStyleChangedCallbackCalled = false;
990 gInputStyleMask = TextEditor::InputStyle::NONE;
991 inputStyleChangedSignal = false;
993 // Create a tap event to touch the text editor.
994 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
995 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
998 application.SendNotification();
999 application.Render();
1001 // Executes the idle callbacks added by the text control on the change of input style.
1002 application.RunIdles();
1004 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1005 DALI_TEST_CHECK( !inputStyleChangedSignal );
1007 gInputStyleChangedCallbackCalled = false;
1008 gInputStyleMask = TextEditor::InputStyle::NONE;
1009 inputStyleChangedSignal = false;
1011 // Create a tap event to touch the text editor.
1012 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1013 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1015 // Render and notify
1016 application.SendNotification();
1017 application.Render();
1019 // Executes the idle callbacks added by the text control on the change of input style.
1020 application.RunIdles();
1022 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1023 if( gInputStyleChangedCallbackCalled )
1025 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1027 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1028 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1030 DALI_TEST_CHECK( inputStyleChangedSignal );
1032 gInputStyleChangedCallbackCalled = false;
1033 gInputStyleMask = TextEditor::InputStyle::NONE;
1034 inputStyleChangedSignal = false;
1036 // Create a tap event to touch the text editor.
1037 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1038 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1040 // Render and notify
1041 application.SendNotification();
1042 application.Render();
1044 // Executes the idle callbacks added by the text control on the change of input style.
1045 application.RunIdles();
1047 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1048 if( gInputStyleChangedCallbackCalled )
1050 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1052 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1053 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1055 Property::Map fontStyleMapSet;
1056 Property::Map fontStyleMapGet;
1058 fontStyleMapSet.Insert( "weight", "bold" );
1060 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1061 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1062 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1064 DALI_TEST_CHECK( inputStyleChangedSignal );
1066 gInputStyleChangedCallbackCalled = false;
1067 gInputStyleMask = TextEditor::InputStyle::NONE;
1068 inputStyleChangedSignal = false;
1070 // Create a tap event to touch the text editor.
1071 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1072 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1074 // Render and notify
1075 application.SendNotification();
1076 application.Render();
1078 // Executes the idle callbacks added by the text control on the change of input style.
1079 application.RunIdles();
1081 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1082 DALI_TEST_CHECK( !inputStyleChangedSignal );
1084 gInputStyleChangedCallbackCalled = false;
1085 gInputStyleMask = TextEditor::InputStyle::NONE;
1086 inputStyleChangedSignal = false;
1088 // Create a tap event to touch the text editor.
1089 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1090 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1092 // Render and notify
1093 application.SendNotification();
1094 application.Render();
1096 // Executes the idle callbacks added by the text control on the change of input style.
1097 application.RunIdles();
1099 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1100 if( gInputStyleChangedCallbackCalled )
1102 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1104 Property::Map fontStyleMapSet;
1105 Property::Map fontStyleMapGet;
1107 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1108 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1109 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1111 DALI_TEST_CHECK( inputStyleChangedSignal );
1113 gInputStyleChangedCallbackCalled = false;
1114 gInputStyleMask = TextEditor::InputStyle::NONE;
1115 inputStyleChangedSignal = false;
1117 // Create a tap event to touch the text editor.
1118 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1119 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1121 // Render and notify
1122 application.SendNotification();
1123 application.Render();
1125 // Executes the idle callbacks added by the text control on the change of input style.
1126 application.RunIdles();
1128 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1129 DALI_TEST_CHECK( !inputStyleChangedSignal );
1134 int utcDaliTextEditorInputStyleChanged02(void)
1136 ToolkitTestApplication application;
1137 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1139 // The text-editor emits signals when the input style changes. These changes of style are
1140 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1141 // can't be emitted during the size negotiation as the callbacks may update the UI.
1142 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1143 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1144 application.CreateAdaptor();
1148 char* pathNamePtr = get_current_dir_name();
1149 const std::string pathName( pathNamePtr );
1150 free( pathNamePtr );
1152 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1153 fontClient.SetDpi( 93u, 93u );
1155 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1156 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1158 TextEditor editor = TextEditor::New();
1159 DALI_TEST_CHECK( editor );
1162 editor.SetSize( 300.f, 50.f );
1163 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1164 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1166 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1167 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>" );
1169 // connect to the text changed signal.
1170 ConnectionTracker* testTracker = new ConnectionTracker();
1171 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1172 bool inputStyleChangedSignal = false;
1173 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1175 Stage::GetCurrent().Add( editor );
1177 // Render and notify
1178 application.SendNotification();
1179 application.Render();
1181 // Executes the idle callbacks added by the text control on the change of input style.
1182 application.RunIdles();
1184 gInputStyleChangedCallbackCalled = false;
1185 gInputStyleMask = TextEditor::InputStyle::NONE;
1186 inputStyleChangedSignal = false;
1188 // Create a tap event to touch the text editor.
1189 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1190 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1191 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1192 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1194 // Render and notify
1195 application.SendNotification();
1196 application.Render();
1198 // Executes the idle callbacks added by the text control on the change of input style.
1199 application.RunIdles();
1201 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1202 if( gInputStyleChangedCallbackCalled )
1204 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1205 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1206 TextEditor::InputStyle::POINT_SIZE |
1207 TextEditor::InputStyle::COLOR ),
1210 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1211 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1213 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1214 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1216 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1217 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1219 DALI_TEST_CHECK( inputStyleChangedSignal );
1221 gInputStyleChangedCallbackCalled = false;
1222 gInputStyleMask = TextEditor::InputStyle::NONE;
1223 inputStyleChangedSignal = false;
1225 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Executes the idle callbacks added by the text control on the change of input style.
1232 application.RunIdles();
1234 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1235 if( gInputStyleChangedCallbackCalled )
1237 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1238 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1241 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1242 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1244 DALI_TEST_CHECK( inputStyleChangedSignal );
1246 gInputStyleChangedCallbackCalled = false;
1247 gInputStyleMask = TextEditor::InputStyle::NONE;
1248 inputStyleChangedSignal = false;
1250 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1252 // Render and notify
1253 application.SendNotification();
1254 application.Render();
1256 // Executes the idle callbacks added by the text control on the change of input style.
1257 application.RunIdles();
1259 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1260 DALI_TEST_CHECK( !inputStyleChangedSignal );
1262 gInputStyleChangedCallbackCalled = false;
1263 gInputStyleMask = TextEditor::InputStyle::NONE;
1264 inputStyleChangedSignal = false;
1266 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1268 // Render and notify
1269 application.SendNotification();
1270 application.Render();
1272 // Executes the idle callbacks added by the text control on the change of input style.
1273 application.RunIdles();
1275 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1276 if( gInputStyleChangedCallbackCalled )
1278 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1279 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1282 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1283 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1285 DALI_TEST_CHECK( inputStyleChangedSignal );
1287 gInputStyleChangedCallbackCalled = false;
1288 gInputStyleMask = TextEditor::InputStyle::NONE;
1289 inputStyleChangedSignal = false;
1291 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1293 Property::Map fontStyleMapSet;
1294 fontStyleMapSet.Insert( "weight", "thin" );
1295 fontStyleMapSet.Insert( "width", "condensed" );
1296 fontStyleMapSet.Insert( "slant", "italic" );
1298 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1299 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1300 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1302 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1303 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1304 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1305 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1307 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 // Executes the idle callbacks added by the text control on the change of input style.
1314 application.RunIdles();
1316 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1317 DALI_TEST_CHECK( !inputStyleChangedSignal );
1319 // Create a tap event to touch the text editor.
1320 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1321 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1323 // Render and notify
1324 application.SendNotification();
1325 application.Render();
1327 // Executes the idle callbacks added by the text control on the change of input style.
1328 application.RunIdles();
1330 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1331 if( gInputStyleChangedCallbackCalled )
1333 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1334 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1335 TextEditor::InputStyle::POINT_SIZE |
1336 TextEditor::InputStyle::FONT_STYLE |
1337 TextEditor::InputStyle::LINE_SPACING |
1338 TextEditor::InputStyle::UNDERLINE |
1339 TextEditor::InputStyle::SHADOW |
1340 TextEditor::InputStyle::EMBOSS |
1341 TextEditor::InputStyle::OUTLINE ),
1344 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1345 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1347 DALI_TEST_CHECK( inputStyleChangedSignal );
1349 gInputStyleChangedCallbackCalled = false;
1350 gInputStyleMask = TextEditor::InputStyle::NONE;
1351 inputStyleChangedSignal = false;
1353 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1355 fontStyleMapSet.Clear();
1356 fontStyleMapSet.Insert( "weight", "black" );
1357 fontStyleMapSet.Insert( "width", "expanded" );
1358 fontStyleMapSet.Insert( "slant", "oblique" );
1360 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1362 // Create a tap event to touch the text editor.
1363 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1364 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1366 // Render and notify
1367 application.SendNotification();
1368 application.Render();
1370 // Executes the idle callbacks added by the text control on the change of input style.
1371 application.RunIdles();
1373 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1374 if( gInputStyleChangedCallbackCalled )
1376 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1377 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1378 TextEditor::InputStyle::POINT_SIZE |
1379 TextEditor::InputStyle::FONT_STYLE ),
1382 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1383 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1385 DALI_TEST_CHECK( inputStyleChangedSignal );
1390 int utcDaliTextEditorEvent01(void)
1392 ToolkitTestApplication application;
1393 tet_infoline(" utcDaliTextEditorEvent01");
1395 // Creates a tap event. After creating a tap event the text editor should
1396 // have the focus and add text with key events should be possible.
1398 TextEditor editor = TextEditor::New();
1399 DALI_TEST_CHECK( editor );
1401 Stage::GetCurrent().Add( editor );
1403 editor.SetSize( 300.f, 50.f );
1404 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1405 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1407 // Avoid a crash when core load gl resources.
1408 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1410 // Render and notify
1411 application.SendNotification();
1412 application.Render();
1414 // Add a key event but as the text editor has not the focus it should do nothing.
1415 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1417 // Render and notify
1418 application.SendNotification();
1419 application.Render();
1421 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1423 // Create a tap event to touch the text editor.
1424 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1425 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1427 // Render and notify
1428 application.SendNotification();
1429 application.Render();
1431 // Now the text editor has the focus, so it can handle the key events.
1432 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1433 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1441 // Create a second text editor and send key events to it.
1442 TextEditor editor2 = TextEditor::New();
1444 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1445 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1446 editor2.SetSize( 100.f, 100.f );
1447 editor2.SetPosition( 100.f, 100.f );
1449 Stage::GetCurrent().Add( editor2 );
1451 // Render and notify
1452 application.SendNotification();
1453 application.Render();
1455 // Create a tap event on the second text editor.
1456 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1457 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1459 // Render and notify
1460 application.SendNotification();
1461 application.Render();
1463 // The second text editor has the focus. It should handle the key events.
1464 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1465 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1467 // Render and notify
1468 application.SendNotification();
1469 application.Render();
1471 // Check the text has been added to the second text editor.
1472 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1477 int utcDaliTextEditorEvent02(void)
1479 ToolkitTestApplication application;
1480 tet_infoline(" utcDaliTextEditorEvent02");
1482 // Checks if the right number of actors are created.
1484 TextEditor editor = TextEditor::New();
1485 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1486 DALI_TEST_CHECK( editor );
1488 Stage::GetCurrent().Add( editor );
1490 editor.SetSize( 300.f, 50.f );
1491 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1492 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1494 // Avoid a crash when core load gl resources.
1495 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1497 // Render and notify
1498 application.SendNotification();
1499 application.Render();
1501 // Check there are the expected number of children (the stencil).
1502 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1504 Actor stencil = editor.GetChildAt( 0u );
1506 // Create a tap event to touch the text editor.
1507 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1508 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1510 // Render and notify
1511 application.SendNotification();
1512 application.Render();
1514 Actor layer = editor.GetChildAt( 1u );
1515 DALI_TEST_CHECK( layer.IsLayer() );
1517 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1518 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1520 // Now the text editor has the focus, so it can handle the key events.
1521 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1522 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1524 // Render and notify
1525 application.SendNotification();
1526 application.Render();
1528 // Checks the cursor and the renderer have been created.
1529 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1530 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1532 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1533 DALI_TEST_CHECK( cursor );
1535 // The stencil actor has a container with all the actors which contain the text renderers.
1536 Actor container = stencil.GetChildAt( 0u );
1537 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1539 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1540 DALI_TEST_CHECK( renderer );
1543 // Move the cursor and check the position changes.
1544 Vector3 position1 = cursor.GetCurrentPosition();
1546 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1547 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1549 // Render and notify
1550 application.SendNotification();
1551 application.Render();
1553 Vector3 position2 = cursor.GetCurrentPosition();
1555 DALI_TEST_CHECK( position2.x < position1.x );
1557 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1558 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 Vector3 position3 = cursor.GetCurrentPosition();
1566 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1568 // Send some taps and check the cursor positions.
1570 // Try to tap at the beginning.
1571 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1572 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // Cursor position should be the same than position1.
1579 Vector3 position4 = cursor.GetCurrentPosition();
1581 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1583 // Tap away from the start position.
1584 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1585 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1587 // Render and notify
1588 application.SendNotification();
1589 application.Render();
1591 Vector3 position5 = cursor.GetCurrentPosition();
1593 DALI_TEST_CHECK( position5.x > position4.x );
1595 // Remove all the text.
1596 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1597 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1598 editor.SetProperty( TextEditor::Property::TEXT, "" );
1600 // Render and notify
1601 application.SendNotification();
1602 application.Render();
1604 // Cursor position should be the same than position2.
1605 Vector3 position6 = cursor.GetCurrentPosition();
1607 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1609 // Should not be a renderer.
1610 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1615 int utcDaliTextEditorEvent03(void)
1617 ToolkitTestApplication application;
1618 tet_infoline(" utcDaliTextEditorEvent03");
1620 // Checks if the highlight actor is created.
1622 TextEditor editor = TextEditor::New();
1623 DALI_TEST_CHECK( editor );
1625 Stage::GetCurrent().Add( editor );
1627 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1628 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1629 editor.SetSize( 30.f, 50.f );
1630 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1631 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1633 // Avoid a crash when core load gl resources.
1634 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Send some taps and check text controller with clipboard window
1641 Dali::Clipboard clipboard = Clipboard::Get();
1642 clipboard.ShowClipboard();
1643 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1644 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1645 clipboard.HideClipboard();
1647 // Render and notify
1648 application.SendNotification();
1649 application.Render();
1651 // Tap first to get the focus.
1652 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1653 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1655 // Render and notify
1656 application.SendNotification();
1657 application.Render();
1659 // Double tap to select a word.
1660 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1661 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1663 // Render and notify
1664 application.SendNotification();
1665 application.Render();
1667 // The stencil actor should have two actors: the renderer and the highlight actor.
1668 Actor stencil = editor.GetChildAt( 0u );
1670 // Highlight needs to be drawn before text, so should come first in child order
1671 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1672 DALI_TEST_CHECK( highlight );
1674 // The stencil actor has a container with all the actors which contain the text renderers.
1675 Actor container = stencil.GetChildAt( 1u );
1676 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1678 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1679 DALI_TEST_CHECK( renderer );
1682 // Double tap out of bounds
1683 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1684 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1686 // Render and notify
1687 application.SendNotification();
1688 application.Render();
1690 // The stencil actor should have one actors: the renderer actor.
1691 stencil = editor.GetChildAt( 0u );
1693 // The stencil actor has a container with all the actors which contain the text renderers.
1694 container = stencil.GetChildAt( 0u );
1695 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1697 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1698 DALI_TEST_CHECK( renderer );
1704 int utcDaliTextEditorEvent04(void)
1706 ToolkitTestApplication application;
1707 tet_infoline(" utcDaliTextEditorEvent04");
1709 // Checks if the highlight actor is created.
1711 TextEditor editor = TextEditor::New();
1712 DALI_TEST_CHECK( editor );
1714 Stage::GetCurrent().Add( editor );
1716 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1717 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1718 editor.SetSize( 100.f, 50.f );
1719 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1720 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1722 // Avoid a crash when core load gl resources.
1723 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1725 // Render and notify
1726 application.SendNotification();
1727 application.Render();
1729 // Tap on the text editor
1730 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1731 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1733 // Render and notify
1734 application.SendNotification();
1735 application.Render();
1737 // Move at the end of the text.
1738 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1739 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1741 // Render and notify
1742 application.SendNotification();
1743 application.Render();
1745 for( unsigned int index = 0u; index < 10u; ++index )
1747 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1748 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1750 // Render and notify
1751 application.SendNotification();
1752 application.Render();
1756 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1758 // Render and notify
1759 application.SendNotification();
1760 application.Render();
1762 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1764 // Add some key events
1765 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1766 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1768 // Render and notify
1769 application.SendNotification();
1770 application.Render();
1772 for( unsigned int index = 0u; index < 10u; ++index )
1774 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1775 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1777 // Render and notify
1778 application.SendNotification();
1779 application.Render();
1783 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1785 // Render and notify
1786 application.SendNotification();
1787 application.Render();
1789 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1794 int utcDaliTextEditorEvent05(void)
1796 ToolkitTestApplication application;
1797 tet_infoline(" utcDaliTextEditorEvent05");
1799 // Checks if the highlight actor is created.
1801 TextEditor editor = TextEditor::New();
1802 DALI_TEST_CHECK( editor );
1804 Stage::GetCurrent().Add( editor );
1806 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1807 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1808 editor.SetSize( 50.f, 50.f );
1809 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1810 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1811 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1812 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1813 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1814 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1815 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1817 // Avoid a crash when core load gl resources.
1818 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 // Tap on the text editor
1825 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1826 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1828 // Render and notify
1829 application.SendNotification();
1830 application.Render();
1832 // Move at the end of the text.
1833 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1834 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1836 // Render and notify
1837 application.SendNotification();
1838 application.Render();
1840 for( unsigned int index = 0u; index < 10u; ++index )
1843 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Modify duration after scroll is enabled
1850 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1852 // Continuous scroll left to increase coverage
1853 for( unsigned int index = 0u; index < 10u; ++index )
1855 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1857 // Render and notify
1858 application.SendNotification();
1859 application.Render();
1861 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1862 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1863 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1864 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1865 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1867 // Press Escape to increase coverage
1868 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1869 application.SendNotification();
1870 application.Render();
1872 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1877 int utcDaliTextEditorEvent06(void)
1879 ToolkitTestApplication application;
1880 tet_infoline(" utcDaliTextEditorEvent06");
1882 // Checks if the highlight actor is created.
1884 TextEditor editor = TextEditor::New();
1885 DALI_TEST_CHECK( editor );
1887 Stage::GetCurrent().Add( editor );
1889 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
1890 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1891 editor.SetSize( 100.f, 50.f );
1892 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1893 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1895 // Avoid a crash when core load gl resources.
1896 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1898 // Render and notify
1899 application.SendNotification();
1900 application.Render();
1902 // Tap on the text editor
1903 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1904 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1906 // Render and notify
1907 application.SendNotification();
1908 application.Render();
1910 // Move to seconds line of the text.
1911 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1913 // Render and notify
1914 application.SendNotification();
1915 application.Render();
1917 float layoutHeight = editor.GetHeightForWidth( 100.f );
1920 // Add another script characters ( glyph height is defferent )
1921 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1922 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1924 // Delete characters
1925 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1926 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1928 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
1930 // Render and notify
1931 application.SendNotification();
1932 application.Render();
1934 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1941 int utcDaliTextEditorHandles(void)
1943 ToolkitTestApplication application;
1944 tet_infoline(" utcDaliTextEditorHandles");
1946 TextEditor editor = TextEditor::New();
1947 DALI_TEST_CHECK( editor );
1949 Stage::GetCurrent().Add( editor );
1951 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1952 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1953 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1954 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1956 editor.SetSize( 30.f, 500.f );
1957 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1958 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1960 // Avoid a crash when core load gl resources.
1961 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1963 // Render and notify
1964 application.SendNotification();
1965 application.Render();
1967 // Tap first to get the focus.
1968 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1969 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1971 // Render and notify
1972 application.SendNotification();
1973 application.Render();
1975 // Tap to create the grab handle.
1976 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1977 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1979 // Render and notify
1980 application.SendNotification();
1981 application.Render();
1983 // Get the active layer where the text's decoration is added.
1984 Actor activeLayer = editor.GetChildAt( 1u );
1986 // Get the handle's actor.
1987 Actor handle = activeLayer.GetChildAt( 1u );
1988 handle.SetSize( 100.f, 100.f );
1990 // Render and notify
1991 application.SendNotification();
1992 application.Render();
1994 // Touch the grab handle to set it as pressed.
1995 Vector2 touchPos( 10.0f, 50.0f );
1996 Dali::Integration::TouchEvent event;
1997 event = Dali::Integration::TouchEvent();
1998 event.AddPoint( GetPointDownInside( touchPos ) );
1999 application.ProcessEvent( event );
2001 // Render and notify
2002 application.SendNotification();
2003 application.Render();
2005 // drag grab handle right
2006 SendPan(application, Gesture::Possible, touchPos);
2007 SendPan(application, Gesture::Started, touchPos);
2009 Wait(application, 100);
2011 for(int i = 0;i<20;i++)
2013 SendPan(application, Gesture::Continuing, touchPos);
2018 SendPan(application, Gesture::Finished, touchPos);
2021 // Release the grab handle.
2022 event = Dali::Integration::TouchEvent();
2023 event.AddPoint( GetPointUpInside( touchPos ) );
2024 application.ProcessEvent( event );
2026 // Render and notify
2027 application.SendNotification();
2028 application.Render();
2034 int utcDaliTextEditorUnderPropertyStringP(void)
2036 ToolkitTestApplication application;
2037 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2038 TextEditor editor = TextEditor::New();
2039 DALI_TEST_CHECK( editor );
2041 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2043 Stage::GetCurrent().Add( editor );
2045 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2046 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2048 tet_infoline("Set underline settings with a map");
2049 // Check the input underline property
2050 Property::Map underlineMapSet;
2051 Property::Map underlineMapGet;
2052 underlineMapSet.Insert( "enable", "true" );
2053 underlineMapSet.Insert( "color", "blue" );
2054 underlineMapSet.Insert( "height", "2" );
2056 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2057 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2058 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2059 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2061 tet_infoline("Set underline settings with a string");
2062 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2063 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2066 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2068 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2069 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2070 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2071 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2073 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2078 int utcDaliTextEditorShadowPropertyStringP(void)
2080 ToolkitTestApplication application;
2081 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2083 TextEditor editor = TextEditor::New();
2085 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2087 Stage::GetCurrent().Add( editor );
2089 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
2091 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2095 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2100 int utcDaliTextEditorFontStylePropertyStringP(void)
2102 ToolkitTestApplication application;
2103 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2105 TextEditor editor = TextEditor::New();
2107 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2109 Stage::GetCurrent().Add( editor );
2111 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2113 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2117 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2122 int utcDaliTextEditorGetPropertyLinecountP(void)
2124 ToolkitTestApplication application;
2126 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2130 TextEditor editor = TextEditor::New();
2131 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2132 editor.SetProperty( TextEditor::Property::TEXT,
2133 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2135 Stage::GetCurrent().Add( editor );
2137 editor.SetSize( 100.0f, 100.0f );
2138 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2139 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2141 editor.SetSize( 50.0f, 100.0f );
2142 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
2143 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2148 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2151 ToolkitTestApplication application;
2152 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2154 TextEditor editor = TextEditor::New();
2155 DALI_TEST_CHECK( editor );
2157 Stage::GetCurrent().Add( editor );
2159 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2160 editor.SetSize( 50.f, 50.f );
2161 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2162 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2163 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
2164 editor.SetKeyboardFocusable(true);
2166 bool startedCalled = false;
2167 bool finishedCalled = false;
2169 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2170 DevelTextEditor::ScrollStateChangedSignal( editor ).Connect( &callback, &ScrollStateChangeCallback::Callback );
2172 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2174 // Render and notify
2175 application.SendNotification();
2176 application.Render();
2178 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2179 application.SendNotification();
2180 application.Render(6000);
2182 application.SendNotification();
2183 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2184 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );