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";
97 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
99 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
101 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
102 const float TO_MILLISECONDS = 1000.f;
103 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
104 const float RENDER_FRAME_INTERVAL = 16.66f;
106 const float SCROLL_THRESHOLD = 10.f;
107 const float SCROLL_SPEED = 300.f;
109 const unsigned int DEFAULT_FONT_SIZE = 1152u;
110 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
112 const int KEY_A_CODE = 38;
113 const int KEY_D_CODE = 40;
114 const int KEY_WHITE_SPACE_CODE = 65;
116 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
118 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
120 static bool gTextChangedCallBackCalled;
121 static bool gInputStyleChangedCallbackCalled;
122 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
124 struct CallbackFunctor
126 CallbackFunctor(bool* callbackFlag)
127 : mCallbackFlag( callbackFlag )
133 *mCallbackFlag = true;
138 static void TestTextChangedCallback( TextEditor control )
140 tet_infoline(" TestTextChangedCallback");
142 gTextChangedCallBackCalled = true;
145 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
147 tet_infoline(" TestInputStyleChangedCallback");
149 gInputStyleChangedCallbackCalled = true;
150 gInputStyleMask = mask;
153 // Generate a TapGestureEvent to send to Core.
154 Integration::TapGestureEvent GenerateTap(
155 Gesture::State state,
156 unsigned int numberOfTaps,
157 unsigned int numberOfTouches,
160 Integration::TapGestureEvent tap( state );
162 tap.numberOfTaps = numberOfTaps;
163 tap.numberOfTouches = numberOfTouches;
169 // Generate a PanGestureEvent to send to Core
170 Integration::PanGestureEvent GeneratePan( Gesture::State state,
171 const Vector2& previousPosition,
172 const Vector2& currentPosition,
173 unsigned long timeDelta,
174 unsigned int numberOfTouches = 1u )
176 Integration::PanGestureEvent pan(state);
178 pan.previousPosition = previousPosition;
179 pan.currentPosition = currentPosition;
180 pan.timeDelta = timeDelta;
181 pan.numberOfTouches = numberOfTouches;
186 // Generate a KeyEvent to send to Core.
187 Integration::KeyEvent GenerateKey( const std::string& keyName,
188 const std::string& keyString,
191 unsigned long timeStamp,
192 const Integration::KeyEvent::State& keyState,
193 const std::string& deviceName,
194 const DevelKeyEvent::DeviceClass::Type& deviceClass )
196 return Integration::KeyEvent( keyName,
207 * Helper to generate PanGestureEvent
209 * @param[in] application Application instance
210 * @param[in] state The Gesture State
211 * @param[in] pos The current position of touch.
213 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
217 if( (state == Gesture::Started) ||
218 (state == Gesture::Possible) )
224 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
231 * Simulate time passed by.
233 * @note this will always process at least 1 frame (1/60 sec)
235 * @param application Test application instance
236 * @param duration Time to pass in milliseconds.
237 * @return The actual time passed in milliseconds
239 static int Wait(ToolkitTestApplication& application, int duration = 0)
243 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
245 application.SendNotification();
246 application.Render(RENDER_FRAME_INTERVAL);
247 time += RENDER_FRAME_INTERVAL;
253 Dali::Integration::Point GetPointDownInside( Vector2& pos )
255 Dali::Integration::Point point;
256 point.SetState( PointState::DOWN );
257 point.SetScreenPosition( pos );
261 Dali::Integration::Point GetPointUpInside( Vector2& pos )
263 Dali::Integration::Point point;
264 point.SetState( PointState::UP );
265 point.SetScreenPosition( pos );
269 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
271 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
273 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
275 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
277 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
278 if( NULL != valueSet )
280 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
282 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
288 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
299 int UtcDaliToolkitTextEditorConstructorP(void)
301 ToolkitTestApplication application;
302 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
303 TextEditor textEditor;
304 DALI_TEST_CHECK( !textEditor );
308 int UtcDaliToolkitTextEditorNewP(void)
310 ToolkitTestApplication application;
311 tet_infoline(" UtcDaliToolkitTextEditorNewP");
312 TextEditor textEditor = TextEditor::New();
313 DALI_TEST_CHECK( textEditor );
317 int UtcDaliToolkitTextEditorDownCastP(void)
319 ToolkitTestApplication application;
320 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
321 TextEditor textEditor1 = TextEditor::New();
322 BaseHandle object( textEditor1 );
324 TextEditor textEditor2 = TextEditor::DownCast( object );
325 DALI_TEST_CHECK( textEditor2 );
327 TextEditor textEditor3 = DownCast< TextEditor >( object );
328 DALI_TEST_CHECK( textEditor3 );
332 int UtcDaliToolkitTextEditorDownCastN(void)
334 ToolkitTestApplication application;
335 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
336 BaseHandle uninitializedObject;
337 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
338 DALI_TEST_CHECK( !textEditor1 );
340 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
341 DALI_TEST_CHECK( !textEditor2 );
345 int UtcDaliToolkitTextEditorCopyConstructorP(void)
347 ToolkitTestApplication application;
348 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
349 TextEditor textEditor = TextEditor::New();
350 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
352 TextEditor copy( textEditor );
353 DALI_TEST_CHECK( copy );
354 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
358 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
360 ToolkitTestApplication application;
361 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
362 TextEditor textEditor = TextEditor::New();
363 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
365 TextEditor copy = textEditor;
366 DALI_TEST_CHECK( copy );
367 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
371 int UtcDaliTextEditorNewP(void)
373 ToolkitTestApplication application;
374 tet_infoline(" UtcDaliToolkitTextEditorNewP");
375 TextEditor textEditor = TextEditor::New();
376 DALI_TEST_CHECK( textEditor );
380 // Positive test case for a method
381 int UtcDaliTextEditorGetPropertyP(void)
383 ToolkitTestApplication application;
384 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
385 TextEditor editor = TextEditor::New();
386 DALI_TEST_CHECK( editor );
388 // Check Property Indices are correct
389 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
390 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
391 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
392 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
393 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
394 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
395 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
396 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
397 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
398 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
399 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
400 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
401 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
402 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
403 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
404 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
405 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
406 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
407 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
408 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
409 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
410 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
411 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
412 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
413 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
414 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
415 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
416 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
417 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
424 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
440 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
443 Property::Map imageMap;
444 imageMap[mapKey] =mapValue;
446 editor.SetProperty( property , imageMap );
447 Property::Value propValue = editor.GetProperty( property );
448 Property::Map* resultMap = propValue.GetMap();
450 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
458 // Positive test case for a method
459 int UtcDaliTextEditorSetPropertyP(void)
461 ToolkitTestApplication application;
462 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
463 TextEditor editor = TextEditor::New();
464 DALI_TEST_CHECK( editor );
465 Stage::GetCurrent().Add( editor );
467 // Note - we can't check the defaults since the stylesheets are platform-specific
469 // Check the render backend property.
470 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
471 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
473 // Check text property.
474 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
475 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
477 // Check text's color property
478 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
479 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
481 // Check font properties.
482 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
483 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
485 Property::Map fontStyleMapSet;
486 Property::Map fontStyleMapGet;
487 Property::Value* slantValue = NULL;
489 fontStyleMapSet.Insert( "weight", "bold" );
490 fontStyleMapSet.Insert( "width", "condensed" );
491 fontStyleMapSet.Insert( "slant", "italic" );
493 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
494 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
495 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
496 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
498 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
499 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
502 fontStyleMapSet.Clear();
503 fontStyleMapSet.Insert( "weight", "normal" );
504 fontStyleMapSet.Insert( "slant", "oblique" );
505 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
506 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
507 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
508 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
510 fontStyleMapSet.Clear();
511 fontStyleMapSet.Insert( "slant", "roman" );
512 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
513 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
515 // Replace 'roman' for 'normal'.
516 slantValue = fontStyleMapGet.Find( "slant" );
517 if( NULL != slantValue )
519 if( "normal" == slantValue->Get<std::string>() )
521 fontStyleMapGet["slant"] = "roman";
524 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
525 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
527 fontStyleMapSet.Clear();
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 // Check that the Alignment properties can be correctly set
535 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
536 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
538 // Check scroll properties.
539 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
540 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
541 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
542 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
544 // Check cursor properties
545 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
546 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
547 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
548 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
550 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
551 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
552 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
553 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
554 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
555 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
556 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
557 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
559 // Check handle images
560 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
561 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
562 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
563 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
564 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
566 // Check handle images
567 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
568 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
569 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
570 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
571 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
572 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
574 // Check the highlight color
575 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
576 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
578 // Decoration bounding box
579 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
580 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
582 // Check the enable markup property.
583 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
584 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
585 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
587 // Check input color property.
588 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
589 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
591 // Check input font properties.
592 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
593 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
595 fontStyleMapSet.Clear();
596 fontStyleMapSet.Insert( "weight", "bold" );
597 fontStyleMapSet.Insert( "width", "condensed" );
598 fontStyleMapSet.Insert( "slant", "italic" );
600 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
601 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
602 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
603 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
605 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
606 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
608 // Reset input font style.
609 fontStyleMapSet.Clear();
610 fontStyleMapSet.Insert( "weight", "normal" );
611 fontStyleMapSet.Insert( "slant", "oblique" );
613 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
614 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
615 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
616 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
618 fontStyleMapSet.Clear();
619 fontStyleMapSet.Insert( "slant", "roman" );
621 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
622 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
624 // Replace 'roman' for 'normal'.
625 slantValue = fontStyleMapGet.Find( "slant" );
626 if( NULL != slantValue )
628 if( "normal" == slantValue->Get<std::string>() )
630 fontStyleMapGet["slant"] = "roman";
633 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
634 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
636 fontStyleMapSet.Clear();
638 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
639 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
640 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
641 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
643 // Check the line spacing property
644 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
645 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
646 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
648 // Check the input line spacing property
649 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
650 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
651 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 // Check the underline property
655 Property::Map underlineMapSet;
656 Property::Map underlineMapGet;
658 underlineMapSet.Insert( "enable", "true" );
659 underlineMapSet.Insert( "color", "red" );
660 underlineMapSet.Insert( "height", "1" );
662 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
664 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
665 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
666 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
668 // Check the input underline property
669 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
670 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
672 // Check the shadow property
673 Property::Map shadowMapSet;
674 Property::Map shadowMapGet;
676 shadowMapSet.Insert( "color", "green" );
677 shadowMapSet.Insert( "offset", "2 2" );
679 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
681 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
682 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
683 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
685 // Check the input shadow property
686 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
687 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
689 // Check the emboss property
690 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
691 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
693 // Check the input emboss property
694 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
695 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
697 // Check the outline property
698 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
699 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
701 // Check the input outline property
702 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
703 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
705 // Check the smooth scroll property
706 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
707 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
708 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
710 // Check the smooth scroll duration property
711 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
712 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
714 // Check the scroll bar property
715 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
716 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
717 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
719 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
720 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
721 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
722 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
724 // Check the pixel size of font
725 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
726 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
731 // Positive Atlas Text Renderer test
732 int utcDaliTextEditorAtlasRenderP(void)
734 ToolkitTestApplication application;
735 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
736 StyleManager styleManager = StyleManager::Get();
737 styleManager.ApplyDefaultTheme();
738 TextEditor editor = TextEditor::New();
739 DALI_TEST_CHECK( editor );
741 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
743 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
745 Stage::GetCurrent().Add( editor );
749 // Render some text with the shared atlas backend
750 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
751 application.SendNotification();
752 application.Render();
756 tet_result(TET_FAIL);
761 // Positive test for the textChanged signal.
762 int utcDaliTextEditorTextChangedP(void)
764 ToolkitTestApplication application;
765 tet_infoline(" utcDaliTextEditorTextChangedP");
766 TextEditor editor = TextEditor::New();
767 DALI_TEST_CHECK( editor );
769 Stage::GetCurrent().Add( editor );
771 // connect to the text changed signal.
772 ConnectionTracker* testTracker = new ConnectionTracker();
773 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
774 bool textChangedSignal = false;
775 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
777 gTextChangedCallBackCalled = false;
778 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
779 DALI_TEST_CHECK( gTextChangedCallBackCalled );
780 DALI_TEST_CHECK( textChangedSignal );
782 application.SendNotification();
784 editor.SetKeyInputFocus();
786 gTextChangedCallBackCalled = false;
787 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
788 DALI_TEST_CHECK( gTextChangedCallBackCalled );
793 int utcDaliTextEditorInputStyleChanged01(void)
795 ToolkitTestApplication application;
796 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
798 // The text-editor emits signals when the input style changes. These changes of style are
799 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
800 // can't be emitted during the size negotiation as the callbacks may update the UI.
801 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
802 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
803 application.CreateAdaptor();
807 char* pathNamePtr = get_current_dir_name();
808 const std::string pathName( pathNamePtr );
811 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
812 fontClient.SetDpi( 93u, 93u );
814 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
815 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
817 TextEditor editor = TextEditor::New();
818 DALI_TEST_CHECK( editor );
821 editor.SetSize( 300.f, 50.f );
822 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
823 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
825 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
826 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
828 // connect to the text changed signal.
829 ConnectionTracker* testTracker = new ConnectionTracker();
830 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
831 bool inputStyleChangedSignal = false;
832 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
834 Stage::GetCurrent().Add( editor );
837 application.SendNotification();
838 application.Render();
840 // Executes the idle callbacks added by the text control on the change of input style.
841 application.RunIdles();
843 gInputStyleChangedCallbackCalled = false;
844 gInputStyleMask = TextEditor::InputStyle::NONE;
845 inputStyleChangedSignal = false;
847 // Create a tap event to touch the text editor.
848 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
849 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
852 application.SendNotification();
853 application.Render();
855 // Executes the idle callbacks added by the text control on the change of input style.
856 application.RunIdles();
858 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
859 if( gInputStyleChangedCallbackCalled )
861 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
863 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
864 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
866 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
867 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
869 DALI_TEST_CHECK( inputStyleChangedSignal );
871 gInputStyleChangedCallbackCalled = false;
872 gInputStyleMask = TextEditor::InputStyle::NONE;
873 inputStyleChangedSignal = false;
875 // Create a tap event to touch the text editor.
876 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
877 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
880 application.SendNotification();
881 application.Render();
883 // Executes the idle callbacks added by the text control on the change of input style.
884 application.RunIdles();
886 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
887 DALI_TEST_CHECK( !inputStyleChangedSignal );
889 gInputStyleChangedCallbackCalled = false;
890 gInputStyleMask = TextEditor::InputStyle::NONE;
891 inputStyleChangedSignal = false;
893 // Create a tap event to touch the text editor.
894 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
895 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
898 application.SendNotification();
899 application.Render();
901 // Executes the idle callbacks added by the text control on the change of input style.
902 application.RunIdles();
904 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
905 if( gInputStyleChangedCallbackCalled )
907 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
909 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
910 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
912 DALI_TEST_CHECK( inputStyleChangedSignal );
914 gInputStyleChangedCallbackCalled = false;
915 gInputStyleMask = TextEditor::InputStyle::NONE;
916 inputStyleChangedSignal = false;
918 // Create a tap event to touch the text editor.
919 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
920 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
923 application.SendNotification();
924 application.Render();
926 // Executes the idle callbacks added by the text control on the change of input style.
927 application.RunIdles();
929 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
930 if( gInputStyleChangedCallbackCalled )
932 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
934 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
935 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
937 Property::Map fontStyleMapSet;
938 Property::Map fontStyleMapGet;
940 fontStyleMapSet.Insert( "weight", "bold" );
942 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
943 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
944 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
946 DALI_TEST_CHECK( inputStyleChangedSignal );
948 gInputStyleChangedCallbackCalled = false;
949 gInputStyleMask = TextEditor::InputStyle::NONE;
950 inputStyleChangedSignal = false;
952 // Create a tap event to touch the text editor.
953 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
954 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
957 application.SendNotification();
958 application.Render();
960 // Executes the idle callbacks added by the text control on the change of input style.
961 application.RunIdles();
963 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
964 DALI_TEST_CHECK( !inputStyleChangedSignal );
966 gInputStyleChangedCallbackCalled = false;
967 gInputStyleMask = TextEditor::InputStyle::NONE;
968 inputStyleChangedSignal = false;
970 // Create a tap event to touch the text editor.
971 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
972 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
975 application.SendNotification();
976 application.Render();
978 // Executes the idle callbacks added by the text control on the change of input style.
979 application.RunIdles();
981 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
982 if( gInputStyleChangedCallbackCalled )
984 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
986 Property::Map fontStyleMapSet;
987 Property::Map fontStyleMapGet;
989 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
990 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
991 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
993 DALI_TEST_CHECK( inputStyleChangedSignal );
995 gInputStyleChangedCallbackCalled = false;
996 gInputStyleMask = TextEditor::InputStyle::NONE;
997 inputStyleChangedSignal = false;
999 // Create a tap event to touch the text editor.
1000 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1001 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1003 // Render and notify
1004 application.SendNotification();
1005 application.Render();
1007 // Executes the idle callbacks added by the text control on the change of input style.
1008 application.RunIdles();
1010 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1011 DALI_TEST_CHECK( !inputStyleChangedSignal );
1016 int utcDaliTextEditorInputStyleChanged02(void)
1018 ToolkitTestApplication application;
1019 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1021 // The text-editor emits signals when the input style changes. These changes of style are
1022 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1023 // can't be emitted during the size negotiation as the callbacks may update the UI.
1024 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1025 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1026 application.CreateAdaptor();
1030 char* pathNamePtr = get_current_dir_name();
1031 const std::string pathName( pathNamePtr );
1032 free( pathNamePtr );
1034 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1035 fontClient.SetDpi( 93u, 93u );
1037 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1038 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1040 TextEditor editor = TextEditor::New();
1041 DALI_TEST_CHECK( editor );
1044 editor.SetSize( 300.f, 50.f );
1045 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1046 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1048 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1049 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>" );
1051 // connect to the text changed signal.
1052 ConnectionTracker* testTracker = new ConnectionTracker();
1053 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1054 bool inputStyleChangedSignal = false;
1055 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1057 Stage::GetCurrent().Add( editor );
1059 // Render and notify
1060 application.SendNotification();
1061 application.Render();
1063 // Executes the idle callbacks added by the text control on the change of input style.
1064 application.RunIdles();
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( 53.f, 25.f ) ) );
1072 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1073 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1074 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1076 // Render and notify
1077 application.SendNotification();
1078 application.Render();
1080 // Executes the idle callbacks added by the text control on the change of input style.
1081 application.RunIdles();
1083 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1084 if( gInputStyleChangedCallbackCalled )
1086 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1087 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1088 TextEditor::InputStyle::POINT_SIZE |
1089 TextEditor::InputStyle::COLOR ),
1092 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1093 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1095 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1096 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1098 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1099 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1101 DALI_TEST_CHECK( inputStyleChangedSignal );
1103 gInputStyleChangedCallbackCalled = false;
1104 gInputStyleMask = TextEditor::InputStyle::NONE;
1105 inputStyleChangedSignal = false;
1107 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1109 // Render and notify
1110 application.SendNotification();
1111 application.Render();
1113 // Executes the idle callbacks added by the text control on the change of input style.
1114 application.RunIdles();
1116 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1117 if( gInputStyleChangedCallbackCalled )
1119 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1120 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1123 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1124 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1126 DALI_TEST_CHECK( inputStyleChangedSignal );
1128 gInputStyleChangedCallbackCalled = false;
1129 gInputStyleMask = TextEditor::InputStyle::NONE;
1130 inputStyleChangedSignal = false;
1132 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1134 // Render and notify
1135 application.SendNotification();
1136 application.Render();
1138 // Executes the idle callbacks added by the text control on the change of input style.
1139 application.RunIdles();
1141 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1142 DALI_TEST_CHECK( !inputStyleChangedSignal );
1144 gInputStyleChangedCallbackCalled = false;
1145 gInputStyleMask = TextEditor::InputStyle::NONE;
1146 inputStyleChangedSignal = false;
1148 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1150 // Render and notify
1151 application.SendNotification();
1152 application.Render();
1154 // Executes the idle callbacks added by the text control on the change of input style.
1155 application.RunIdles();
1157 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1158 if( gInputStyleChangedCallbackCalled )
1160 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1161 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1164 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1165 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1167 DALI_TEST_CHECK( inputStyleChangedSignal );
1169 gInputStyleChangedCallbackCalled = false;
1170 gInputStyleMask = TextEditor::InputStyle::NONE;
1171 inputStyleChangedSignal = false;
1173 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1175 Property::Map fontStyleMapSet;
1176 fontStyleMapSet.Insert( "weight", "thin" );
1177 fontStyleMapSet.Insert( "width", "condensed" );
1178 fontStyleMapSet.Insert( "slant", "italic" );
1180 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1181 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1182 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1184 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1185 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1186 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1187 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1189 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1191 // Render and notify
1192 application.SendNotification();
1193 application.Render();
1195 // Executes the idle callbacks added by the text control on the change of input style.
1196 application.RunIdles();
1198 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1199 DALI_TEST_CHECK( !inputStyleChangedSignal );
1201 // Create a tap event to touch the text editor.
1202 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1203 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1205 // Render and notify
1206 application.SendNotification();
1207 application.Render();
1209 // Executes the idle callbacks added by the text control on the change of input style.
1210 application.RunIdles();
1212 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1213 if( gInputStyleChangedCallbackCalled )
1215 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1216 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1217 TextEditor::InputStyle::POINT_SIZE |
1218 TextEditor::InputStyle::FONT_STYLE |
1219 TextEditor::InputStyle::LINE_SPACING |
1220 TextEditor::InputStyle::UNDERLINE |
1221 TextEditor::InputStyle::SHADOW |
1222 TextEditor::InputStyle::EMBOSS |
1223 TextEditor::InputStyle::OUTLINE ),
1226 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1227 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1229 DALI_TEST_CHECK( inputStyleChangedSignal );
1231 gInputStyleChangedCallbackCalled = false;
1232 gInputStyleMask = TextEditor::InputStyle::NONE;
1233 inputStyleChangedSignal = false;
1235 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1237 fontStyleMapSet.Clear();
1238 fontStyleMapSet.Insert( "weight", "black" );
1239 fontStyleMapSet.Insert( "width", "expanded" );
1240 fontStyleMapSet.Insert( "slant", "oblique" );
1242 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1244 // Create a tap event to touch the text editor.
1245 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1246 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1248 // Render and notify
1249 application.SendNotification();
1250 application.Render();
1252 // Executes the idle callbacks added by the text control on the change of input style.
1253 application.RunIdles();
1255 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1256 if( gInputStyleChangedCallbackCalled )
1258 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1259 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1260 TextEditor::InputStyle::POINT_SIZE |
1261 TextEditor::InputStyle::FONT_STYLE ),
1264 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1265 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1267 DALI_TEST_CHECK( inputStyleChangedSignal );
1272 int utcDaliTextEditorEvent01(void)
1274 ToolkitTestApplication application;
1275 tet_infoline(" utcDaliTextEditorEvent01");
1277 // Creates a tap event. After creating a tap event the text editor should
1278 // have the focus and add text with key events should be possible.
1280 TextEditor editor = TextEditor::New();
1281 DALI_TEST_CHECK( editor );
1283 Stage::GetCurrent().Add( editor );
1285 editor.SetSize( 300.f, 50.f );
1286 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1287 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1289 // Avoid a crash when core load gl resources.
1290 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1292 // Render and notify
1293 application.SendNotification();
1294 application.Render();
1296 // Add a key event but as the text editor has not the focus it should do nothing.
1297 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1305 // Create a tap event to touch the text editor.
1306 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1307 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 // Now the text editor has the focus, so it can handle the key events.
1314 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1315 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1317 // Render and notify
1318 application.SendNotification();
1319 application.Render();
1321 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1323 // Create a second text editor and send key events to it.
1324 TextEditor editor2 = TextEditor::New();
1326 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1327 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1328 editor2.SetSize( 100.f, 100.f );
1329 editor2.SetPosition( 100.f, 100.f );
1331 Stage::GetCurrent().Add( editor2 );
1333 // Render and notify
1334 application.SendNotification();
1335 application.Render();
1337 // Create a tap event on the second text editor.
1338 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1339 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1341 // Render and notify
1342 application.SendNotification();
1343 application.Render();
1345 // The second text editor has the focus. It should handle the key events.
1346 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1347 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1349 // Render and notify
1350 application.SendNotification();
1351 application.Render();
1353 // Check the text has been added to the second text editor.
1354 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1359 int utcDaliTextEditorEvent02(void)
1361 ToolkitTestApplication application;
1362 tet_infoline(" utcDaliTextEditorEvent02");
1364 // Checks if the right number of actors are created.
1366 TextEditor editor = TextEditor::New();
1367 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1368 DALI_TEST_CHECK( editor );
1370 Stage::GetCurrent().Add( editor );
1372 editor.SetSize( 300.f, 50.f );
1373 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1374 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1376 // Avoid a crash when core load gl resources.
1377 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1379 // Render and notify
1380 application.SendNotification();
1381 application.Render();
1383 // Check there are the expected number of children (the stencil).
1384 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1386 Actor stencil = editor.GetChildAt( 0u );
1388 // Create a tap event to touch the text editor.
1389 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1390 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1392 // Render and notify
1393 application.SendNotification();
1394 application.Render();
1396 Actor layer = editor.GetChildAt( 1u );
1397 DALI_TEST_CHECK( layer.IsLayer() );
1399 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1400 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1402 // Now the text editor has the focus, so it can handle the key events.
1403 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1404 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1406 // Render and notify
1407 application.SendNotification();
1408 application.Render();
1410 // Checks the cursor and the renderer have been created.
1411 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1412 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1414 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1415 DALI_TEST_CHECK( cursor );
1417 // The stencil actor has a container with all the actors which contain the text renderers.
1418 Actor container = stencil.GetChildAt( 0u );
1419 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1421 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1422 DALI_TEST_CHECK( renderer );
1425 // Move the cursor and check the position changes.
1426 Vector3 position1 = cursor.GetCurrentPosition();
1428 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1429 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1431 // Render and notify
1432 application.SendNotification();
1433 application.Render();
1435 Vector3 position2 = cursor.GetCurrentPosition();
1437 DALI_TEST_CHECK( position2.x < position1.x );
1439 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1440 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1442 // Render and notify
1443 application.SendNotification();
1444 application.Render();
1446 Vector3 position3 = cursor.GetCurrentPosition();
1448 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1450 // Send some taps and check the cursor positions.
1452 // Try to tap at the beginning.
1453 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1454 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1456 // Render and notify
1457 application.SendNotification();
1458 application.Render();
1460 // Cursor position should be the same than position1.
1461 Vector3 position4 = cursor.GetCurrentPosition();
1463 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1465 // Tap away from the start position.
1466 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1467 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1469 // Render and notify
1470 application.SendNotification();
1471 application.Render();
1473 Vector3 position5 = cursor.GetCurrentPosition();
1475 DALI_TEST_CHECK( position5.x > position4.x );
1477 // Remove all the text.
1478 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1479 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1480 editor.SetProperty( TextEditor::Property::TEXT, "" );
1482 // Render and notify
1483 application.SendNotification();
1484 application.Render();
1486 // Cursor position should be the same than position2.
1487 Vector3 position6 = cursor.GetCurrentPosition();
1489 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1491 // Should not be a renderer.
1492 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1497 int utcDaliTextEditorEvent03(void)
1499 ToolkitTestApplication application;
1500 tet_infoline(" utcDaliTextEditorEvent03");
1502 // Checks if the highlight actor is created.
1504 TextEditor editor = TextEditor::New();
1505 DALI_TEST_CHECK( editor );
1507 Stage::GetCurrent().Add( editor );
1509 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1510 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1511 editor.SetSize( 30.f, 50.f );
1512 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1513 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1515 // Avoid a crash when core load gl resources.
1516 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1518 // Render and notify
1519 application.SendNotification();
1520 application.Render();
1522 // Send some taps and check text controller with clipboard window
1523 Dali::Clipboard clipboard = Clipboard::Get();
1524 clipboard.ShowClipboard();
1525 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1526 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1527 clipboard.HideClipboard();
1529 // Render and notify
1530 application.SendNotification();
1531 application.Render();
1533 // Tap first to get the focus.
1534 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1535 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1537 // Render and notify
1538 application.SendNotification();
1539 application.Render();
1541 // Double tap to select a word.
1542 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1543 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1545 // Render and notify
1546 application.SendNotification();
1547 application.Render();
1549 // The stencil actor should have two actors: the renderer and the highlight actor.
1550 Actor stencil = editor.GetChildAt( 0u );
1552 // The stencil actor has a container with all the actors which contain the text renderers.
1553 Actor container = stencil.GetChildAt( 0u );
1554 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1556 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1557 DALI_TEST_CHECK( renderer );
1560 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1561 DALI_TEST_CHECK( highlight );
1563 // Double tap out of bounds
1564 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1565 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // The stencil actor should have one actors: the renderer actor.
1572 stencil = editor.GetChildAt( 0u );
1574 // The stencil actor has a container with all the actors which contain the text renderers.
1575 container = stencil.GetChildAt( 0u );
1576 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1578 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1579 DALI_TEST_CHECK( renderer );
1585 int utcDaliTextEditorEvent04(void)
1587 ToolkitTestApplication application;
1588 tet_infoline(" utcDaliTextEditorEvent04");
1590 // Checks if the highlight actor is created.
1592 TextEditor editor = TextEditor::New();
1593 DALI_TEST_CHECK( editor );
1595 Stage::GetCurrent().Add( editor );
1597 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1598 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1599 editor.SetSize( 100.f, 50.f );
1600 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1601 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1603 // Avoid a crash when core load gl resources.
1604 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Tap on the text editor
1611 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1612 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1614 // Render and notify
1615 application.SendNotification();
1616 application.Render();
1618 // Move at the end of the text.
1619 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1620 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1622 // Render and notify
1623 application.SendNotification();
1624 application.Render();
1626 for( unsigned int index = 0u; index < 10u; ++index )
1628 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1629 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1631 // Render and notify
1632 application.SendNotification();
1633 application.Render();
1637 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1645 // Add some key events
1646 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1647 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1649 // Render and notify
1650 application.SendNotification();
1651 application.Render();
1653 for( unsigned int index = 0u; index < 10u; ++index )
1655 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1656 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1658 // Render and notify
1659 application.SendNotification();
1660 application.Render();
1664 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1675 int utcDaliTextEditorEvent05(void)
1677 ToolkitTestApplication application;
1678 tet_infoline(" utcDaliTextEditorEvent05");
1680 // Checks if the highlight actor is created.
1682 TextEditor editor = TextEditor::New();
1683 DALI_TEST_CHECK( editor );
1685 Stage::GetCurrent().Add( editor );
1687 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1688 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1689 editor.SetSize( 50.f, 50.f );
1690 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1691 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1692 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1693 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1694 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1695 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1696 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1698 // Avoid a crash when core load gl resources.
1699 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1701 // Render and notify
1702 application.SendNotification();
1703 application.Render();
1705 // Tap on the text editor
1706 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1707 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 // Move at the end of the text.
1714 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1715 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1717 // Render and notify
1718 application.SendNotification();
1719 application.Render();
1721 for( unsigned int index = 0u; index < 10u; ++index )
1724 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1726 // Render and notify
1727 application.SendNotification();
1728 application.Render();
1730 // Modify duration after scroll is enabled
1731 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1733 // Continuous scroll left to increase coverage
1734 for( unsigned int index = 0u; index < 10u; ++index )
1736 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1738 // Render and notify
1739 application.SendNotification();
1740 application.Render();
1742 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1743 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1744 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1745 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1746 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1748 // Press Escape to increase coverage
1749 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1750 application.SendNotification();
1751 application.Render();
1753 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1758 int utcDaliTextEditorHandles(void)
1760 ToolkitTestApplication application;
1761 tet_infoline(" utcDaliTextEditorHandles");
1763 TextEditor editor = TextEditor::New();
1764 DALI_TEST_CHECK( editor );
1766 Stage::GetCurrent().Add( editor );
1768 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1769 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1770 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1771 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1773 editor.SetSize( 30.f, 500.f );
1774 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1775 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1777 // Avoid a crash when core load gl resources.
1778 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1780 // Render and notify
1781 application.SendNotification();
1782 application.Render();
1784 // Tap first to get the focus.
1785 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1786 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1788 // Render and notify
1789 application.SendNotification();
1790 application.Render();
1792 // Tap to create the grab handle.
1793 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1794 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // Get the active layer where the text's decoration is added.
1801 Actor activeLayer = editor.GetChildAt( 1u );
1803 // Get the handle's actor.
1804 Actor handle = activeLayer.GetChildAt( 1u );
1805 handle.SetSize( 100.f, 100.f );
1807 // Render and notify
1808 application.SendNotification();
1809 application.Render();
1811 // Touch the grab handle to set it as pressed.
1812 Vector2 touchPos( 10.0f, 50.0f );
1813 Dali::Integration::TouchEvent event;
1814 event = Dali::Integration::TouchEvent();
1815 event.AddPoint( GetPointDownInside( touchPos ) );
1816 application.ProcessEvent( event );
1818 // Render and notify
1819 application.SendNotification();
1820 application.Render();
1822 // drag grab handle right
1823 SendPan(application, Gesture::Possible, touchPos);
1824 SendPan(application, Gesture::Started, touchPos);
1826 Wait(application, 100);
1828 for(int i = 0;i<20;i++)
1830 SendPan(application, Gesture::Continuing, touchPos);
1835 SendPan(application, Gesture::Finished, touchPos);
1838 // Release the grab handle.
1839 event = Dali::Integration::TouchEvent();
1840 event.AddPoint( GetPointUpInside( touchPos ) );
1841 application.ProcessEvent( event );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1851 int utcDaliTextEditorUnderPropertyStringP(void)
1853 ToolkitTestApplication application;
1854 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
1855 TextEditor editor = TextEditor::New();
1856 DALI_TEST_CHECK( editor );
1858 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
1860 Stage::GetCurrent().Add( editor );
1862 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1863 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
1865 tet_infoline("Set underline settings with a map");
1866 // Check the input underline property
1867 Property::Map underlineMapSet;
1868 Property::Map underlineMapGet;
1869 underlineMapSet.Insert( "enable", "true" );
1870 underlineMapSet.Insert( "color", "blue" );
1871 underlineMapSet.Insert( "height", "2" );
1873 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
1874 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
1875 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
1876 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
1878 tet_infoline("Set underline settings with a string");
1879 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1880 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1883 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
1885 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
1886 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
1887 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
1888 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1890 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
1895 int utcDaliTextEditorShadowPropertyStringP(void)
1897 ToolkitTestApplication application;
1898 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
1900 TextEditor editor = TextEditor::New();
1902 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
1904 Stage::GetCurrent().Add( editor );
1906 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
1908 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
1912 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );