2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali/integration-api/events/long-press-gesture-event.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
104 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION = "matchSystemLanguageDirection";
107 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
109 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
110 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
112 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
113 const float TO_MILLISECONDS = 1000.f;
114 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
115 const float RENDER_FRAME_INTERVAL = 16.66f;
117 const float SCROLL_THRESHOLD = 10.f;
118 const float SCROLL_SPEED = 300.f;
120 const unsigned int DEFAULT_FONT_SIZE = 1152u;
121 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123 const int KEY_A_CODE = 38;
124 const int KEY_D_CODE = 40;
125 const int KEY_C_CODE = 54;
126 const int KEY_V_CODE = 55;
127 const int KEY_X_CODE = 53;
128 const int KEY_WHITE_SPACE_CODE = 65;
130 const int KEY_SHIFT_MODIFIER = 257;
131 const int KEY_CONTROL_MODIFIER = 258;
133 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
135 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
137 static bool gTextChangedCallBackCalled;
138 static bool gInputStyleChangedCallbackCalled;
139 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
141 struct CallbackFunctor
143 CallbackFunctor(bool* callbackFlag)
144 : mCallbackFlag( callbackFlag )
150 *mCallbackFlag = true;
155 static void TestTextChangedCallback( TextEditor control )
157 tet_infoline(" TestTextChangedCallback");
159 gTextChangedCallBackCalled = true;
162 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
164 tet_infoline(" TestInputStyleChangedCallback");
166 gInputStyleChangedCallbackCalled = true;
167 gInputStyleMask = mask;
170 // Generate a TapGestureEvent to send to Core.
171 Integration::TapGestureEvent GenerateTap(
172 Gesture::State state,
173 unsigned int numberOfTaps,
174 unsigned int numberOfTouches,
177 Integration::TapGestureEvent tap( state );
179 tap.numberOfTaps = numberOfTaps;
180 tap.numberOfTouches = numberOfTouches;
186 Integration::LongPressGestureEvent GenerateLongPress(
187 Gesture::State state,
188 unsigned int numberOfTouches,
191 Integration::LongPressGestureEvent longPress( state );
193 longPress.numberOfTouches = numberOfTouches;
194 longPress.point = point;
198 // Generate a PanGestureEvent to send to Core
199 Integration::PanGestureEvent GeneratePan( Gesture::State state,
200 const Vector2& previousPosition,
201 const Vector2& currentPosition,
202 unsigned long timeDelta,
203 unsigned int numberOfTouches = 1u )
205 Integration::PanGestureEvent pan(state);
207 pan.previousPosition = previousPosition;
208 pan.currentPosition = currentPosition;
209 pan.timeDelta = timeDelta;
210 pan.numberOfTouches = numberOfTouches;
215 // Generate a KeyEvent to send to Core.
216 Integration::KeyEvent GenerateKey( const std::string& keyName,
217 const std::string& keyString,
220 unsigned long timeStamp,
221 const Integration::KeyEvent::State& keyState,
222 const std::string& compose = "",
223 const std::string& deviceName = DEFAULT_DEVICE_NAME,
224 const Device::Class::Type& deviceClass = Device::Class::NONE,
225 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
227 return Integration::KeyEvent( keyName,
240 * Helper to generate PanGestureEvent
242 * @param[in] application Application instance
243 * @param[in] state The Gesture State
244 * @param[in] pos The current position of touch.
246 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
250 if( (state == Gesture::Started) ||
251 (state == Gesture::Possible) )
257 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
264 * Simulate time passed by.
266 * @note this will always process at least 1 frame (1/60 sec)
268 * @param application Test application instance
269 * @param duration Time to pass in milliseconds.
270 * @return The actual time passed in milliseconds
272 static int Wait(ToolkitTestApplication& application, int duration = 0)
276 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
278 application.SendNotification();
279 application.Render(RENDER_FRAME_INTERVAL);
280 time += RENDER_FRAME_INTERVAL;
286 Dali::Integration::Point GetPointDownInside( Vector2& pos )
288 Dali::Integration::Point point;
289 point.SetState( PointState::DOWN );
290 point.SetScreenPosition( pos );
294 Dali::Integration::Point GetPointUpInside( Vector2& pos )
296 Dali::Integration::Point point;
297 point.SetState( PointState::UP );
298 point.SetScreenPosition( pos );
302 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
304 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
306 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
308 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
310 Property::Value* valueSet = NULL;
311 if ( valueGet.first.type == Property::Key::INDEX )
313 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
317 // Get Key is a string so searching Set Map for a string key
318 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
321 if( NULL != valueSet )
323 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
325 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
328 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
330 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
333 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
335 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
338 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
340 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
343 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
345 Vector2 vector2Get = valueGet.second.Get<Vector2>();
346 Vector2 vector2Set = valueSet->Get<Vector2>();
347 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
350 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
352 Vector4 vector4Get = valueGet.second.Get<Vector4>();
353 Vector4 vector4Set = valueSet->Get<Vector4>();
354 tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
360 if ( valueGet.first.type == Property::Key::INDEX )
362 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
366 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
376 class ScrollStateChangeCallback : public Dali::ConnectionTracker
379 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
380 : mStartedCalled( startedCalled ),
381 mFinishedCalled( finishedCalled )
385 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
387 if( type == TextEditor::Scroll::STARTED )
389 mStartedCalled = true;
391 else if( type == TextEditor::Scroll::FINISHED )
393 mFinishedCalled = true;
397 bool& mStartedCalled;
398 bool& mFinishedCalled;
403 int UtcDaliToolkitTextEditorConstructorP(void)
405 ToolkitTestApplication application;
406 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
407 TextEditor textEditor;
408 DALI_TEST_CHECK( !textEditor );
412 int UtcDaliToolkitTextEditorNewP(void)
414 ToolkitTestApplication application;
415 tet_infoline(" UtcDaliToolkitTextEditorNewP");
416 TextEditor textEditor = TextEditor::New();
417 DALI_TEST_CHECK( textEditor );
421 int UtcDaliToolkitTextEditorDownCastP(void)
423 ToolkitTestApplication application;
424 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
425 TextEditor textEditor1 = TextEditor::New();
426 BaseHandle object( textEditor1 );
428 TextEditor textEditor2 = TextEditor::DownCast( object );
429 DALI_TEST_CHECK( textEditor2 );
431 TextEditor textEditor3 = DownCast< TextEditor >( object );
432 DALI_TEST_CHECK( textEditor3 );
436 int UtcDaliToolkitTextEditorDownCastN(void)
438 ToolkitTestApplication application;
439 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
440 BaseHandle uninitializedObject;
441 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
442 DALI_TEST_CHECK( !textEditor1 );
444 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
445 DALI_TEST_CHECK( !textEditor2 );
449 int UtcDaliToolkitTextEditorCopyConstructorP(void)
451 ToolkitTestApplication application;
452 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
453 TextEditor textEditor = TextEditor::New();
454 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
456 TextEditor copy( textEditor );
457 DALI_TEST_CHECK( copy );
458 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
462 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
464 ToolkitTestApplication application;
465 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
466 TextEditor textEditor = TextEditor::New();
467 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
469 TextEditor copy = textEditor;
470 DALI_TEST_CHECK( copy );
471 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
475 int UtcDaliTextEditorNewP(void)
477 ToolkitTestApplication application;
478 tet_infoline(" UtcDaliToolkitTextEditorNewP");
479 TextEditor textEditor = TextEditor::New();
480 DALI_TEST_CHECK( textEditor );
484 // Positive test case for a method
485 int UtcDaliTextEditorGetPropertyP(void)
487 ToolkitTestApplication application;
488 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
489 TextEditor editor = TextEditor::New();
490 DALI_TEST_CHECK( editor );
492 // Check Property Indices are correct
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
552 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
555 Property::Map imageMap;
556 imageMap[mapKey] =mapValue;
558 editor.SetProperty( property , imageMap );
559 Property::Value propValue = editor.GetProperty( property );
560 Property::Map* resultMap = propValue.GetMap();
562 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
570 // Positive test case for a method
571 int UtcDaliTextEditorSetPropertyP(void)
573 ToolkitTestApplication application;
574 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
575 TextEditor editor = TextEditor::New();
576 DALI_TEST_CHECK( editor );
577 Stage::GetCurrent().Add( editor );
579 // Note - we can't check the defaults since the stylesheets are platform-specific
581 // Check the render backend property.
582 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
583 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
585 // Check text property.
586 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
587 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
589 // Check text's color property
590 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
591 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
593 // Check font properties.
594 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
595 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
597 Property::Map fontStyleMapSet;
598 Property::Map fontStyleMapGet;
599 Property::Value* slantValue = NULL;
601 fontStyleMapSet.Insert( "weight", "bold" );
602 fontStyleMapSet.Insert( "width", "condensed" );
603 fontStyleMapSet.Insert( "slant", "italic" );
605 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
606 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
607 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
608 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
610 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
611 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
614 fontStyleMapSet.Clear();
615 fontStyleMapSet.Insert( "weight", "normal" );
616 fontStyleMapSet.Insert( "slant", "oblique" );
617 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
618 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
619 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
620 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
622 fontStyleMapSet.Clear();
623 fontStyleMapSet.Insert( "slant", "roman" );
624 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
625 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
627 // Replace 'roman' for 'normal'.
628 slantValue = fontStyleMapGet.Find( "slant" );
629 if( NULL != slantValue )
631 if( "normal" == slantValue->Get<std::string>() )
633 fontStyleMapGet["slant"] = "roman";
636 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
637 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
639 fontStyleMapSet.Clear();
641 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
642 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
643 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
644 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
646 // Check that the Alignment properties can be correctly set
647 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
648 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
650 // Check scroll properties.
651 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
652 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
654 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
656 // Check cursor properties
657 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
658 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
659 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
660 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
662 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
663 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
664 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
665 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
666 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
667 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
669 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
671 // Check handle images
672 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
673 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
674 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
675 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
676 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
678 // Check handle images
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
680 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
682 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
683 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
684 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
686 // Check the highlight color
687 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
688 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
690 // Decoration bounding box
691 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
692 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
694 // Check the enable markup property.
695 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
696 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
697 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
699 // Check input color property.
700 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
701 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
703 // Check input font properties.
704 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
705 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
707 fontStyleMapSet.Clear();
708 fontStyleMapSet.Insert( "weight", "bold" );
709 fontStyleMapSet.Insert( "width", "condensed" );
710 fontStyleMapSet.Insert( "slant", "italic" );
712 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
713 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
714 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
715 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
717 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
718 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
720 // Reset input font style.
721 fontStyleMapSet.Clear();
722 fontStyleMapSet.Insert( "weight", "normal" );
723 fontStyleMapSet.Insert( "slant", "oblique" );
725 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
726 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
727 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
728 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
730 fontStyleMapSet.Clear();
731 fontStyleMapSet.Insert( "slant", "roman" );
733 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
734 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
736 // Replace 'roman' for 'normal'.
737 slantValue = fontStyleMapGet.Find( "slant" );
738 if( NULL != slantValue )
740 if( "normal" == slantValue->Get<std::string>() )
742 fontStyleMapGet["slant"] = "roman";
745 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
746 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
748 fontStyleMapSet.Clear();
750 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
751 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
752 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
753 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
755 // Check the line spacing property
756 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
757 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
758 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
760 // Check the input line spacing property
761 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
762 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
763 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
765 // Check the underline property
767 Property::Map underlineMapSet;
768 Property::Map underlineMapGet;
770 underlineMapSet.Insert( "enable", "true" );
771 underlineMapSet.Insert( "color", "red" );
772 underlineMapSet.Insert( "height", "1" );
774 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
776 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
777 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
778 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
780 // Check the input underline property
781 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
782 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
784 // Check the shadow property
785 Property::Map shadowMapSet;
786 Property::Map shadowMapGet;
788 shadowMapSet.Insert( "color", Color::GREEN );
789 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
790 shadowMapSet.Insert( "blurRadius", 3.0f );
792 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
794 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
795 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
796 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
798 // Check the input shadow property
799 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
800 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
802 // Check the emboss property
803 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
804 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
806 // Check the input emboss property
807 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
808 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
810 // Check the outline property
812 // Test string type first
813 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
814 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
815 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
817 // Then test the property map type
818 Property::Map outlineMapSet;
819 Property::Map outlineMapGet;
821 outlineMapSet["color"] = Color::RED;
822 outlineMapSet["width"] = 2.0f;
824 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
826 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
827 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
828 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
830 // Check the input outline property
831 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
832 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
834 // Check the smooth scroll property
835 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
836 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
837 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
839 // Check the smooth scroll duration property
840 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
841 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
843 // Check the scroll bar property
844 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
845 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
846 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
848 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
849 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
850 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
851 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
853 // Check the pixel size of font
854 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
855 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
857 // Check placeholder text properties.
858 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
859 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
861 // Check placeholder text's color property.
862 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
863 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
865 // Check the enable selection property
866 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
867 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
869 // Check the placeholder property with pixel size
870 Property::Map placeholderPixelSizeMapSet;
871 Property::Map placeholderPixelSizeMapGet;
872 Property::Map placeholderFontstyleMap;
873 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
874 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
875 placeholderPixelSizeMapSet["color"] = Color::BLUE;
876 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
877 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
879 placeholderFontstyleMap.Insert( "weight", "bold" );
880 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
881 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
883 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
884 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
886 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
887 Property::Map placeholderConversionMap;
888 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
889 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
890 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
891 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
892 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
893 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
895 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
897 // Check the placeholder property with point size
898 Property::Map placeholderMapSet;
899 Property::Map placeholderMapGet;
900 placeholderMapSet["text"] = "Setting Placeholder Text";
901 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
902 placeholderMapSet["color"] = Color::RED;
903 placeholderMapSet["fontFamily"] = "Arial";
904 placeholderMapSet["pointSize"] = 12.0f;
905 // Check the placeholder font style property
906 placeholderFontstyleMap.Clear();
908 placeholderFontstyleMap.Insert( "weight", "bold" );
909 placeholderFontstyleMap.Insert( "width", "condensed" );
910 placeholderFontstyleMap.Insert( "slant", "italic" );
911 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
912 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
914 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
915 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
917 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
918 placeholderConversionMap.Clear();
919 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
920 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
921 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
923 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
924 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
925 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
928 placeholderFontstyleMap.Clear();
929 placeholderFontstyleMap.Insert( "weight", "normal" );
930 placeholderFontstyleMap.Insert( "slant", "oblique" );
931 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
932 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
934 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
935 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
936 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
937 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
939 placeholderFontstyleMap.Clear();
940 placeholderFontstyleMap.Insert( "slant", "roman" );
941 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
942 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
944 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
946 placeholderFontstyleMap.Clear();
947 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
949 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
950 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
951 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
952 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
953 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
955 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
956 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
958 application.SendNotification();
959 application.Render();
964 // Positive Atlas Text Renderer test
965 int utcDaliTextEditorAtlasRenderP(void)
967 ToolkitTestApplication application;
968 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
969 StyleManager styleManager = StyleManager::Get();
970 styleManager.ApplyDefaultTheme();
971 TextEditor editor = TextEditor::New();
972 DALI_TEST_CHECK( editor );
974 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
976 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
978 Stage::GetCurrent().Add( editor );
982 // Render some text with the shared atlas backend
983 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
984 application.SendNotification();
985 application.Render();
989 tet_result(TET_FAIL);
994 // Positive test for the textChanged signal.
995 int utcDaliTextEditorTextChangedP(void)
997 ToolkitTestApplication application;
998 tet_infoline(" utcDaliTextEditorTextChangedP");
999 TextEditor editor = TextEditor::New();
1000 DALI_TEST_CHECK( editor );
1002 Stage::GetCurrent().Add( editor );
1004 // connect to the text changed signal.
1005 ConnectionTracker* testTracker = new ConnectionTracker();
1006 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1007 bool textChangedSignal = false;
1008 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1010 gTextChangedCallBackCalled = false;
1011 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1012 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1013 DALI_TEST_CHECK( textChangedSignal );
1015 application.SendNotification();
1017 editor.SetKeyInputFocus();
1019 gTextChangedCallBackCalled = false;
1020 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1021 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1026 int utcDaliTextEditorInputStyleChanged01(void)
1028 ToolkitTestApplication application;
1029 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1031 // The text-editor emits signals when the input style changes. These changes of style are
1032 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1033 // can't be emitted during the size negotiation as the callbacks may update the UI.
1034 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1035 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1036 application.CreateAdaptor();
1040 char* pathNamePtr = get_current_dir_name();
1041 const std::string pathName( pathNamePtr );
1042 free( pathNamePtr );
1044 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1045 fontClient.SetDpi( 93u, 93u );
1047 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1048 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1050 TextEditor editor = TextEditor::New();
1051 DALI_TEST_CHECK( editor );
1054 editor.SetSize( 300.f, 50.f );
1055 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1056 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1058 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1059 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1061 // connect to the text changed signal.
1062 ConnectionTracker* testTracker = new ConnectionTracker();
1063 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1064 bool inputStyleChangedSignal = false;
1065 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1067 Stage::GetCurrent().Add( editor );
1069 // Render and notify
1070 application.SendNotification();
1071 application.Render();
1073 // Executes the idle callbacks added by the text control on the change of input style.
1074 application.RunIdles();
1076 gInputStyleChangedCallbackCalled = false;
1077 gInputStyleMask = TextEditor::InputStyle::NONE;
1078 inputStyleChangedSignal = false;
1080 // Create a tap event to touch the text editor.
1081 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1082 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1084 // Render and notify
1085 application.SendNotification();
1086 application.Render();
1088 // Executes the idle callbacks added by the text control on the change of input style.
1089 application.RunIdles();
1091 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1092 if( gInputStyleChangedCallbackCalled )
1094 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1096 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1097 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1099 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1100 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1102 DALI_TEST_CHECK( inputStyleChangedSignal );
1104 gInputStyleChangedCallbackCalled = false;
1105 gInputStyleMask = TextEditor::InputStyle::NONE;
1106 inputStyleChangedSignal = false;
1108 // Create a tap event to touch the text editor.
1109 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1110 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1112 // Render and notify
1113 application.SendNotification();
1114 application.Render();
1116 // Executes the idle callbacks added by the text control on the change of input style.
1117 application.RunIdles();
1119 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1120 DALI_TEST_CHECK( !inputStyleChangedSignal );
1122 gInputStyleChangedCallbackCalled = false;
1123 gInputStyleMask = TextEditor::InputStyle::NONE;
1124 inputStyleChangedSignal = false;
1126 // Create a tap event to touch the text editor.
1127 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1128 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1130 // Render and notify
1131 application.SendNotification();
1132 application.Render();
1134 // Executes the idle callbacks added by the text control on the change of input style.
1135 application.RunIdles();
1137 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1138 if( gInputStyleChangedCallbackCalled )
1140 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1142 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1143 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1145 DALI_TEST_CHECK( inputStyleChangedSignal );
1147 gInputStyleChangedCallbackCalled = false;
1148 gInputStyleMask = TextEditor::InputStyle::NONE;
1149 inputStyleChangedSignal = false;
1151 // Create a tap event to touch the text editor.
1152 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1153 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1155 // Render and notify
1156 application.SendNotification();
1157 application.Render();
1159 // Executes the idle callbacks added by the text control on the change of input style.
1160 application.RunIdles();
1162 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1163 if( gInputStyleChangedCallbackCalled )
1165 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1167 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1168 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1170 Property::Map fontStyleMapSet;
1171 Property::Map fontStyleMapGet;
1173 fontStyleMapSet.Insert( "weight", "bold" );
1175 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1176 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1177 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1179 DALI_TEST_CHECK( inputStyleChangedSignal );
1181 gInputStyleChangedCallbackCalled = false;
1182 gInputStyleMask = TextEditor::InputStyle::NONE;
1183 inputStyleChangedSignal = false;
1185 // Create a tap event to touch the text editor.
1186 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1187 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1189 // Render and notify
1190 application.SendNotification();
1191 application.Render();
1193 // Executes the idle callbacks added by the text control on the change of input style.
1194 application.RunIdles();
1196 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1197 DALI_TEST_CHECK( !inputStyleChangedSignal );
1199 gInputStyleChangedCallbackCalled = false;
1200 gInputStyleMask = TextEditor::InputStyle::NONE;
1201 inputStyleChangedSignal = false;
1203 // Create a tap event to touch the text editor.
1204 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1205 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1207 // Render and notify
1208 application.SendNotification();
1209 application.Render();
1211 // Executes the idle callbacks added by the text control on the change of input style.
1212 application.RunIdles();
1214 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1215 if( gInputStyleChangedCallbackCalled )
1217 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1219 Property::Map fontStyleMapSet;
1220 Property::Map fontStyleMapGet;
1222 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1223 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1224 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1226 DALI_TEST_CHECK( inputStyleChangedSignal );
1228 gInputStyleChangedCallbackCalled = false;
1229 gInputStyleMask = TextEditor::InputStyle::NONE;
1230 inputStyleChangedSignal = false;
1232 // Create a tap event to touch the text editor.
1233 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1234 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1236 // Render and notify
1237 application.SendNotification();
1238 application.Render();
1240 // Executes the idle callbacks added by the text control on the change of input style.
1241 application.RunIdles();
1243 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1244 DALI_TEST_CHECK( !inputStyleChangedSignal );
1249 int utcDaliTextEditorInputStyleChanged02(void)
1251 ToolkitTestApplication application;
1252 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1254 // The text-editor emits signals when the input style changes. These changes of style are
1255 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1256 // can't be emitted during the size negotiation as the callbacks may update the UI.
1257 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1258 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1259 application.CreateAdaptor();
1263 char* pathNamePtr = get_current_dir_name();
1264 const std::string pathName( pathNamePtr );
1265 free( pathNamePtr );
1267 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1268 fontClient.SetDpi( 93u, 93u );
1270 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1271 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1273 TextEditor editor = TextEditor::New();
1274 DALI_TEST_CHECK( editor );
1277 editor.SetSize( 300.f, 50.f );
1278 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1279 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1281 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1282 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>" );
1284 // connect to the text changed signal.
1285 ConnectionTracker* testTracker = new ConnectionTracker();
1286 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1287 bool inputStyleChangedSignal = false;
1288 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1290 Stage::GetCurrent().Add( editor );
1292 // Render and notify
1293 application.SendNotification();
1294 application.Render();
1296 // Executes the idle callbacks added by the text control on the change of input style.
1297 application.RunIdles();
1299 gInputStyleChangedCallbackCalled = false;
1300 gInputStyleMask = TextEditor::InputStyle::NONE;
1301 inputStyleChangedSignal = false;
1303 // Create a tap event to touch the text editor.
1304 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1305 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1306 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1307 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1309 // Render and notify
1310 application.SendNotification();
1311 application.Render();
1313 // Executes the idle callbacks added by the text control on the change of input style.
1314 application.RunIdles();
1316 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1317 if( gInputStyleChangedCallbackCalled )
1319 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1320 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1321 TextEditor::InputStyle::POINT_SIZE |
1322 TextEditor::InputStyle::COLOR ),
1325 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1326 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1328 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1329 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1331 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1332 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1334 DALI_TEST_CHECK( inputStyleChangedSignal );
1336 gInputStyleChangedCallbackCalled = false;
1337 gInputStyleMask = TextEditor::InputStyle::NONE;
1338 inputStyleChangedSignal = false;
1340 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1342 // Render and notify
1343 application.SendNotification();
1344 application.Render();
1346 // Executes the idle callbacks added by the text control on the change of input style.
1347 application.RunIdles();
1349 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1350 if( gInputStyleChangedCallbackCalled )
1352 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1353 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1356 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1357 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1359 DALI_TEST_CHECK( inputStyleChangedSignal );
1361 gInputStyleChangedCallbackCalled = false;
1362 gInputStyleMask = TextEditor::InputStyle::NONE;
1363 inputStyleChangedSignal = false;
1365 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1367 // Render and notify
1368 application.SendNotification();
1369 application.Render();
1371 // Executes the idle callbacks added by the text control on the change of input style.
1372 application.RunIdles();
1374 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1375 DALI_TEST_CHECK( !inputStyleChangedSignal );
1377 gInputStyleChangedCallbackCalled = false;
1378 gInputStyleMask = TextEditor::InputStyle::NONE;
1379 inputStyleChangedSignal = false;
1381 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1383 // Render and notify
1384 application.SendNotification();
1385 application.Render();
1387 // Executes the idle callbacks added by the text control on the change of input style.
1388 application.RunIdles();
1390 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1391 if( gInputStyleChangedCallbackCalled )
1393 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1394 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1397 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1398 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1400 DALI_TEST_CHECK( inputStyleChangedSignal );
1402 gInputStyleChangedCallbackCalled = false;
1403 gInputStyleMask = TextEditor::InputStyle::NONE;
1404 inputStyleChangedSignal = false;
1406 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1408 Property::Map fontStyleMapSet;
1409 fontStyleMapSet.Insert( "weight", "thin" );
1410 fontStyleMapSet.Insert( "width", "condensed" );
1411 fontStyleMapSet.Insert( "slant", "italic" );
1413 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1414 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1415 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1417 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1418 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1419 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1420 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1422 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1424 // Render and notify
1425 application.SendNotification();
1426 application.Render();
1428 // Executes the idle callbacks added by the text control on the change of input style.
1429 application.RunIdles();
1431 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1432 DALI_TEST_CHECK( !inputStyleChangedSignal );
1434 // Create a tap event to touch the text editor.
1435 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1436 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1438 // Render and notify
1439 application.SendNotification();
1440 application.Render();
1442 // Executes the idle callbacks added by the text control on the change of input style.
1443 application.RunIdles();
1445 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1446 if( gInputStyleChangedCallbackCalled )
1448 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1449 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1450 TextEditor::InputStyle::POINT_SIZE |
1451 TextEditor::InputStyle::FONT_STYLE |
1452 TextEditor::InputStyle::LINE_SPACING |
1453 TextEditor::InputStyle::UNDERLINE |
1454 TextEditor::InputStyle::SHADOW |
1455 TextEditor::InputStyle::EMBOSS |
1456 TextEditor::InputStyle::OUTLINE ),
1459 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1460 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1462 DALI_TEST_CHECK( inputStyleChangedSignal );
1464 gInputStyleChangedCallbackCalled = false;
1465 gInputStyleMask = TextEditor::InputStyle::NONE;
1466 inputStyleChangedSignal = false;
1468 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1470 fontStyleMapSet.Clear();
1471 fontStyleMapSet.Insert( "weight", "black" );
1472 fontStyleMapSet.Insert( "width", "expanded" );
1473 fontStyleMapSet.Insert( "slant", "oblique" );
1475 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1477 // Create a tap event to touch the text editor.
1478 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1479 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1481 // Render and notify
1482 application.SendNotification();
1483 application.Render();
1485 // Executes the idle callbacks added by the text control on the change of input style.
1486 application.RunIdles();
1488 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1489 if( gInputStyleChangedCallbackCalled )
1491 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1492 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1493 TextEditor::InputStyle::POINT_SIZE |
1494 TextEditor::InputStyle::FONT_STYLE ),
1497 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1498 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1500 DALI_TEST_CHECK( inputStyleChangedSignal );
1505 int utcDaliTextEditorEvent01(void)
1507 ToolkitTestApplication application;
1508 tet_infoline(" utcDaliTextEditorEvent01");
1510 // Creates a tap event. After creating a tap event the text editor should
1511 // have the focus and add text with key events should be possible.
1513 TextEditor editor = TextEditor::New();
1514 DALI_TEST_CHECK( editor );
1516 Stage::GetCurrent().Add( editor );
1518 editor.SetSize( 300.f, 50.f );
1519 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1520 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1522 // Avoid a crash when core load gl resources.
1523 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1525 // Render and notify
1526 application.SendNotification();
1527 application.Render();
1529 // Add a key event but as the text editor has not the focus it should do nothing.
1530 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1532 // Render and notify
1533 application.SendNotification();
1534 application.Render();
1536 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1538 // Create a tap event to touch the text editor.
1539 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1540 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1542 // Render and notify
1543 application.SendNotification();
1544 application.Render();
1546 // Now the text editor has the focus, so it can handle the key events.
1547 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1548 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1550 // Render and notify
1551 application.SendNotification();
1552 application.Render();
1554 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1556 // Create a second text editor and send key events to it.
1557 TextEditor editor2 = TextEditor::New();
1559 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1560 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1561 editor2.SetSize( 100.f, 100.f );
1562 editor2.SetPosition( 100.f, 100.f );
1564 Stage::GetCurrent().Add( editor2 );
1566 // Render and notify
1567 application.SendNotification();
1568 application.Render();
1570 // Create a tap event on the second text editor.
1571 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1572 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1574 // Render and notify
1575 application.SendNotification();
1576 application.Render();
1578 // The second text editor has the focus. It should handle the key events.
1579 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1580 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1582 // Render and notify
1583 application.SendNotification();
1584 application.Render();
1586 // Check the text has been added to the second text editor.
1587 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1592 int utcDaliTextEditorEvent02(void)
1594 ToolkitTestApplication application;
1595 tet_infoline(" utcDaliTextEditorEvent02");
1597 // Checks if the right number of actors are created.
1599 TextEditor editor = TextEditor::New();
1600 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1601 DALI_TEST_CHECK( editor );
1603 Stage::GetCurrent().Add( editor );
1605 editor.SetSize( 300.f, 50.f );
1606 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1607 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1609 // Avoid a crash when core load gl resources.
1610 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1612 // Render and notify
1613 application.SendNotification();
1614 application.Render();
1616 // Check there are the expected number of children (the stencil).
1617 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1619 Actor stencil = editor.GetChildAt( 0u );
1621 // Create a tap event to touch the text editor.
1622 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1623 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1625 // Render and notify
1626 application.SendNotification();
1627 application.Render();
1629 Actor layer = editor.GetChildAt( 1u );
1630 DALI_TEST_CHECK( layer.IsLayer() );
1632 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1633 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1635 // Now the text editor has the focus, so it can handle the key events.
1636 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1637 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 // Render and notify
1640 application.SendNotification();
1641 application.Render();
1643 // Checks the cursor and the renderer have been created.
1644 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1645 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1647 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1648 DALI_TEST_CHECK( cursor );
1650 // The stencil actor has a container with all the actors which contain the text renderers.
1651 Actor container = stencil.GetChildAt( 0u );
1652 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1654 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1655 DALI_TEST_CHECK( renderer );
1658 // Move the cursor and check the position changes.
1659 Vector3 position1 = cursor.GetCurrentPosition();
1661 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1662 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1664 // Render and notify
1665 application.SendNotification();
1666 application.Render();
1668 Vector3 position2 = cursor.GetCurrentPosition();
1670 DALI_TEST_CHECK( position2.x < position1.x );
1672 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1673 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1675 // Render and notify
1676 application.SendNotification();
1677 application.Render();
1679 Vector3 position3 = cursor.GetCurrentPosition();
1681 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1683 // Send some taps and check the cursor positions.
1685 // Try to tap at the beginning.
1686 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1687 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1689 // Render and notify
1690 application.SendNotification();
1691 application.Render();
1693 // Cursor position should be the same than position1.
1694 Vector3 position4 = cursor.GetCurrentPosition();
1696 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1698 // Tap away from the start position.
1699 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1700 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1702 // Render and notify
1703 application.SendNotification();
1704 application.Render();
1706 Vector3 position5 = cursor.GetCurrentPosition();
1708 DALI_TEST_CHECK( position5.x > position4.x );
1710 // Remove all the text.
1711 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1712 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1713 editor.SetProperty( TextEditor::Property::TEXT, "" );
1715 // Render and notify
1716 application.SendNotification();
1717 application.Render();
1719 // Cursor position should be the same than position2.
1720 Vector3 position6 = cursor.GetCurrentPosition();
1722 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1724 // Should not be a renderer.
1725 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1730 int utcDaliTextEditorEvent03(void)
1732 ToolkitTestApplication application;
1733 tet_infoline(" utcDaliTextEditorEvent03");
1735 // Checks if the highlight actor is created.
1737 TextEditor editor = TextEditor::New();
1738 DALI_TEST_CHECK( editor );
1740 Stage::GetCurrent().Add( editor );
1742 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1743 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1744 editor.SetSize( 30.f, 50.f );
1745 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1746 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1748 // Avoid a crash when core load gl resources.
1749 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1751 // Render and notify
1752 application.SendNotification();
1753 application.Render();
1755 // Send some taps and check text controller with clipboard window
1756 Dali::Clipboard clipboard = Clipboard::Get();
1757 clipboard.ShowClipboard();
1758 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1759 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1760 clipboard.HideClipboard();
1762 // Render and notify
1763 application.SendNotification();
1764 application.Render();
1766 // Tap first to get the focus.
1767 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1768 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1770 // Render and notify
1771 application.SendNotification();
1772 application.Render();
1774 // Double tap to select a word.
1775 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1776 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1778 // Render and notify
1779 application.SendNotification();
1780 application.Render();
1782 // The stencil actor should have two actors: the renderer and the highlight actor.
1783 Actor stencil = editor.GetChildAt( 0u );
1785 // Highlight needs to be drawn before text, so should come first in child order
1786 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1787 DALI_TEST_CHECK( highlight );
1789 // The stencil actor has a container with all the actors which contain the text renderers.
1790 Actor container = stencil.GetChildAt( 1u );
1791 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1793 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1794 DALI_TEST_CHECK( renderer );
1797 // Double tap out of bounds
1798 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1799 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1801 // Render and notify
1802 application.SendNotification();
1803 application.Render();
1805 // The stencil actor should have one actors: the renderer actor.
1806 stencil = editor.GetChildAt( 0u );
1808 // The stencil actor has a container with all the actors which contain the text renderers.
1809 container = stencil.GetChildAt( 0u );
1810 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1812 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1813 DALI_TEST_CHECK( renderer );
1817 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1818 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1820 // Render and notify
1821 application.SendNotification();
1822 application.Render();
1827 int utcDaliTextEditorEvent04(void)
1829 ToolkitTestApplication application;
1830 tet_infoline(" utcDaliTextEditorEvent04");
1832 // Checks if the highlight actor is created.
1834 TextEditor editor = TextEditor::New();
1835 DALI_TEST_CHECK( editor );
1837 Stage::GetCurrent().Add( editor );
1839 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1840 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1841 editor.SetSize( 100.f, 50.f );
1842 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1843 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1845 // Avoid a crash when core load gl resources.
1846 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1848 // Render and notify
1849 application.SendNotification();
1850 application.Render();
1852 // Tap on the text editor
1853 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1854 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1856 // Render and notify
1857 application.SendNotification();
1858 application.Render();
1860 // Move at the end of the text.
1861 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1862 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1864 // Render and notify
1865 application.SendNotification();
1866 application.Render();
1868 for( unsigned int index = 0u; index < 10u; ++index )
1870 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1871 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1873 // Render and notify
1874 application.SendNotification();
1875 application.Render();
1879 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1881 // Render and notify
1882 application.SendNotification();
1883 application.Render();
1885 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1887 // Add some key events
1888 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1889 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1891 // Render and notify
1892 application.SendNotification();
1893 application.Render();
1895 for( unsigned int index = 0u; index < 10u; ++index )
1897 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1898 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1900 // Render and notify
1901 application.SendNotification();
1902 application.Render();
1906 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1908 // Render and notify
1909 application.SendNotification();
1910 application.Render();
1912 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1917 int utcDaliTextEditorEvent05(void)
1919 ToolkitTestApplication application;
1920 tet_infoline(" utcDaliTextEditorEvent05");
1922 // Checks if the highlight actor is created.
1924 TextEditor editor = TextEditor::New();
1925 DALI_TEST_CHECK( editor );
1927 Stage::GetCurrent().Add( editor );
1929 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1930 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1931 editor.SetSize( 50.f, 50.f );
1932 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1933 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1934 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1935 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1936 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1937 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1938 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1940 // Avoid a crash when core load gl resources.
1941 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1943 // Render and notify
1944 application.SendNotification();
1945 application.Render();
1947 // Tap on the text editor
1948 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1949 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1951 // Render and notify
1952 application.SendNotification();
1953 application.Render();
1955 // Move at the end of the text.
1956 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1957 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1959 // Render and notify
1960 application.SendNotification();
1961 application.Render();
1963 for( unsigned int index = 0u; index < 10u; ++index )
1966 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1968 // Render and notify
1969 application.SendNotification();
1970 application.Render();
1972 // Modify duration after scroll is enabled
1973 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1975 // Continuous scroll left to increase coverage
1976 for( unsigned int index = 0u; index < 10u; ++index )
1978 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1980 // Render and notify
1981 application.SendNotification();
1982 application.Render();
1984 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1985 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1986 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1987 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1988 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1990 // Press Escape to increase coverage
1991 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1992 application.SendNotification();
1993 application.Render();
1995 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2000 int utcDaliTextEditorEvent06(void)
2002 ToolkitTestApplication application;
2003 tet_infoline(" utcDaliTextEditorEvent06");
2005 // Checks if the highlight actor is created.
2007 TextEditor editor = TextEditor::New();
2008 DALI_TEST_CHECK( editor );
2010 Stage::GetCurrent().Add( editor );
2012 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2013 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2014 editor.SetSize( 100.f, 50.f );
2015 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2016 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2018 // Avoid a crash when core load gl resources.
2019 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2021 // Render and notify
2022 application.SendNotification();
2023 application.Render();
2025 // Tap on the text editor
2026 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2027 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2029 // Render and notify
2030 application.SendNotification();
2031 application.Render();
2033 // Move to seconds line of the text.
2034 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2036 // Render and notify
2037 application.SendNotification();
2038 application.Render();
2040 float layoutHeight = editor.GetHeightForWidth( 100.f );
2043 // Add another script characters ( glyph height is defferent )
2044 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2047 // Delete characters
2048 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2049 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2053 // Render and notify
2054 application.SendNotification();
2055 application.Render();
2057 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2060 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2061 application.SendNotification();
2062 application.Render();
2064 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2065 application.SendNotification();
2066 application.Render();
2068 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2069 application.SendNotification();
2070 application.Render();
2072 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2073 application.SendNotification();
2074 application.Render();
2076 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2077 application.SendNotification();
2078 application.Render();
2080 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2081 application.SendNotification();
2082 application.Render();
2084 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2085 application.SendNotification();
2086 application.Render();
2091 int utcDaliTextEditorEvent07(void)
2093 ToolkitTestApplication application;
2094 tet_infoline(" utcDaliTextEditorEvent07");
2096 // Checks if the highlight actor is created.
2098 TextEditor editor = TextEditor::New();
2099 DALI_TEST_CHECK( editor );
2101 Stage::GetCurrent().Add( editor );
2103 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2104 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2105 editor.SetSize( 100.f, 50.f );
2106 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2107 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2109 // Avoid a crash when core load gl resources.
2110 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2112 // Render and notify
2113 application.SendNotification();
2114 application.Render();
2116 // Tap on the text editor
2117 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2118 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2120 // Render and notify
2121 application.SendNotification();
2122 application.Render();
2124 // Move to second line of the text.
2125 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2127 // Render and notify
2128 application.SendNotification();
2129 application.Render();
2131 // Select some text in the right of the current cursor position
2132 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2133 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2135 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 // Render and notify
2138 application.SendNotification();
2139 application.Render();
2141 // Cut the selected text
2142 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2143 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2145 // Render and notify
2146 application.SendNotification();
2147 application.Render();
2149 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2151 // Select some text in the left of the current cursor position
2152 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2153 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2154 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2155 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 // Render and notify
2158 application.SendNotification();
2159 application.Render();
2161 // Copy the selected text
2162 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2163 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 // Render and notify
2166 application.SendNotification();
2167 application.Render();
2169 // Move the cursor to the third line
2170 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2171 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2173 // Render and notify
2174 application.SendNotification();
2175 application.Render();
2177 // Paste the selected text at the current cursor position
2178 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2179 application.ProcessEvent( GenerateKey( "v", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, "v", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2181 // Render and notify
2182 application.SendNotification();
2183 application.Render();
2185 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2188 // Disable Shift Selection
2189 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2191 // Test to select some text in the right of the current cursor position
2192 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2193 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2194 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2195 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2197 // Render and notify
2198 application.SendNotification();
2199 application.Render();
2201 // Cut the selected text
2202 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2203 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205 // Render and notify
2206 application.SendNotification();
2207 application.Render();
2209 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2210 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2212 // Test to select some text in the left of the current cursor position
2213 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2214 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2216 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218 // Render and notify
2219 application.SendNotification();
2220 application.Render();
2222 // Copy the selected text
2223 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2224 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226 // Render and notify
2227 application.SendNotification();
2228 application.Render();
2230 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2231 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2236 int utcDaliTextEditorEvent08(void)
2238 ToolkitTestApplication application;
2239 tet_infoline(" utcDaliTextEditorEvent08");
2241 // Checks if the highlight actor is released correctly.
2243 TextEditor editor = TextEditor::New();
2244 DALI_TEST_CHECK( editor );
2246 Stage::GetCurrent().Add( editor );
2248 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2249 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2250 editor.SetSize( 100.f, 50.f );
2251 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2252 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2254 // Avoid a crash when core load gl resources.
2255 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2257 // Render and notify
2258 application.SendNotification();
2259 application.Render();
2261 // Tap on the text editor
2262 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2263 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2265 // Render and notify
2266 application.SendNotification();
2267 application.Render();
2269 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2270 // Test to select some text in the left of the current cursor position
2271 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2274 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 // Render and notify
2277 application.SendNotification();
2278 application.Render();
2280 // Test to the left selection handle position and the right selection handle position
2281 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2282 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2284 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2286 // Render and notify
2287 application.SendNotification();
2288 application.Render();
2290 // Test to select full text in the left of the current cursor position
2291 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2294 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2295 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2296 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 // Render and notify
2299 application.SendNotification();
2300 application.Render();
2302 // Test to release the current full text selection
2303 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2304 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 // Render and notify
2307 application.SendNotification();
2308 application.Render();
2310 // Test to move the current cursor position correctly
2311 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2313 // Render and notify
2314 application.SendNotification();
2315 application.Render();
2318 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2320 // Render and notify
2321 application.SendNotification();
2322 application.Render();
2324 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2326 // Test to select some text in the right of the current cursor position
2327 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2328 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2329 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2331 // Render and notify
2332 application.SendNotification();
2333 application.Render();
2335 // Test the cursor position with right arrow key
2336 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2338 // Render and notify
2339 application.SendNotification();
2340 application.Render();
2343 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2345 // Render and notify
2346 application.SendNotification();
2347 application.Render();
2349 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2351 // Test to select some text in the left of the current cursor position
2352 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2354 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2355 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2356 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2358 // Render and notify
2359 application.SendNotification();
2360 application.Render();
2362 // Test the cursor position with left arrow key
2363 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2365 // Render and notify
2366 application.SendNotification();
2367 application.Render();
2370 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372 // Render and notify
2373 application.SendNotification();
2374 application.Render();
2376 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2378 // Test to select some text in the right of the current cursor position
2379 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2380 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2382 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 // Render and notify
2385 application.SendNotification();
2386 application.Render();
2388 // Test the cursor position with left arrow key
2389 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2391 // Render and notify
2392 application.SendNotification();
2393 application.Render();
2396 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2398 // Render and notify
2399 application.SendNotification();
2400 application.Render();
2402 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2404 // Test to select some text in the left of the current cursor position
2405 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2408 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2410 // Render and notify
2411 application.SendNotification();
2412 application.Render();
2414 // Test the cursor position with right arrow key
2415 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2417 // Render and notify
2418 application.SendNotification();
2419 application.Render();
2422 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2424 // Render and notify
2425 application.SendNotification();
2426 application.Render();
2428 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2433 int utcDaliTextEditorHandles(void)
2435 ToolkitTestApplication application;
2436 tet_infoline(" utcDaliTextEditorHandles");
2438 TextEditor editor = TextEditor::New();
2439 DALI_TEST_CHECK( editor );
2441 Stage::GetCurrent().Add( editor );
2443 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2444 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2445 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2446 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2448 Property::Map imagePropertyMap;
2449 imagePropertyMap["type"] = "BufferImage";
2450 imagePropertyMap["width"] = 40;
2451 imagePropertyMap["height"] = 40;
2453 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2454 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2455 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2456 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2458 editor.SetSize( 30.f, 500.f );
2459 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2460 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2462 // Avoid a crash when core load gl resources.
2463 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2465 // Render and notify
2466 application.SendNotification();
2467 application.Render();
2469 // Tap first to get the focus.
2470 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2471 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2473 // Render and notify
2474 application.SendNotification();
2475 application.Render();
2477 // Tap to create the grab handle.
2478 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2479 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2481 // Render and notify
2482 application.SendNotification();
2483 application.Render();
2485 // Get the active layer where the text's decoration is added.
2486 Actor activeLayer = editor.GetChildAt( 1u );
2488 // Get the handle's actor.
2489 Actor handle = activeLayer.GetChildAt( 1u );
2490 handle.SetSize( 100.f, 100.f );
2492 // Render and notify
2493 application.SendNotification();
2494 application.Render();
2496 // Touch the grab handle to set it as pressed.
2497 Vector2 touchPos( 10.0f, 50.0f );
2498 Dali::Integration::TouchEvent event;
2499 event = Dali::Integration::TouchEvent();
2500 event.AddPoint( GetPointDownInside( touchPos ) );
2501 application.ProcessEvent( event );
2503 // Render and notify
2504 application.SendNotification();
2505 application.Render();
2507 // drag grab handle right
2508 SendPan(application, Gesture::Possible, touchPos);
2509 SendPan(application, Gesture::Started, touchPos);
2511 Wait(application, 100);
2513 for(int i = 0;i<20;i++)
2515 SendPan(application, Gesture::Continuing, touchPos);
2520 SendPan(application, Gesture::Finished, touchPos);
2523 // Release the grab handle.
2524 event = Dali::Integration::TouchEvent();
2525 event.AddPoint( GetPointUpInside( touchPos ) );
2526 application.ProcessEvent( event );
2528 // Render and notify
2529 application.SendNotification();
2530 application.Render();
2532 // Tap first to get the focus.
2533 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2534 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2536 // Render and notify
2537 application.SendNotification();
2538 application.Render();
2540 // Double tap to select a word and create the selection handles.
2541 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2542 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2544 // Render and notify
2545 application.SendNotification();
2546 application.Render();
2548 touchPos = Vector2( 10.0f, 50.0f );
2550 // Touch the left selection handle to set it as pressed.
2551 event = Dali::Integration::TouchEvent();
2552 event.AddPoint( GetPointDownInside( touchPos ) );
2553 application.ProcessEvent( event );
2555 // Render and notify
2556 application.SendNotification();
2557 application.Render();
2559 // drag the left selection handle right
2560 SendPan(application, Gesture::Possible, touchPos);
2561 SendPan(application, Gesture::Started, touchPos);
2563 Wait(application, 100);
2565 for(int i = 0;i<20;i++)
2567 SendPan(application, Gesture::Continuing, touchPos);
2572 SendPan(application, Gesture::Finished, touchPos);
2575 // Release the left selection handle.
2576 event = Dali::Integration::TouchEvent();
2577 event.AddPoint( GetPointUpInside( touchPos ) );
2578 application.ProcessEvent( event );
2580 // Render and notify
2581 application.SendNotification();
2582 application.Render();
2587 int utcDaliTextEditorUnderPropertyStringP(void)
2589 ToolkitTestApplication application;
2590 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2591 TextEditor editor = TextEditor::New();
2592 DALI_TEST_CHECK( editor );
2594 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2596 Stage::GetCurrent().Add( editor );
2598 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2599 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2601 tet_infoline("Set underline settings with a map");
2602 // Check the input underline property
2603 Property::Map underlineMapSet;
2604 Property::Map underlineMapGet;
2605 underlineMapSet.Insert( "enable", "true" );
2606 underlineMapSet.Insert( "color", "blue" );
2607 underlineMapSet.Insert( "height", "2" );
2609 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2610 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2611 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2612 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2614 tet_infoline("Set underline settings with a string");
2615 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2616 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2619 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2621 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2622 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2623 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2624 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2626 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2631 int utcDaliTextEditorShadowPropertyStringP(void)
2633 ToolkitTestApplication application;
2634 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2636 TextEditor editor = TextEditor::New();
2638 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2640 Stage::GetCurrent().Add( editor );
2642 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2644 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2648 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2653 int utcDaliTextEditorFontStylePropertyStringP(void)
2655 ToolkitTestApplication application;
2656 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2658 TextEditor editor = TextEditor::New();
2660 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2662 Stage::GetCurrent().Add( editor );
2664 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2666 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2670 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2675 int utcDaliTextEditorGetPropertyLinecountP(void)
2677 ToolkitTestApplication application;
2679 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2683 TextEditor editor = TextEditor::New();
2684 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2685 editor.SetProperty( TextEditor::Property::TEXT,
2686 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2688 Stage::GetCurrent().Add( editor );
2690 editor.SetSize( 100.0f, 100.0f );
2691 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2692 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2694 editor.SetSize( 50.0f, 100.0f );
2695 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2696 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2701 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2704 ToolkitTestApplication application;
2705 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2707 TextEditor editor = TextEditor::New();
2708 DALI_TEST_CHECK( editor );
2710 Stage::GetCurrent().Add( editor );
2712 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2713 editor.SetSize( 50.f, 50.f );
2714 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2715 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2716 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2717 editor.SetKeyboardFocusable(true);
2719 bool startedCalled = false;
2720 bool finishedCalled = false;
2722 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2723 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2725 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2727 // Render and notify
2728 application.SendNotification();
2729 application.Render();
2731 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2732 application.SendNotification();
2733 application.Render(6000);
2735 application.SendNotification();
2736 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2737 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2742 int UtcDaliToolkitTextEditorTextWrapMode(void)
2744 ToolkitTestApplication application;
2745 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2749 TextEditor editor = TextEditor::New();
2750 editor.SetSize( 150.0f, 300.f );
2751 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2753 Stage::GetCurrent().Add( editor );
2755 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2756 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2758 application.SendNotification();
2759 application.Render();
2761 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2762 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2764 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2765 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2767 application.SendNotification();
2768 application.Render();
2770 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2771 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2773 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2774 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2776 application.SendNotification();
2777 application.Render();
2779 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2780 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2782 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2783 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2785 application.SendNotification();
2786 application.Render();
2788 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2789 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2794 int UtcDaliTextEditorSetPaddingProperty(void)
2796 ToolkitTestApplication application;
2797 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2799 TextEditor editor = TextEditor::New();
2800 DALI_TEST_CHECK( editor );
2801 editor.SetSize( 300.f, 50.f );
2802 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2803 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2804 Stage::GetCurrent().Add( editor );
2806 application.SendNotification();
2807 application.Render();
2809 Vector3 originalSize = editor.GetNaturalSize();
2811 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2813 application.SendNotification();
2814 application.Render();
2816 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2818 Vector3 paddingAddedSize = editor.GetNaturalSize();
2820 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2822 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2827 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2829 ToolkitTestApplication application;
2830 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2832 TextEditor editor = TextEditor::New();
2833 DALI_TEST_CHECK( editor );
2834 editor.SetSize( 300.f, 50.f );
2835 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2836 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2837 Stage::GetCurrent().Add( editor );
2839 application.SendNotification();
2840 application.Render();
2842 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2843 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2845 // Check the enable shift selection property
2846 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2847 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2849 application.SendNotification();
2850 application.Render();
2855 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2857 ToolkitTestApplication application;
2858 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2860 TextEditor editor = TextEditor::New();
2861 DALI_TEST_CHECK( editor );
2862 editor.SetSize( 300.f, 50.f );
2863 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2864 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2865 Stage::GetCurrent().Add( editor );
2867 application.SendNotification();
2868 application.Render();
2870 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2871 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2873 // Check the enable grab handle property
2874 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2875 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2877 application.SendNotification();
2878 application.Render();
2883 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2885 ToolkitTestApplication application;
2886 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2888 TextEditor editor = TextEditor::New();
2889 DALI_TEST_CHECK( editor );
2890 editor.SetSize( 300.f, 50.f );
2891 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2892 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2893 Stage::GetCurrent().Add( editor );
2895 application.SendNotification();
2896 application.Render();
2898 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2899 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2901 // Check the enable match system language direction property
2902 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2903 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2905 application.SendNotification();
2906 application.Render();
2911 int UtcDaliTextEditorGetInputMethodContext(void)
2913 ToolkitTestApplication application;
2914 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2916 TextEditor editor = TextEditor::New();
2917 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );