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.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/devel-api/adaptor-framework/clipboard.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.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";
98 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
100 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
102 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
103 const float TO_MILLISECONDS = 1000.f;
104 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
105 const float RENDER_FRAME_INTERVAL = 16.66f;
107 const float SCROLL_THRESHOLD = 10.f;
108 const float SCROLL_SPEED = 300.f;
110 const unsigned int DEFAULT_FONT_SIZE = 1152u;
111 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
113 const int KEY_A_CODE = 38;
114 const int KEY_D_CODE = 40;
115 const int KEY_WHITE_SPACE_CODE = 65;
117 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
119 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
121 static bool gTextChangedCallBackCalled;
122 static bool gInputStyleChangedCallbackCalled;
123 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
125 struct CallbackFunctor
127 CallbackFunctor(bool* callbackFlag)
128 : mCallbackFlag( callbackFlag )
134 *mCallbackFlag = true;
139 static void TestTextChangedCallback( TextEditor control )
141 tet_infoline(" TestTextChangedCallback");
143 gTextChangedCallBackCalled = true;
146 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
148 tet_infoline(" TestInputStyleChangedCallback");
150 gInputStyleChangedCallbackCalled = true;
151 gInputStyleMask = mask;
154 // Generate a TapGestureEvent to send to Core.
155 Integration::TapGestureEvent GenerateTap(
156 Gesture::State state,
157 unsigned int numberOfTaps,
158 unsigned int numberOfTouches,
161 Integration::TapGestureEvent tap( state );
163 tap.numberOfTaps = numberOfTaps;
164 tap.numberOfTouches = numberOfTouches;
170 // Generate a PanGestureEvent to send to Core
171 Integration::PanGestureEvent GeneratePan( Gesture::State state,
172 const Vector2& previousPosition,
173 const Vector2& currentPosition,
174 unsigned long timeDelta,
175 unsigned int numberOfTouches = 1u )
177 Integration::PanGestureEvent pan(state);
179 pan.previousPosition = previousPosition;
180 pan.currentPosition = currentPosition;
181 pan.timeDelta = timeDelta;
182 pan.numberOfTouches = numberOfTouches;
187 // Generate a KeyEvent to send to Core.
188 Integration::KeyEvent GenerateKey( const std::string& keyName,
189 const std::string& keyString,
192 unsigned long timeStamp,
193 const Integration::KeyEvent::State& keyState,
194 const std::string& deviceName,
195 const DevelKeyEvent::DeviceClass::Type& deviceClass )
197 return Integration::KeyEvent( keyName,
208 * Helper to generate PanGestureEvent
210 * @param[in] application Application instance
211 * @param[in] state The Gesture State
212 * @param[in] pos The current position of touch.
214 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
218 if( (state == Gesture::Started) ||
219 (state == Gesture::Possible) )
225 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
232 * Simulate time passed by.
234 * @note this will always process at least 1 frame (1/60 sec)
236 * @param application Test application instance
237 * @param duration Time to pass in milliseconds.
238 * @return The actual time passed in milliseconds
240 static int Wait(ToolkitTestApplication& application, int duration = 0)
244 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
246 application.SendNotification();
247 application.Render(RENDER_FRAME_INTERVAL);
248 time += RENDER_FRAME_INTERVAL;
254 Dali::Integration::Point GetPointDownInside( Vector2& pos )
256 Dali::Integration::Point point;
257 point.SetState( PointState::DOWN );
258 point.SetScreenPosition( pos );
262 Dali::Integration::Point GetPointUpInside( Vector2& pos )
264 Dali::Integration::Point point;
265 point.SetState( PointState::UP );
266 point.SetScreenPosition( pos );
270 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
272 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
274 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
276 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
278 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
279 if( NULL != valueSet )
281 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
283 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
289 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
300 int UtcDaliToolkitTextEditorConstructorP(void)
302 ToolkitTestApplication application;
303 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
304 TextEditor textEditor;
305 DALI_TEST_CHECK( !textEditor );
309 int UtcDaliToolkitTextEditorNewP(void)
311 ToolkitTestApplication application;
312 tet_infoline(" UtcDaliToolkitTextEditorNewP");
313 TextEditor textEditor = TextEditor::New();
314 DALI_TEST_CHECK( textEditor );
318 int UtcDaliToolkitTextEditorDownCastP(void)
320 ToolkitTestApplication application;
321 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
322 TextEditor textEditor1 = TextEditor::New();
323 BaseHandle object( textEditor1 );
325 TextEditor textEditor2 = TextEditor::DownCast( object );
326 DALI_TEST_CHECK( textEditor2 );
328 TextEditor textEditor3 = DownCast< TextEditor >( object );
329 DALI_TEST_CHECK( textEditor3 );
333 int UtcDaliToolkitTextEditorDownCastN(void)
335 ToolkitTestApplication application;
336 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
337 BaseHandle uninitializedObject;
338 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
339 DALI_TEST_CHECK( !textEditor1 );
341 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
342 DALI_TEST_CHECK( !textEditor2 );
346 int UtcDaliToolkitTextEditorCopyConstructorP(void)
348 ToolkitTestApplication application;
349 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
350 TextEditor textEditor = TextEditor::New();
351 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
353 TextEditor copy( textEditor );
354 DALI_TEST_CHECK( copy );
355 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
359 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
361 ToolkitTestApplication application;
362 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
363 TextEditor textEditor = TextEditor::New();
364 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
366 TextEditor copy = textEditor;
367 DALI_TEST_CHECK( copy );
368 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
372 int UtcDaliTextEditorNewP(void)
374 ToolkitTestApplication application;
375 tet_infoline(" UtcDaliToolkitTextEditorNewP");
376 TextEditor textEditor = TextEditor::New();
377 DALI_TEST_CHECK( textEditor );
381 // Positive test case for a method
382 int UtcDaliTextEditorGetPropertyP(void)
384 ToolkitTestApplication application;
385 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
386 TextEditor editor = TextEditor::New();
387 DALI_TEST_CHECK( editor );
389 // Check Property Indices are correct
390 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
391 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
392 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
393 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
394 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
395 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
396 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
397 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
398 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
399 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
400 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
401 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
402 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
403 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
404 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
405 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
406 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
407 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
408 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
409 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
410 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
411 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
412 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
413 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
414 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
415 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
416 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
417 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
442 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
445 Property::Map imageMap;
446 imageMap[mapKey] =mapValue;
448 editor.SetProperty( property , imageMap );
449 Property::Value propValue = editor.GetProperty( property );
450 Property::Map* resultMap = propValue.GetMap();
452 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
460 // Positive test case for a method
461 int UtcDaliTextEditorSetPropertyP(void)
463 ToolkitTestApplication application;
464 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
465 TextEditor editor = TextEditor::New();
466 DALI_TEST_CHECK( editor );
467 Stage::GetCurrent().Add( editor );
469 // Note - we can't check the defaults since the stylesheets are platform-specific
471 // Check the render backend property.
472 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
473 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
475 // Check text property.
476 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
477 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
479 // Check text's color property
480 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
481 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
483 // Check font properties.
484 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
485 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
487 Property::Map fontStyleMapSet;
488 Property::Map fontStyleMapGet;
489 Property::Value* slantValue = NULL;
491 fontStyleMapSet.Insert( "weight", "bold" );
492 fontStyleMapSet.Insert( "width", "condensed" );
493 fontStyleMapSet.Insert( "slant", "italic" );
495 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
496 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
497 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
498 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
500 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
501 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
504 fontStyleMapSet.Clear();
505 fontStyleMapSet.Insert( "weight", "normal" );
506 fontStyleMapSet.Insert( "slant", "oblique" );
507 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
508 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
509 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
510 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
512 fontStyleMapSet.Clear();
513 fontStyleMapSet.Insert( "slant", "roman" );
514 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
515 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
517 // Replace 'roman' for 'normal'.
518 slantValue = fontStyleMapGet.Find( "slant" );
519 if( NULL != slantValue )
521 if( "normal" == slantValue->Get<std::string>() )
523 fontStyleMapGet["slant"] = "roman";
526 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
527 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
529 fontStyleMapSet.Clear();
531 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
532 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
533 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
534 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
536 // Check that the Alignment properties can be correctly set
537 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
538 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
540 // Check scroll properties.
541 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
542 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
543 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
544 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
546 // Check cursor properties
547 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
548 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
549 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
550 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
552 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
553 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
554 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
555 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
556 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
557 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
558 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
559 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
561 // Check handle images
562 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
563 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
564 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
565 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
566 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
568 // Check handle images
569 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
570 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
571 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
572 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
573 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
574 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
576 // Check the highlight color
577 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
578 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
580 // Decoration bounding box
581 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
582 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
584 // Check the enable markup property.
585 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
586 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
587 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
589 // Check input color property.
590 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
591 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
593 // Check input font properties.
594 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
595 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
597 fontStyleMapSet.Clear();
598 fontStyleMapSet.Insert( "weight", "bold" );
599 fontStyleMapSet.Insert( "width", "condensed" );
600 fontStyleMapSet.Insert( "slant", "italic" );
602 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
603 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
604 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
605 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
607 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
608 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
610 // Reset input font style.
611 fontStyleMapSet.Clear();
612 fontStyleMapSet.Insert( "weight", "normal" );
613 fontStyleMapSet.Insert( "slant", "oblique" );
615 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
616 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
617 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
618 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
620 fontStyleMapSet.Clear();
621 fontStyleMapSet.Insert( "slant", "roman" );
623 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
624 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
626 // Replace 'roman' for 'normal'.
627 slantValue = fontStyleMapGet.Find( "slant" );
628 if( NULL != slantValue )
630 if( "normal" == slantValue->Get<std::string>() )
632 fontStyleMapGet["slant"] = "roman";
635 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
636 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
638 fontStyleMapSet.Clear();
640 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
641 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
642 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
643 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
645 // Check the line spacing property
646 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
647 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
648 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
650 // Check the input line spacing property
651 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
652 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
653 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
655 // Check the underline property
657 Property::Map underlineMapSet;
658 Property::Map underlineMapGet;
660 underlineMapSet.Insert( "enable", "true" );
661 underlineMapSet.Insert( "color", "red" );
662 underlineMapSet.Insert( "height", "1" );
664 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
666 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
667 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
668 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
670 // Check the input underline property
671 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
672 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
674 // Check the shadow property
675 Property::Map shadowMapSet;
676 Property::Map shadowMapGet;
678 shadowMapSet.Insert( "color", "green" );
679 shadowMapSet.Insert( "offset", "2 2" );
681 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
683 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
684 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
685 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
687 // Check the input shadow property
688 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
689 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
691 // Check the emboss property
692 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
693 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
695 // Check the input emboss property
696 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
697 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
699 // Check the outline property
700 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
701 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
703 // Check the input outline property
704 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
705 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
707 // Check the smooth scroll property
708 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
709 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
710 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
712 // Check the smooth scroll duration property
713 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
714 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
716 // Check the scroll bar property
717 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
718 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
719 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
721 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
722 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
723 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
724 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
726 // Check the pixel size of font
727 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
728 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
733 // Positive Atlas Text Renderer test
734 int utcDaliTextEditorAtlasRenderP(void)
736 ToolkitTestApplication application;
737 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
738 StyleManager styleManager = StyleManager::Get();
739 styleManager.ApplyDefaultTheme();
740 TextEditor editor = TextEditor::New();
741 DALI_TEST_CHECK( editor );
743 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
745 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
747 Stage::GetCurrent().Add( editor );
751 // Render some text with the shared atlas backend
752 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
753 application.SendNotification();
754 application.Render();
758 tet_result(TET_FAIL);
763 // Positive test for the textChanged signal.
764 int utcDaliTextEditorTextChangedP(void)
766 ToolkitTestApplication application;
767 tet_infoline(" utcDaliTextEditorTextChangedP");
768 TextEditor editor = TextEditor::New();
769 DALI_TEST_CHECK( editor );
771 Stage::GetCurrent().Add( editor );
773 // connect to the text changed signal.
774 ConnectionTracker* testTracker = new ConnectionTracker();
775 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
776 bool textChangedSignal = false;
777 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
779 gTextChangedCallBackCalled = false;
780 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
781 DALI_TEST_CHECK( gTextChangedCallBackCalled );
782 DALI_TEST_CHECK( textChangedSignal );
784 application.SendNotification();
786 editor.SetKeyInputFocus();
788 gTextChangedCallBackCalled = false;
789 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
790 DALI_TEST_CHECK( gTextChangedCallBackCalled );
795 int utcDaliTextEditorInputStyleChanged01(void)
797 ToolkitTestApplication application;
798 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
800 // The text-editor emits signals when the input style changes. These changes of style are
801 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
802 // can't be emitted during the size negotiation as the callbacks may update the UI.
803 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
804 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
805 application.CreateAdaptor();
809 char* pathNamePtr = get_current_dir_name();
810 const std::string pathName( pathNamePtr );
813 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
814 fontClient.SetDpi( 93u, 93u );
816 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
817 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
819 TextEditor editor = TextEditor::New();
820 DALI_TEST_CHECK( editor );
823 editor.SetSize( 300.f, 50.f );
824 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
825 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
827 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
828 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
830 // connect to the text changed signal.
831 ConnectionTracker* testTracker = new ConnectionTracker();
832 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
833 bool inputStyleChangedSignal = false;
834 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
836 Stage::GetCurrent().Add( editor );
839 application.SendNotification();
840 application.Render();
842 // Executes the idle callbacks added by the text control on the change of input style.
843 application.RunIdles();
845 gInputStyleChangedCallbackCalled = false;
846 gInputStyleMask = TextEditor::InputStyle::NONE;
847 inputStyleChangedSignal = false;
849 // Create a tap event to touch the text editor.
850 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
851 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
854 application.SendNotification();
855 application.Render();
857 // Executes the idle callbacks added by the text control on the change of input style.
858 application.RunIdles();
860 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
861 if( gInputStyleChangedCallbackCalled )
863 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
865 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
866 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
868 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
869 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
871 DALI_TEST_CHECK( inputStyleChangedSignal );
873 gInputStyleChangedCallbackCalled = false;
874 gInputStyleMask = TextEditor::InputStyle::NONE;
875 inputStyleChangedSignal = false;
877 // Create a tap event to touch the text editor.
878 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
879 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
882 application.SendNotification();
883 application.Render();
885 // Executes the idle callbacks added by the text control on the change of input style.
886 application.RunIdles();
888 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
889 DALI_TEST_CHECK( !inputStyleChangedSignal );
891 gInputStyleChangedCallbackCalled = false;
892 gInputStyleMask = TextEditor::InputStyle::NONE;
893 inputStyleChangedSignal = false;
895 // Create a tap event to touch the text editor.
896 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
897 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
900 application.SendNotification();
901 application.Render();
903 // Executes the idle callbacks added by the text control on the change of input style.
904 application.RunIdles();
906 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
907 if( gInputStyleChangedCallbackCalled )
909 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
911 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
912 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
914 DALI_TEST_CHECK( inputStyleChangedSignal );
916 gInputStyleChangedCallbackCalled = false;
917 gInputStyleMask = TextEditor::InputStyle::NONE;
918 inputStyleChangedSignal = false;
920 // Create a tap event to touch the text editor.
921 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
922 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
925 application.SendNotification();
926 application.Render();
928 // Executes the idle callbacks added by the text control on the change of input style.
929 application.RunIdles();
931 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
932 if( gInputStyleChangedCallbackCalled )
934 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
936 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
937 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
939 Property::Map fontStyleMapSet;
940 Property::Map fontStyleMapGet;
942 fontStyleMapSet.Insert( "weight", "bold" );
944 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
945 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
946 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
948 DALI_TEST_CHECK( inputStyleChangedSignal );
950 gInputStyleChangedCallbackCalled = false;
951 gInputStyleMask = TextEditor::InputStyle::NONE;
952 inputStyleChangedSignal = false;
954 // Create a tap event to touch the text editor.
955 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
956 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
959 application.SendNotification();
960 application.Render();
962 // Executes the idle callbacks added by the text control on the change of input style.
963 application.RunIdles();
965 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
966 DALI_TEST_CHECK( !inputStyleChangedSignal );
968 gInputStyleChangedCallbackCalled = false;
969 gInputStyleMask = TextEditor::InputStyle::NONE;
970 inputStyleChangedSignal = false;
972 // Create a tap event to touch the text editor.
973 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
974 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
977 application.SendNotification();
978 application.Render();
980 // Executes the idle callbacks added by the text control on the change of input style.
981 application.RunIdles();
983 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
984 if( gInputStyleChangedCallbackCalled )
986 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
988 Property::Map fontStyleMapSet;
989 Property::Map fontStyleMapGet;
991 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
992 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
993 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
995 DALI_TEST_CHECK( inputStyleChangedSignal );
997 gInputStyleChangedCallbackCalled = false;
998 gInputStyleMask = TextEditor::InputStyle::NONE;
999 inputStyleChangedSignal = false;
1001 // Create a tap event to touch the text editor.
1002 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1003 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1005 // Render and notify
1006 application.SendNotification();
1007 application.Render();
1009 // Executes the idle callbacks added by the text control on the change of input style.
1010 application.RunIdles();
1012 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1013 DALI_TEST_CHECK( !inputStyleChangedSignal );
1018 int utcDaliTextEditorInputStyleChanged02(void)
1020 ToolkitTestApplication application;
1021 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1023 // The text-editor emits signals when the input style changes. These changes of style are
1024 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1025 // can't be emitted during the size negotiation as the callbacks may update the UI.
1026 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1027 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1028 application.CreateAdaptor();
1032 char* pathNamePtr = get_current_dir_name();
1033 const std::string pathName( pathNamePtr );
1034 free( pathNamePtr );
1036 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1037 fontClient.SetDpi( 93u, 93u );
1039 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1040 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1042 TextEditor editor = TextEditor::New();
1043 DALI_TEST_CHECK( editor );
1046 editor.SetSize( 300.f, 50.f );
1047 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1048 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1050 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1051 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>" );
1053 // connect to the text changed signal.
1054 ConnectionTracker* testTracker = new ConnectionTracker();
1055 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1056 bool inputStyleChangedSignal = false;
1057 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1059 Stage::GetCurrent().Add( editor );
1061 // Render and notify
1062 application.SendNotification();
1063 application.Render();
1065 // Executes the idle callbacks added by the text control on the change of input style.
1066 application.RunIdles();
1068 gInputStyleChangedCallbackCalled = false;
1069 gInputStyleMask = TextEditor::InputStyle::NONE;
1070 inputStyleChangedSignal = false;
1072 // Create a tap event to touch the text editor.
1073 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1074 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1075 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1076 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1078 // Render and notify
1079 application.SendNotification();
1080 application.Render();
1082 // Executes the idle callbacks added by the text control on the change of input style.
1083 application.RunIdles();
1085 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1086 if( gInputStyleChangedCallbackCalled )
1088 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1089 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1090 TextEditor::InputStyle::POINT_SIZE |
1091 TextEditor::InputStyle::COLOR ),
1094 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1095 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1097 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1098 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1100 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1101 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1103 DALI_TEST_CHECK( inputStyleChangedSignal );
1105 gInputStyleChangedCallbackCalled = false;
1106 gInputStyleMask = TextEditor::InputStyle::NONE;
1107 inputStyleChangedSignal = false;
1109 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1111 // Render and notify
1112 application.SendNotification();
1113 application.Render();
1115 // Executes the idle callbacks added by the text control on the change of input style.
1116 application.RunIdles();
1118 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1119 if( gInputStyleChangedCallbackCalled )
1121 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1122 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1125 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1126 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1128 DALI_TEST_CHECK( inputStyleChangedSignal );
1130 gInputStyleChangedCallbackCalled = false;
1131 gInputStyleMask = TextEditor::InputStyle::NONE;
1132 inputStyleChangedSignal = false;
1134 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1136 // Render and notify
1137 application.SendNotification();
1138 application.Render();
1140 // Executes the idle callbacks added by the text control on the change of input style.
1141 application.RunIdles();
1143 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1144 DALI_TEST_CHECK( !inputStyleChangedSignal );
1146 gInputStyleChangedCallbackCalled = false;
1147 gInputStyleMask = TextEditor::InputStyle::NONE;
1148 inputStyleChangedSignal = false;
1150 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1152 // Render and notify
1153 application.SendNotification();
1154 application.Render();
1156 // Executes the idle callbacks added by the text control on the change of input style.
1157 application.RunIdles();
1159 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1160 if( gInputStyleChangedCallbackCalled )
1162 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1163 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1166 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1167 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1169 DALI_TEST_CHECK( inputStyleChangedSignal );
1171 gInputStyleChangedCallbackCalled = false;
1172 gInputStyleMask = TextEditor::InputStyle::NONE;
1173 inputStyleChangedSignal = false;
1175 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1177 Property::Map fontStyleMapSet;
1178 fontStyleMapSet.Insert( "weight", "thin" );
1179 fontStyleMapSet.Insert( "width", "condensed" );
1180 fontStyleMapSet.Insert( "slant", "italic" );
1182 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1183 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1184 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1186 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1187 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1188 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1189 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1191 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1193 // Render and notify
1194 application.SendNotification();
1195 application.Render();
1197 // Executes the idle callbacks added by the text control on the change of input style.
1198 application.RunIdles();
1200 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1201 DALI_TEST_CHECK( !inputStyleChangedSignal );
1203 // Create a tap event to touch the text editor.
1204 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1205 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1207 // Render and notify
1208 application.SendNotification();
1209 application.Render();
1211 // Executes the idle callbacks added by the text control on the change of input style.
1212 application.RunIdles();
1214 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1215 if( gInputStyleChangedCallbackCalled )
1217 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1218 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1219 TextEditor::InputStyle::POINT_SIZE |
1220 TextEditor::InputStyle::FONT_STYLE |
1221 TextEditor::InputStyle::LINE_SPACING |
1222 TextEditor::InputStyle::UNDERLINE |
1223 TextEditor::InputStyle::SHADOW |
1224 TextEditor::InputStyle::EMBOSS |
1225 TextEditor::InputStyle::OUTLINE ),
1228 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1229 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1231 DALI_TEST_CHECK( inputStyleChangedSignal );
1233 gInputStyleChangedCallbackCalled = false;
1234 gInputStyleMask = TextEditor::InputStyle::NONE;
1235 inputStyleChangedSignal = false;
1237 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1239 fontStyleMapSet.Clear();
1240 fontStyleMapSet.Insert( "weight", "black" );
1241 fontStyleMapSet.Insert( "width", "expanded" );
1242 fontStyleMapSet.Insert( "slant", "oblique" );
1244 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1246 // Create a tap event to touch the text editor.
1247 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1248 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1250 // Render and notify
1251 application.SendNotification();
1252 application.Render();
1254 // Executes the idle callbacks added by the text control on the change of input style.
1255 application.RunIdles();
1257 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1258 if( gInputStyleChangedCallbackCalled )
1260 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1261 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1262 TextEditor::InputStyle::POINT_SIZE |
1263 TextEditor::InputStyle::FONT_STYLE ),
1266 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1267 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1269 DALI_TEST_CHECK( inputStyleChangedSignal );
1274 int utcDaliTextEditorEvent01(void)
1276 ToolkitTestApplication application;
1277 tet_infoline(" utcDaliTextEditorEvent01");
1279 // Creates a tap event. After creating a tap event the text editor should
1280 // have the focus and add text with key events should be possible.
1282 TextEditor editor = TextEditor::New();
1283 DALI_TEST_CHECK( editor );
1285 Stage::GetCurrent().Add( editor );
1287 editor.SetSize( 300.f, 50.f );
1288 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1289 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1291 // Avoid a crash when core load gl resources.
1292 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Add a key event but as the text editor has not the focus it should do nothing.
1299 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1301 // Render and notify
1302 application.SendNotification();
1303 application.Render();
1305 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1307 // Create a tap event to touch the text editor.
1308 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1309 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1311 // Render and notify
1312 application.SendNotification();
1313 application.Render();
1315 // Now the text editor has the focus, so it can handle the key events.
1316 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1317 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1319 // Render and notify
1320 application.SendNotification();
1321 application.Render();
1323 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1325 // Create a second text editor and send key events to it.
1326 TextEditor editor2 = TextEditor::New();
1328 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1329 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1330 editor2.SetSize( 100.f, 100.f );
1331 editor2.SetPosition( 100.f, 100.f );
1333 Stage::GetCurrent().Add( editor2 );
1335 // Render and notify
1336 application.SendNotification();
1337 application.Render();
1339 // Create a tap event on the second text editor.
1340 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1341 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1343 // Render and notify
1344 application.SendNotification();
1345 application.Render();
1347 // The second text editor has the focus. It should handle the key events.
1348 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1349 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1351 // Render and notify
1352 application.SendNotification();
1353 application.Render();
1355 // Check the text has been added to the second text editor.
1356 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1361 int utcDaliTextEditorEvent02(void)
1363 ToolkitTestApplication application;
1364 tet_infoline(" utcDaliTextEditorEvent02");
1366 // Checks if the right number of actors are created.
1368 TextEditor editor = TextEditor::New();
1369 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1370 DALI_TEST_CHECK( editor );
1372 Stage::GetCurrent().Add( editor );
1374 editor.SetSize( 300.f, 50.f );
1375 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1376 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1378 // Avoid a crash when core load gl resources.
1379 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1381 // Render and notify
1382 application.SendNotification();
1383 application.Render();
1385 // Check there are the expected number of children (the stencil).
1386 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1388 Actor stencil = editor.GetChildAt( 0u );
1390 // Create a tap event to touch the text editor.
1391 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1392 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1394 // Render and notify
1395 application.SendNotification();
1396 application.Render();
1398 Actor layer = editor.GetChildAt( 1u );
1399 DALI_TEST_CHECK( layer.IsLayer() );
1401 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1402 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1404 // Now the text editor has the focus, so it can handle the key events.
1405 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1406 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1408 // Render and notify
1409 application.SendNotification();
1410 application.Render();
1412 // Checks the cursor and the renderer have been created.
1413 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1414 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1416 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1417 DALI_TEST_CHECK( cursor );
1419 // The stencil actor has a container with all the actors which contain the text renderers.
1420 Actor container = stencil.GetChildAt( 0u );
1421 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1423 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1424 DALI_TEST_CHECK( renderer );
1427 // Move the cursor and check the position changes.
1428 Vector3 position1 = cursor.GetCurrentPosition();
1430 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1431 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1433 // Render and notify
1434 application.SendNotification();
1435 application.Render();
1437 Vector3 position2 = cursor.GetCurrentPosition();
1439 DALI_TEST_CHECK( position2.x < position1.x );
1441 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1442 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1444 // Render and notify
1445 application.SendNotification();
1446 application.Render();
1448 Vector3 position3 = cursor.GetCurrentPosition();
1450 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1452 // Send some taps and check the cursor positions.
1454 // Try to tap at the beginning.
1455 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1456 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1458 // Render and notify
1459 application.SendNotification();
1460 application.Render();
1462 // Cursor position should be the same than position1.
1463 Vector3 position4 = cursor.GetCurrentPosition();
1465 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1467 // Tap away from the start position.
1468 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1469 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1471 // Render and notify
1472 application.SendNotification();
1473 application.Render();
1475 Vector3 position5 = cursor.GetCurrentPosition();
1477 DALI_TEST_CHECK( position5.x > position4.x );
1479 // Remove all the text.
1480 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1481 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1482 editor.SetProperty( TextEditor::Property::TEXT, "" );
1484 // Render and notify
1485 application.SendNotification();
1486 application.Render();
1488 // Cursor position should be the same than position2.
1489 Vector3 position6 = cursor.GetCurrentPosition();
1491 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1493 // Should not be a renderer.
1494 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1499 int utcDaliTextEditorEvent03(void)
1501 ToolkitTestApplication application;
1502 tet_infoline(" utcDaliTextEditorEvent03");
1504 // Checks if the highlight actor is created.
1506 TextEditor editor = TextEditor::New();
1507 DALI_TEST_CHECK( editor );
1509 Stage::GetCurrent().Add( editor );
1511 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1512 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1513 editor.SetSize( 30.f, 50.f );
1514 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1515 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1517 // Avoid a crash when core load gl resources.
1518 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Send some taps and check text controller with clipboard window
1525 Dali::Clipboard clipboard = Clipboard::Get();
1526 clipboard.ShowClipboard();
1527 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1528 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1529 clipboard.HideClipboard();
1531 // Render and notify
1532 application.SendNotification();
1533 application.Render();
1535 // Tap first to get the focus.
1536 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1537 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1539 // Render and notify
1540 application.SendNotification();
1541 application.Render();
1543 // Double tap to select a word.
1544 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1545 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 // The stencil actor should have two actors: the renderer and the highlight actor.
1552 Actor stencil = editor.GetChildAt( 0u );
1554 // The stencil actor has a container with all the actors which contain the text renderers.
1555 Actor container = stencil.GetChildAt( 0u );
1556 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1558 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1559 DALI_TEST_CHECK( renderer );
1562 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1563 DALI_TEST_CHECK( highlight );
1565 // Double tap out of bounds
1566 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1567 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // The stencil actor should have one actors: the renderer actor.
1574 stencil = editor.GetChildAt( 0u );
1576 // The stencil actor has a container with all the actors which contain the text renderers.
1577 container = stencil.GetChildAt( 0u );
1578 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1580 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1581 DALI_TEST_CHECK( renderer );
1587 int utcDaliTextEditorEvent04(void)
1589 ToolkitTestApplication application;
1590 tet_infoline(" utcDaliTextEditorEvent04");
1592 // Checks if the highlight actor is created.
1594 TextEditor editor = TextEditor::New();
1595 DALI_TEST_CHECK( editor );
1597 Stage::GetCurrent().Add( editor );
1599 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1600 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1601 editor.SetSize( 100.f, 50.f );
1602 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1603 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1605 // Avoid a crash when core load gl resources.
1606 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1608 // Render and notify
1609 application.SendNotification();
1610 application.Render();
1612 // Tap on the text editor
1613 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1614 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1616 // Render and notify
1617 application.SendNotification();
1618 application.Render();
1620 // Move at the end of the text.
1621 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1622 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1624 // Render and notify
1625 application.SendNotification();
1626 application.Render();
1628 for( unsigned int index = 0u; index < 10u; ++index )
1630 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1631 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1639 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1647 // Add some key events
1648 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1649 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1651 // Render and notify
1652 application.SendNotification();
1653 application.Render();
1655 for( unsigned int index = 0u; index < 10u; ++index )
1657 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1658 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1660 // Render and notify
1661 application.SendNotification();
1662 application.Render();
1666 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1668 // Render and notify
1669 application.SendNotification();
1670 application.Render();
1672 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1677 int utcDaliTextEditorEvent05(void)
1679 ToolkitTestApplication application;
1680 tet_infoline(" utcDaliTextEditorEvent05");
1682 // Checks if the highlight actor is created.
1684 TextEditor editor = TextEditor::New();
1685 DALI_TEST_CHECK( editor );
1687 Stage::GetCurrent().Add( editor );
1689 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1690 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1691 editor.SetSize( 50.f, 50.f );
1692 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1693 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1694 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1695 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1696 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1697 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1698 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1700 // Avoid a crash when core load gl resources.
1701 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1703 // Render and notify
1704 application.SendNotification();
1705 application.Render();
1707 // Tap on the text editor
1708 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1709 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1711 // Render and notify
1712 application.SendNotification();
1713 application.Render();
1715 // Move at the end of the text.
1716 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1717 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1719 // Render and notify
1720 application.SendNotification();
1721 application.Render();
1723 for( unsigned int index = 0u; index < 10u; ++index )
1726 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1728 // Render and notify
1729 application.SendNotification();
1730 application.Render();
1732 // Modify duration after scroll is enabled
1733 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1735 // Continuous scroll left to increase coverage
1736 for( unsigned int index = 0u; index < 10u; ++index )
1738 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1740 // Render and notify
1741 application.SendNotification();
1742 application.Render();
1744 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1745 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1746 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1747 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1748 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1750 // Press Escape to increase coverage
1751 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1752 application.SendNotification();
1753 application.Render();
1755 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1760 int utcDaliTextEditorHandles(void)
1762 ToolkitTestApplication application;
1763 tet_infoline(" utcDaliTextEditorHandles");
1765 TextEditor editor = TextEditor::New();
1766 DALI_TEST_CHECK( editor );
1768 Stage::GetCurrent().Add( editor );
1770 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1771 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1772 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1773 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1775 editor.SetSize( 30.f, 500.f );
1776 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1777 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1779 // Avoid a crash when core load gl resources.
1780 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1782 // Render and notify
1783 application.SendNotification();
1784 application.Render();
1786 // Tap first to get the focus.
1787 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1788 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1790 // Render and notify
1791 application.SendNotification();
1792 application.Render();
1794 // Tap to create the grab handle.
1795 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1796 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1798 // Render and notify
1799 application.SendNotification();
1800 application.Render();
1802 // Get the active layer where the text's decoration is added.
1803 Actor activeLayer = editor.GetChildAt( 1u );
1805 // Get the handle's actor.
1806 Actor handle = activeLayer.GetChildAt( 1u );
1807 handle.SetSize( 100.f, 100.f );
1809 // Render and notify
1810 application.SendNotification();
1811 application.Render();
1813 // Touch the grab handle to set it as pressed.
1814 Vector2 touchPos( 10.0f, 50.0f );
1815 Dali::Integration::TouchEvent event;
1816 event = Dali::Integration::TouchEvent();
1817 event.AddPoint( GetPointDownInside( touchPos ) );
1818 application.ProcessEvent( event );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1824 // drag grab handle right
1825 SendPan(application, Gesture::Possible, touchPos);
1826 SendPan(application, Gesture::Started, touchPos);
1828 Wait(application, 100);
1830 for(int i = 0;i<20;i++)
1832 SendPan(application, Gesture::Continuing, touchPos);
1837 SendPan(application, Gesture::Finished, touchPos);
1840 // Release the grab handle.
1841 event = Dali::Integration::TouchEvent();
1842 event.AddPoint( GetPointUpInside( touchPos ) );
1843 application.ProcessEvent( event );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1853 int utcDaliTextEditorUnderPropertyStringP(void)
1855 ToolkitTestApplication application;
1856 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
1857 TextEditor editor = TextEditor::New();
1858 DALI_TEST_CHECK( editor );
1860 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
1862 Stage::GetCurrent().Add( editor );
1864 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1865 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
1867 tet_infoline("Set underline settings with a map");
1868 // Check the input underline property
1869 Property::Map underlineMapSet;
1870 Property::Map underlineMapGet;
1871 underlineMapSet.Insert( "enable", "true" );
1872 underlineMapSet.Insert( "color", "blue" );
1873 underlineMapSet.Insert( "height", "2" );
1875 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
1876 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
1877 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
1878 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
1880 tet_infoline("Set underline settings with a string");
1881 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1882 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1885 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
1887 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
1888 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
1889 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
1890 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1892 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
1897 int utcDaliTextEditorShadowPropertyStringP(void)
1899 ToolkitTestApplication application;
1900 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
1902 TextEditor editor = TextEditor::New();
1904 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
1906 Stage::GetCurrent().Add( editor );
1908 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
1910 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
1914 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
1919 int utcDaliTextEditorFontStylePropertyStringP(void)
1921 ToolkitTestApplication application;
1922 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
1924 TextEditor editor = TextEditor::New();
1926 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
1928 Stage::GetCurrent().Add( editor );
1930 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
1932 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
1936 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
1940 int utcDaliTextEditorGetPropertyLinecountP(void)
1942 ToolkitTestApplication application;
1944 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
1948 TextEditor editor = TextEditor::New();
1949 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
1950 editor.SetProperty( TextEditor::Property::TEXT,
1951 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
1953 Stage::GetCurrent().Add( editor );
1955 editor.SetSize( 100.0f, 100.0f );
1956 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
1957 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
1959 editor.SetSize( 50.0f, 100.0f );
1960 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
1961 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );