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/control-devel.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
101 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
103 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
104 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
106 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
107 const float TO_MILLISECONDS = 1000.f;
108 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
109 const float RENDER_FRAME_INTERVAL = 16.66f;
111 const float SCROLL_THRESHOLD = 10.f;
112 const float SCROLL_SPEED = 300.f;
114 const unsigned int DEFAULT_FONT_SIZE = 1152u;
115 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
117 const int KEY_A_CODE = 38;
118 const int KEY_D_CODE = 40;
119 const int KEY_WHITE_SPACE_CODE = 65;
121 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
123 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
125 static bool gTextChangedCallBackCalled;
126 static bool gInputStyleChangedCallbackCalled;
127 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
129 struct CallbackFunctor
131 CallbackFunctor(bool* callbackFlag)
132 : mCallbackFlag( callbackFlag )
138 *mCallbackFlag = true;
143 static void TestTextChangedCallback( TextEditor control )
145 tet_infoline(" TestTextChangedCallback");
147 gTextChangedCallBackCalled = true;
150 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
152 tet_infoline(" TestInputStyleChangedCallback");
154 gInputStyleChangedCallbackCalled = true;
155 gInputStyleMask = mask;
158 // Generate a TapGestureEvent to send to Core.
159 Integration::TapGestureEvent GenerateTap(
160 Gesture::State state,
161 unsigned int numberOfTaps,
162 unsigned int numberOfTouches,
165 Integration::TapGestureEvent tap( state );
167 tap.numberOfTaps = numberOfTaps;
168 tap.numberOfTouches = numberOfTouches;
174 // Generate a PanGestureEvent to send to Core
175 Integration::PanGestureEvent GeneratePan( Gesture::State state,
176 const Vector2& previousPosition,
177 const Vector2& currentPosition,
178 unsigned long timeDelta,
179 unsigned int numberOfTouches = 1u )
181 Integration::PanGestureEvent pan(state);
183 pan.previousPosition = previousPosition;
184 pan.currentPosition = currentPosition;
185 pan.timeDelta = timeDelta;
186 pan.numberOfTouches = numberOfTouches;
191 // Generate a KeyEvent to send to Core.
192 Integration::KeyEvent GenerateKey( const std::string& keyName,
193 const std::string& keyString,
196 unsigned long timeStamp,
197 const Integration::KeyEvent::State& keyState,
198 const std::string& deviceName,
199 const DevelKeyEvent::DeviceClass::Type& deviceClass )
201 return Integration::KeyEvent( keyName,
212 * Helper to generate PanGestureEvent
214 * @param[in] application Application instance
215 * @param[in] state The Gesture State
216 * @param[in] pos The current position of touch.
218 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
222 if( (state == Gesture::Started) ||
223 (state == Gesture::Possible) )
229 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
236 * Simulate time passed by.
238 * @note this will always process at least 1 frame (1/60 sec)
240 * @param application Test application instance
241 * @param duration Time to pass in milliseconds.
242 * @return The actual time passed in milliseconds
244 static int Wait(ToolkitTestApplication& application, int duration = 0)
248 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
250 application.SendNotification();
251 application.Render(RENDER_FRAME_INTERVAL);
252 time += RENDER_FRAME_INTERVAL;
258 Dali::Integration::Point GetPointDownInside( Vector2& pos )
260 Dali::Integration::Point point;
261 point.SetState( PointState::DOWN );
262 point.SetScreenPosition( pos );
266 Dali::Integration::Point GetPointUpInside( Vector2& pos )
268 Dali::Integration::Point point;
269 point.SetState( PointState::UP );
270 point.SetScreenPosition( pos );
274 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
276 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
278 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
280 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
282 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
283 if( NULL != valueSet )
285 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
287 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
293 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
304 int UtcDaliToolkitTextEditorConstructorP(void)
306 ToolkitTestApplication application;
307 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
308 TextEditor textEditor;
309 DALI_TEST_CHECK( !textEditor );
313 int UtcDaliToolkitTextEditorNewP(void)
315 ToolkitTestApplication application;
316 tet_infoline(" UtcDaliToolkitTextEditorNewP");
317 TextEditor textEditor = TextEditor::New();
318 DALI_TEST_CHECK( textEditor );
322 int UtcDaliToolkitTextEditorDownCastP(void)
324 ToolkitTestApplication application;
325 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
326 TextEditor textEditor1 = TextEditor::New();
327 BaseHandle object( textEditor1 );
329 TextEditor textEditor2 = TextEditor::DownCast( object );
330 DALI_TEST_CHECK( textEditor2 );
332 TextEditor textEditor3 = DownCast< TextEditor >( object );
333 DALI_TEST_CHECK( textEditor3 );
337 int UtcDaliToolkitTextEditorDownCastN(void)
339 ToolkitTestApplication application;
340 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
341 BaseHandle uninitializedObject;
342 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
343 DALI_TEST_CHECK( !textEditor1 );
345 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
346 DALI_TEST_CHECK( !textEditor2 );
350 int UtcDaliToolkitTextEditorCopyConstructorP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
354 TextEditor textEditor = TextEditor::New();
355 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
357 TextEditor copy( textEditor );
358 DALI_TEST_CHECK( copy );
359 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
363 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
365 ToolkitTestApplication application;
366 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
367 TextEditor textEditor = TextEditor::New();
368 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
370 TextEditor copy = textEditor;
371 DALI_TEST_CHECK( copy );
372 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
376 int UtcDaliTextEditorNewP(void)
378 ToolkitTestApplication application;
379 tet_infoline(" UtcDaliToolkitTextEditorNewP");
380 TextEditor textEditor = TextEditor::New();
381 DALI_TEST_CHECK( textEditor );
385 // Positive test case for a method
386 int UtcDaliTextEditorGetPropertyP(void)
388 ToolkitTestApplication application;
389 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
390 TextEditor editor = TextEditor::New();
391 DALI_TEST_CHECK( editor );
393 // Check Property Indices are correct
394 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
395 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
396 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
397 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
398 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
399 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
400 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
401 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
402 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
403 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
404 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
405 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
406 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
407 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
408 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
409 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
410 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
411 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
412 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
413 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
414 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
415 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
416 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
417 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
418 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
419 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
420 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
421 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
422 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
423 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
425 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
426 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
427 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
428 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
429 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
430 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
431 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
432 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
433 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
434 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
435 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == DevelTextEditor::Property::SMOOTH_SCROLL );
436 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == DevelTextEditor::Property::SMOOTH_SCROLL_DURATION );
437 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == DevelTextEditor::Property::ENABLE_SCROLL_BAR );
438 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION );
439 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION );
440 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == DevelTextEditor::Property::PIXEL_SIZE );
441 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == DevelTextEditor::Property::LINE_COUNT );
442 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
443 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
448 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
451 Property::Map imageMap;
452 imageMap[mapKey] =mapValue;
454 editor.SetProperty( property , imageMap );
455 Property::Value propValue = editor.GetProperty( property );
456 Property::Map* resultMap = propValue.GetMap();
458 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
466 // Positive test case for a method
467 int UtcDaliTextEditorSetPropertyP(void)
469 ToolkitTestApplication application;
470 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
471 TextEditor editor = TextEditor::New();
472 DALI_TEST_CHECK( editor );
473 Stage::GetCurrent().Add( editor );
475 // Note - we can't check the defaults since the stylesheets are platform-specific
477 // Check the render backend property.
478 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
479 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
481 // Check text property.
482 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
483 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
485 // Check text's color property
486 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
487 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
489 // Check font properties.
490 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
491 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
493 Property::Map fontStyleMapSet;
494 Property::Map fontStyleMapGet;
495 Property::Value* slantValue = NULL;
497 fontStyleMapSet.Insert( "weight", "bold" );
498 fontStyleMapSet.Insert( "width", "condensed" );
499 fontStyleMapSet.Insert( "slant", "italic" );
501 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
502 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
503 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
504 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
506 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
507 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
510 fontStyleMapSet.Clear();
511 fontStyleMapSet.Insert( "weight", "normal" );
512 fontStyleMapSet.Insert( "slant", "oblique" );
513 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
514 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
515 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
516 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
518 fontStyleMapSet.Clear();
519 fontStyleMapSet.Insert( "slant", "roman" );
520 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
521 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
523 // Replace 'roman' for 'normal'.
524 slantValue = fontStyleMapGet.Find( "slant" );
525 if( NULL != slantValue )
527 if( "normal" == slantValue->Get<std::string>() )
529 fontStyleMapGet["slant"] = "roman";
532 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
533 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
535 fontStyleMapSet.Clear();
537 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
538 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
539 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
540 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
542 // Check that the Alignment properties can be correctly set
543 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
544 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
546 // Check scroll properties.
547 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
548 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
549 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
550 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
552 // Check cursor properties
553 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
554 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
555 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
556 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
558 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
559 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
560 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
561 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
562 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
563 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
564 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
565 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
567 // Check handle images
568 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
569 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
570 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
571 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
572 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
574 // Check handle images
575 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
576 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
577 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
578 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
579 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
580 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
582 // Check the highlight color
583 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
584 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
586 // Decoration bounding box
587 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
588 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
590 // Check the enable markup property.
591 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
592 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
593 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
595 // Check input color property.
596 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
597 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
599 // Check input font properties.
600 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
601 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
603 fontStyleMapSet.Clear();
604 fontStyleMapSet.Insert( "weight", "bold" );
605 fontStyleMapSet.Insert( "width", "condensed" );
606 fontStyleMapSet.Insert( "slant", "italic" );
608 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
609 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
610 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
611 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
613 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
614 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
616 // Reset input font style.
617 fontStyleMapSet.Clear();
618 fontStyleMapSet.Insert( "weight", "normal" );
619 fontStyleMapSet.Insert( "slant", "oblique" );
621 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
622 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
623 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
624 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
626 fontStyleMapSet.Clear();
627 fontStyleMapSet.Insert( "slant", "roman" );
629 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
630 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
632 // Replace 'roman' for 'normal'.
633 slantValue = fontStyleMapGet.Find( "slant" );
634 if( NULL != slantValue )
636 if( "normal" == slantValue->Get<std::string>() )
638 fontStyleMapGet["slant"] = "roman";
641 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
642 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
644 fontStyleMapSet.Clear();
646 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
647 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
648 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
649 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
651 // Check the line spacing property
652 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
654 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
656 // Check the input line spacing property
657 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
658 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
659 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 // Check the underline property
663 Property::Map underlineMapSet;
664 Property::Map underlineMapGet;
666 underlineMapSet.Insert( "enable", "true" );
667 underlineMapSet.Insert( "color", "red" );
668 underlineMapSet.Insert( "height", "1" );
670 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
672 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
673 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
674 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
676 // Check the input underline property
677 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
678 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
680 // Check the shadow property
681 Property::Map shadowMapSet;
682 Property::Map shadowMapGet;
684 shadowMapSet.Insert( "color", "green" );
685 shadowMapSet.Insert( "offset", "2 2" );
687 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
689 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
690 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
691 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
693 // Check the input shadow property
694 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
695 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
697 // Check the emboss property
698 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
699 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
701 // Check the input emboss property
702 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
703 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
705 // Check the outline property
706 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
707 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
709 // Check the input outline property
710 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
711 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
713 // Check the smooth scroll property
714 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
715 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
716 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
718 // Check the smooth scroll duration property
719 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
720 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
722 // Check the scroll bar property
723 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
724 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
725 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
727 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
728 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
729 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
730 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
732 // Check the pixel size of font
733 editor.SetProperty( DevelTextEditor::Property::PIXEL_SIZE, 20.f );
734 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736 // Check placeholder text properties.
737 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
738 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
740 // Check placeholder text properties when focused.
741 editor.SetProperty( DevelControl::Property::STATE, "FOCUSED" );
742 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Focused Placeholder Text" );
743 DALI_TEST_EQUALS( editor.GetProperty<int>( DevelControl::Property::STATE ), (int)DevelControl::FOCUSED, TEST_LOCATION );
744 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Focused Placeholder Text"), TEST_LOCATION );
746 // Check placeholder text's color property.
747 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
748 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
753 // Positive Atlas Text Renderer test
754 int utcDaliTextEditorAtlasRenderP(void)
756 ToolkitTestApplication application;
757 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
758 StyleManager styleManager = StyleManager::Get();
759 styleManager.ApplyDefaultTheme();
760 TextEditor editor = TextEditor::New();
761 DALI_TEST_CHECK( editor );
763 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
765 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
767 Stage::GetCurrent().Add( editor );
771 // Render some text with the shared atlas backend
772 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
773 application.SendNotification();
774 application.Render();
778 tet_result(TET_FAIL);
783 // Positive test for the textChanged signal.
784 int utcDaliTextEditorTextChangedP(void)
786 ToolkitTestApplication application;
787 tet_infoline(" utcDaliTextEditorTextChangedP");
788 TextEditor editor = TextEditor::New();
789 DALI_TEST_CHECK( editor );
791 Stage::GetCurrent().Add( editor );
793 // connect to the text changed signal.
794 ConnectionTracker* testTracker = new ConnectionTracker();
795 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
796 bool textChangedSignal = false;
797 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
799 gTextChangedCallBackCalled = false;
800 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
801 DALI_TEST_CHECK( gTextChangedCallBackCalled );
802 DALI_TEST_CHECK( textChangedSignal );
804 application.SendNotification();
806 editor.SetKeyInputFocus();
808 gTextChangedCallBackCalled = false;
809 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
810 DALI_TEST_CHECK( gTextChangedCallBackCalled );
815 int utcDaliTextEditorInputStyleChanged01(void)
817 ToolkitTestApplication application;
818 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
820 // The text-editor emits signals when the input style changes. These changes of style are
821 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
822 // can't be emitted during the size negotiation as the callbacks may update the UI.
823 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
824 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
825 application.CreateAdaptor();
829 char* pathNamePtr = get_current_dir_name();
830 const std::string pathName( pathNamePtr );
833 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
834 fontClient.SetDpi( 93u, 93u );
836 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
837 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
839 TextEditor editor = TextEditor::New();
840 DALI_TEST_CHECK( editor );
843 editor.SetSize( 300.f, 50.f );
844 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
845 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
847 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
848 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
850 // connect to the text changed signal.
851 ConnectionTracker* testTracker = new ConnectionTracker();
852 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
853 bool inputStyleChangedSignal = false;
854 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
856 Stage::GetCurrent().Add( editor );
859 application.SendNotification();
860 application.Render();
862 // Executes the idle callbacks added by the text control on the change of input style.
863 application.RunIdles();
865 gInputStyleChangedCallbackCalled = false;
866 gInputStyleMask = TextEditor::InputStyle::NONE;
867 inputStyleChangedSignal = false;
869 // Create a tap event to touch the text editor.
870 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
871 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
874 application.SendNotification();
875 application.Render();
877 // Executes the idle callbacks added by the text control on the change of input style.
878 application.RunIdles();
880 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
881 if( gInputStyleChangedCallbackCalled )
883 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
885 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
886 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
888 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
889 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
891 DALI_TEST_CHECK( inputStyleChangedSignal );
893 gInputStyleChangedCallbackCalled = false;
894 gInputStyleMask = TextEditor::InputStyle::NONE;
895 inputStyleChangedSignal = false;
897 // Create a tap event to touch the text editor.
898 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
899 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
902 application.SendNotification();
903 application.Render();
905 // Executes the idle callbacks added by the text control on the change of input style.
906 application.RunIdles();
908 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
909 DALI_TEST_CHECK( !inputStyleChangedSignal );
911 gInputStyleChangedCallbackCalled = false;
912 gInputStyleMask = TextEditor::InputStyle::NONE;
913 inputStyleChangedSignal = false;
915 // Create a tap event to touch the text editor.
916 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
917 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
920 application.SendNotification();
921 application.Render();
923 // Executes the idle callbacks added by the text control on the change of input style.
924 application.RunIdles();
926 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
927 if( gInputStyleChangedCallbackCalled )
929 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
931 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
932 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
934 DALI_TEST_CHECK( inputStyleChangedSignal );
936 gInputStyleChangedCallbackCalled = false;
937 gInputStyleMask = TextEditor::InputStyle::NONE;
938 inputStyleChangedSignal = false;
940 // Create a tap event to touch the text editor.
941 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
942 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
945 application.SendNotification();
946 application.Render();
948 // Executes the idle callbacks added by the text control on the change of input style.
949 application.RunIdles();
951 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
952 if( gInputStyleChangedCallbackCalled )
954 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
956 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
957 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
959 Property::Map fontStyleMapSet;
960 Property::Map fontStyleMapGet;
962 fontStyleMapSet.Insert( "weight", "bold" );
964 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
965 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
966 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
968 DALI_TEST_CHECK( inputStyleChangedSignal );
970 gInputStyleChangedCallbackCalled = false;
971 gInputStyleMask = TextEditor::InputStyle::NONE;
972 inputStyleChangedSignal = false;
974 // Create a tap event to touch the text editor.
975 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
976 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
979 application.SendNotification();
980 application.Render();
982 // Executes the idle callbacks added by the text control on the change of input style.
983 application.RunIdles();
985 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
986 DALI_TEST_CHECK( !inputStyleChangedSignal );
988 gInputStyleChangedCallbackCalled = false;
989 gInputStyleMask = TextEditor::InputStyle::NONE;
990 inputStyleChangedSignal = false;
992 // Create a tap event to touch the text editor.
993 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
994 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
997 application.SendNotification();
998 application.Render();
1000 // Executes the idle callbacks added by the text control on the change of input style.
1001 application.RunIdles();
1003 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1004 if( gInputStyleChangedCallbackCalled )
1006 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1008 Property::Map fontStyleMapSet;
1009 Property::Map fontStyleMapGet;
1011 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1012 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1013 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1015 DALI_TEST_CHECK( inputStyleChangedSignal );
1017 gInputStyleChangedCallbackCalled = false;
1018 gInputStyleMask = TextEditor::InputStyle::NONE;
1019 inputStyleChangedSignal = false;
1021 // Create a tap event to touch the text editor.
1022 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1023 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1025 // Render and notify
1026 application.SendNotification();
1027 application.Render();
1029 // Executes the idle callbacks added by the text control on the change of input style.
1030 application.RunIdles();
1032 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1033 DALI_TEST_CHECK( !inputStyleChangedSignal );
1038 int utcDaliTextEditorInputStyleChanged02(void)
1040 ToolkitTestApplication application;
1041 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1043 // The text-editor emits signals when the input style changes. These changes of style are
1044 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1045 // can't be emitted during the size negotiation as the callbacks may update the UI.
1046 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1047 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1048 application.CreateAdaptor();
1052 char* pathNamePtr = get_current_dir_name();
1053 const std::string pathName( pathNamePtr );
1054 free( pathNamePtr );
1056 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1057 fontClient.SetDpi( 93u, 93u );
1059 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1060 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1062 TextEditor editor = TextEditor::New();
1063 DALI_TEST_CHECK( editor );
1066 editor.SetSize( 300.f, 50.f );
1067 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1068 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1070 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1071 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>" );
1073 // connect to the text changed signal.
1074 ConnectionTracker* testTracker = new ConnectionTracker();
1075 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1076 bool inputStyleChangedSignal = false;
1077 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1079 Stage::GetCurrent().Add( editor );
1081 // Render and notify
1082 application.SendNotification();
1083 application.Render();
1085 // Executes the idle callbacks added by the text control on the change of input style.
1086 application.RunIdles();
1088 gInputStyleChangedCallbackCalled = false;
1089 gInputStyleMask = TextEditor::InputStyle::NONE;
1090 inputStyleChangedSignal = false;
1092 // Create a tap event to touch the text editor.
1093 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1094 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1095 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1096 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1098 // Render and notify
1099 application.SendNotification();
1100 application.Render();
1102 // Executes the idle callbacks added by the text control on the change of input style.
1103 application.RunIdles();
1105 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1106 if( gInputStyleChangedCallbackCalled )
1108 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1109 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1110 TextEditor::InputStyle::POINT_SIZE |
1111 TextEditor::InputStyle::COLOR ),
1114 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1115 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1117 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1118 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1120 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1121 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1123 DALI_TEST_CHECK( inputStyleChangedSignal );
1125 gInputStyleChangedCallbackCalled = false;
1126 gInputStyleMask = TextEditor::InputStyle::NONE;
1127 inputStyleChangedSignal = false;
1129 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1131 // Render and notify
1132 application.SendNotification();
1133 application.Render();
1135 // Executes the idle callbacks added by the text control on the change of input style.
1136 application.RunIdles();
1138 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1139 if( gInputStyleChangedCallbackCalled )
1141 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1142 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1145 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1146 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1148 DALI_TEST_CHECK( inputStyleChangedSignal );
1150 gInputStyleChangedCallbackCalled = false;
1151 gInputStyleMask = TextEditor::InputStyle::NONE;
1152 inputStyleChangedSignal = false;
1154 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1156 // Render and notify
1157 application.SendNotification();
1158 application.Render();
1160 // Executes the idle callbacks added by the text control on the change of input style.
1161 application.RunIdles();
1163 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1164 DALI_TEST_CHECK( !inputStyleChangedSignal );
1166 gInputStyleChangedCallbackCalled = false;
1167 gInputStyleMask = TextEditor::InputStyle::NONE;
1168 inputStyleChangedSignal = false;
1170 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1172 // Render and notify
1173 application.SendNotification();
1174 application.Render();
1176 // Executes the idle callbacks added by the text control on the change of input style.
1177 application.RunIdles();
1179 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1180 if( gInputStyleChangedCallbackCalled )
1182 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1183 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1186 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1187 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1189 DALI_TEST_CHECK( inputStyleChangedSignal );
1191 gInputStyleChangedCallbackCalled = false;
1192 gInputStyleMask = TextEditor::InputStyle::NONE;
1193 inputStyleChangedSignal = false;
1195 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1197 Property::Map fontStyleMapSet;
1198 fontStyleMapSet.Insert( "weight", "thin" );
1199 fontStyleMapSet.Insert( "width", "condensed" );
1200 fontStyleMapSet.Insert( "slant", "italic" );
1202 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1203 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1204 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1206 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1207 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1208 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1209 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1211 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1213 // Render and notify
1214 application.SendNotification();
1215 application.Render();
1217 // Executes the idle callbacks added by the text control on the change of input style.
1218 application.RunIdles();
1220 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1221 DALI_TEST_CHECK( !inputStyleChangedSignal );
1223 // Create a tap event to touch the text editor.
1224 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1225 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Executes the idle callbacks added by the text control on the change of input style.
1232 application.RunIdles();
1234 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1235 if( gInputStyleChangedCallbackCalled )
1237 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1238 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1239 TextEditor::InputStyle::POINT_SIZE |
1240 TextEditor::InputStyle::FONT_STYLE |
1241 TextEditor::InputStyle::LINE_SPACING |
1242 TextEditor::InputStyle::UNDERLINE |
1243 TextEditor::InputStyle::SHADOW |
1244 TextEditor::InputStyle::EMBOSS |
1245 TextEditor::InputStyle::OUTLINE ),
1248 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1249 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1251 DALI_TEST_CHECK( inputStyleChangedSignal );
1253 gInputStyleChangedCallbackCalled = false;
1254 gInputStyleMask = TextEditor::InputStyle::NONE;
1255 inputStyleChangedSignal = false;
1257 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1259 fontStyleMapSet.Clear();
1260 fontStyleMapSet.Insert( "weight", "black" );
1261 fontStyleMapSet.Insert( "width", "expanded" );
1262 fontStyleMapSet.Insert( "slant", "oblique" );
1264 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1266 // Create a tap event to touch the text editor.
1267 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1268 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1270 // Render and notify
1271 application.SendNotification();
1272 application.Render();
1274 // Executes the idle callbacks added by the text control on the change of input style.
1275 application.RunIdles();
1277 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1278 if( gInputStyleChangedCallbackCalled )
1280 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1281 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1282 TextEditor::InputStyle::POINT_SIZE |
1283 TextEditor::InputStyle::FONT_STYLE ),
1286 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1287 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1289 DALI_TEST_CHECK( inputStyleChangedSignal );
1294 int utcDaliTextEditorEvent01(void)
1296 ToolkitTestApplication application;
1297 tet_infoline(" utcDaliTextEditorEvent01");
1299 // Creates a tap event. After creating a tap event the text editor should
1300 // have the focus and add text with key events should be possible.
1302 TextEditor editor = TextEditor::New();
1303 DALI_TEST_CHECK( editor );
1305 Stage::GetCurrent().Add( editor );
1307 editor.SetSize( 300.f, 50.f );
1308 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1309 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1311 // Avoid a crash when core load gl resources.
1312 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1314 // Render and notify
1315 application.SendNotification();
1316 application.Render();
1318 // Add a key event but as the text editor has not the focus it should do nothing.
1319 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1321 // Render and notify
1322 application.SendNotification();
1323 application.Render();
1325 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1327 // Create a tap event to touch the text editor.
1328 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1329 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1331 // Render and notify
1332 application.SendNotification();
1333 application.Render();
1335 // Now the text editor has the focus, so it can handle the key events.
1336 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1337 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1339 // Render and notify
1340 application.SendNotification();
1341 application.Render();
1343 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1345 // Create a second text editor and send key events to it.
1346 TextEditor editor2 = TextEditor::New();
1348 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1349 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1350 editor2.SetSize( 100.f, 100.f );
1351 editor2.SetPosition( 100.f, 100.f );
1353 Stage::GetCurrent().Add( editor2 );
1355 // Render and notify
1356 application.SendNotification();
1357 application.Render();
1359 // Create a tap event on the second text editor.
1360 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1361 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1363 // Render and notify
1364 application.SendNotification();
1365 application.Render();
1367 // The second text editor has the focus. It should handle the key events.
1368 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1369 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1371 // Render and notify
1372 application.SendNotification();
1373 application.Render();
1375 // Check the text has been added to the second text editor.
1376 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1381 int utcDaliTextEditorEvent02(void)
1383 ToolkitTestApplication application;
1384 tet_infoline(" utcDaliTextEditorEvent02");
1386 // Checks if the right number of actors are created.
1388 TextEditor editor = TextEditor::New();
1389 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1390 DALI_TEST_CHECK( editor );
1392 Stage::GetCurrent().Add( editor );
1394 editor.SetSize( 300.f, 50.f );
1395 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1396 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1398 // Avoid a crash when core load gl resources.
1399 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1401 // Render and notify
1402 application.SendNotification();
1403 application.Render();
1405 // Check there are the expected number of children (the stencil).
1406 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1408 Actor stencil = editor.GetChildAt( 0u );
1410 // Create a tap event to touch the text editor.
1411 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1412 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1414 // Render and notify
1415 application.SendNotification();
1416 application.Render();
1418 Actor layer = editor.GetChildAt( 1u );
1419 DALI_TEST_CHECK( layer.IsLayer() );
1421 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1422 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1424 // Now the text editor has the focus, so it can handle the key events.
1425 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1426 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1428 // Render and notify
1429 application.SendNotification();
1430 application.Render();
1432 // Checks the cursor and the renderer have been created.
1433 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1434 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1436 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1437 DALI_TEST_CHECK( cursor );
1439 // The stencil actor has a container with all the actors which contain the text renderers.
1440 Actor container = stencil.GetChildAt( 0u );
1441 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1443 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1444 DALI_TEST_CHECK( renderer );
1447 // Move the cursor and check the position changes.
1448 Vector3 position1 = cursor.GetCurrentPosition();
1450 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1451 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1453 // Render and notify
1454 application.SendNotification();
1455 application.Render();
1457 Vector3 position2 = cursor.GetCurrentPosition();
1459 DALI_TEST_CHECK( position2.x < position1.x );
1461 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1462 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1464 // Render and notify
1465 application.SendNotification();
1466 application.Render();
1468 Vector3 position3 = cursor.GetCurrentPosition();
1470 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1472 // Send some taps and check the cursor positions.
1474 // Try to tap at the beginning.
1475 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1476 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1478 // Render and notify
1479 application.SendNotification();
1480 application.Render();
1482 // Cursor position should be the same than position1.
1483 Vector3 position4 = cursor.GetCurrentPosition();
1485 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1487 // Tap away from the start position.
1488 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1489 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1491 // Render and notify
1492 application.SendNotification();
1493 application.Render();
1495 Vector3 position5 = cursor.GetCurrentPosition();
1497 DALI_TEST_CHECK( position5.x > position4.x );
1499 // Remove all the text.
1500 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1501 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1502 editor.SetProperty( TextEditor::Property::TEXT, "" );
1504 // Render and notify
1505 application.SendNotification();
1506 application.Render();
1508 // Cursor position should be the same than position2.
1509 Vector3 position6 = cursor.GetCurrentPosition();
1511 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1513 // Should not be a renderer.
1514 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1519 int utcDaliTextEditorEvent03(void)
1521 ToolkitTestApplication application;
1522 tet_infoline(" utcDaliTextEditorEvent03");
1524 // Checks if the highlight actor is created.
1526 TextEditor editor = TextEditor::New();
1527 DALI_TEST_CHECK( editor );
1529 Stage::GetCurrent().Add( editor );
1531 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1532 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1533 editor.SetSize( 30.f, 50.f );
1534 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1535 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1537 // Avoid a crash when core load gl resources.
1538 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1540 // Render and notify
1541 application.SendNotification();
1542 application.Render();
1544 // Send some taps and check text controller with clipboard window
1545 Dali::Clipboard clipboard = Clipboard::Get();
1546 clipboard.ShowClipboard();
1547 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1548 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1549 clipboard.HideClipboard();
1551 // Render and notify
1552 application.SendNotification();
1553 application.Render();
1555 // Tap first to get the focus.
1556 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1557 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1559 // Render and notify
1560 application.SendNotification();
1561 application.Render();
1563 // Double tap to select a word.
1564 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1565 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1567 // Render and notify
1568 application.SendNotification();
1569 application.Render();
1571 // The stencil actor should have two actors: the renderer and the highlight actor.
1572 Actor stencil = editor.GetChildAt( 0u );
1574 // The stencil actor has a container with all the actors which contain the text renderers.
1575 Actor 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 );
1582 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1583 DALI_TEST_CHECK( highlight );
1585 // Double tap out of bounds
1586 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1587 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1589 // Render and notify
1590 application.SendNotification();
1591 application.Render();
1593 // The stencil actor should have one actors: the renderer actor.
1594 stencil = editor.GetChildAt( 0u );
1596 // The stencil actor has a container with all the actors which contain the text renderers.
1597 container = stencil.GetChildAt( 0u );
1598 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1600 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1601 DALI_TEST_CHECK( renderer );
1607 int utcDaliTextEditorEvent04(void)
1609 ToolkitTestApplication application;
1610 tet_infoline(" utcDaliTextEditorEvent04");
1612 // Checks if the highlight actor is created.
1614 TextEditor editor = TextEditor::New();
1615 DALI_TEST_CHECK( editor );
1617 Stage::GetCurrent().Add( editor );
1619 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1620 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1621 editor.SetSize( 100.f, 50.f );
1622 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1623 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1625 // Avoid a crash when core load gl resources.
1626 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1628 // Render and notify
1629 application.SendNotification();
1630 application.Render();
1632 // Tap on the text editor
1633 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1634 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Move at the end of the text.
1641 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1642 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1644 // Render and notify
1645 application.SendNotification();
1646 application.Render();
1648 for( unsigned int index = 0u; index < 10u; ++index )
1650 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1651 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1653 // Render and notify
1654 application.SendNotification();
1655 application.Render();
1659 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1667 // Add some key events
1668 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1669 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1671 // Render and notify
1672 application.SendNotification();
1673 application.Render();
1675 for( unsigned int index = 0u; index < 10u; ++index )
1677 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1678 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1680 // Render and notify
1681 application.SendNotification();
1682 application.Render();
1686 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1688 // Render and notify
1689 application.SendNotification();
1690 application.Render();
1692 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1697 int utcDaliTextEditorEvent05(void)
1699 ToolkitTestApplication application;
1700 tet_infoline(" utcDaliTextEditorEvent05");
1702 // Checks if the highlight actor is created.
1704 TextEditor editor = TextEditor::New();
1705 DALI_TEST_CHECK( editor );
1707 Stage::GetCurrent().Add( editor );
1709 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1710 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1711 editor.SetSize( 50.f, 50.f );
1712 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1713 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1714 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1715 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1716 editor.SetProperty( DevelTextEditor::Property::ENABLE_SCROLL_BAR, true );
1717 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1718 editor.SetProperty( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1720 // Avoid a crash when core load gl resources.
1721 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1723 // Render and notify
1724 application.SendNotification();
1725 application.Render();
1727 // Tap on the text editor
1728 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1729 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1731 // Render and notify
1732 application.SendNotification();
1733 application.Render();
1735 // Move at the end of the text.
1736 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1737 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1739 // Render and notify
1740 application.SendNotification();
1741 application.Render();
1743 for( unsigned int index = 0u; index < 10u; ++index )
1746 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 // Modify duration after scroll is enabled
1753 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1755 // Continuous scroll left to increase coverage
1756 for( unsigned int index = 0u; index < 10u; ++index )
1758 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1760 // Render and notify
1761 application.SendNotification();
1762 application.Render();
1764 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1765 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1766 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1767 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1768 DALI_TEST_EQUALS( editor.GetProperty<float>( DevelTextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1770 // Press Escape to increase coverage
1771 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, DevelKeyEvent::DeviceClass::NONE ) );
1772 application.SendNotification();
1773 application.Render();
1775 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1780 int utcDaliTextEditorHandles(void)
1782 ToolkitTestApplication application;
1783 tet_infoline(" utcDaliTextEditorHandles");
1785 TextEditor editor = TextEditor::New();
1786 DALI_TEST_CHECK( editor );
1788 Stage::GetCurrent().Add( editor );
1790 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1791 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1792 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
1793 editor.SetProperty( DevelTextEditor::Property::SMOOTH_SCROLL, true );
1795 editor.SetSize( 30.f, 500.f );
1796 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1797 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1799 // Avoid a crash when core load gl resources.
1800 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1802 // Render and notify
1803 application.SendNotification();
1804 application.Render();
1806 // Tap first to get the focus.
1807 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1808 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1810 // Render and notify
1811 application.SendNotification();
1812 application.Render();
1814 // Tap to create the grab handle.
1815 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1816 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1818 // Render and notify
1819 application.SendNotification();
1820 application.Render();
1822 // Get the active layer where the text's decoration is added.
1823 Actor activeLayer = editor.GetChildAt( 1u );
1825 // Get the handle's actor.
1826 Actor handle = activeLayer.GetChildAt( 1u );
1827 handle.SetSize( 100.f, 100.f );
1829 // Render and notify
1830 application.SendNotification();
1831 application.Render();
1833 // Touch the grab handle to set it as pressed.
1834 Vector2 touchPos( 10.0f, 50.0f );
1835 Dali::Integration::TouchEvent event;
1836 event = Dali::Integration::TouchEvent();
1837 event.AddPoint( GetPointDownInside( touchPos ) );
1838 application.ProcessEvent( event );
1840 // Render and notify
1841 application.SendNotification();
1842 application.Render();
1844 // drag grab handle right
1845 SendPan(application, Gesture::Possible, touchPos);
1846 SendPan(application, Gesture::Started, touchPos);
1848 Wait(application, 100);
1850 for(int i = 0;i<20;i++)
1852 SendPan(application, Gesture::Continuing, touchPos);
1857 SendPan(application, Gesture::Finished, touchPos);
1860 // Release the grab handle.
1861 event = Dali::Integration::TouchEvent();
1862 event.AddPoint( GetPointUpInside( touchPos ) );
1863 application.ProcessEvent( event );
1865 // Render and notify
1866 application.SendNotification();
1867 application.Render();
1873 int utcDaliTextEditorUnderPropertyStringP(void)
1875 ToolkitTestApplication application;
1876 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
1877 TextEditor editor = TextEditor::New();
1878 DALI_TEST_CHECK( editor );
1880 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
1882 Stage::GetCurrent().Add( editor );
1884 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1885 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
1887 tet_infoline("Set underline settings with a map");
1888 // Check the input underline property
1889 Property::Map underlineMapSet;
1890 Property::Map underlineMapGet;
1891 underlineMapSet.Insert( "enable", "true" );
1892 underlineMapSet.Insert( "color", "blue" );
1893 underlineMapSet.Insert( "height", "2" );
1895 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
1896 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
1897 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
1898 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
1900 tet_infoline("Set underline settings with a string");
1901 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
1902 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1905 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
1907 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
1908 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
1909 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
1910 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
1912 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
1917 int utcDaliTextEditorShadowPropertyStringP(void)
1919 ToolkitTestApplication application;
1920 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
1922 TextEditor editor = TextEditor::New();
1924 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\"}" );
1926 Stage::GetCurrent().Add( editor );
1928 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
1930 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
1934 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
1939 int utcDaliTextEditorFontStylePropertyStringP(void)
1941 ToolkitTestApplication application;
1942 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
1944 TextEditor editor = TextEditor::New();
1946 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
1948 Stage::GetCurrent().Add( editor );
1950 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
1952 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
1956 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
1960 int utcDaliTextEditorGetPropertyLinecountP(void)
1962 ToolkitTestApplication application;
1964 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
1968 TextEditor editor = TextEditor::New();
1969 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
1970 editor.SetProperty( TextEditor::Property::TEXT,
1971 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
1973 Stage::GetCurrent().Add( editor );
1975 editor.SetSize( 100.0f, 100.0f );
1976 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
1977 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
1979 editor.SetSize( 50.0f, 100.0f );
1980 lineCount = editor.GetProperty<int>( DevelTextEditor::Property::LINE_COUNT );
1981 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );