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& key,
218 const std::string& keyString,
221 unsigned long timeStamp,
222 const Integration::KeyEvent::State& keyState,
223 const std::string& compose = "",
224 const std::string& deviceName = DEFAULT_DEVICE_NAME,
225 const Device::Class::Type& deviceClass = Device::Class::NONE,
226 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
228 return Integration::KeyEvent( keyName,
242 * Helper to generate PanGestureEvent
244 * @param[in] application Application instance
245 * @param[in] state The Gesture State
246 * @param[in] pos The current position of touch.
248 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
252 if( (state == Gesture::Started) ||
253 (state == Gesture::Possible) )
259 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
266 * Simulate time passed by.
268 * @note this will always process at least 1 frame (1/60 sec)
270 * @param application Test application instance
271 * @param duration Time to pass in milliseconds.
272 * @return The actual time passed in milliseconds
274 static int Wait(ToolkitTestApplication& application, int duration = 0)
278 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
280 application.SendNotification();
281 application.Render(RENDER_FRAME_INTERVAL);
282 time += RENDER_FRAME_INTERVAL;
288 Dali::Integration::Point GetPointDownInside( Vector2& pos )
290 Dali::Integration::Point point;
291 point.SetState( PointState::DOWN );
292 point.SetScreenPosition( pos );
296 Dali::Integration::Point GetPointUpInside( Vector2& pos )
298 Dali::Integration::Point point;
299 point.SetState( PointState::UP );
300 point.SetScreenPosition( pos );
304 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
306 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
308 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
310 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
312 Property::Value* valueSet = NULL;
313 if ( valueGet.first.type == Property::Key::INDEX )
315 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
319 // Get Key is a string so searching Set Map for a string key
320 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
323 if( NULL != valueSet )
325 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
327 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
330 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
332 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
335 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
337 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
340 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
342 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
345 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
347 Vector2 vector2Get = valueGet.second.Get<Vector2>();
348 Vector2 vector2Set = valueSet->Get<Vector2>();
349 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
352 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
354 Vector4 vector4Get = valueGet.second.Get<Vector4>();
355 Vector4 vector4Set = valueSet->Get<Vector4>();
356 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 );
362 if ( valueGet.first.type == Property::Key::INDEX )
364 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
368 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
378 class ScrollStateChangeCallback : public Dali::ConnectionTracker
381 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
382 : mStartedCalled( startedCalled ),
383 mFinishedCalled( finishedCalled )
387 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
389 if( type == TextEditor::Scroll::STARTED )
391 mStartedCalled = true;
393 else if( type == TextEditor::Scroll::FINISHED )
395 mFinishedCalled = true;
399 bool& mStartedCalled;
400 bool& mFinishedCalled;
405 int UtcDaliToolkitTextEditorConstructorP(void)
407 ToolkitTestApplication application;
408 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
409 TextEditor textEditor;
410 DALI_TEST_CHECK( !textEditor );
414 int UtcDaliToolkitTextEditorNewP(void)
416 ToolkitTestApplication application;
417 tet_infoline(" UtcDaliToolkitTextEditorNewP");
418 TextEditor textEditor = TextEditor::New();
419 DALI_TEST_CHECK( textEditor );
423 int UtcDaliToolkitTextEditorDownCastP(void)
425 ToolkitTestApplication application;
426 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
427 TextEditor textEditor1 = TextEditor::New();
428 BaseHandle object( textEditor1 );
430 TextEditor textEditor2 = TextEditor::DownCast( object );
431 DALI_TEST_CHECK( textEditor2 );
433 TextEditor textEditor3 = DownCast< TextEditor >( object );
434 DALI_TEST_CHECK( textEditor3 );
438 int UtcDaliToolkitTextEditorDownCastN(void)
440 ToolkitTestApplication application;
441 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
442 BaseHandle uninitializedObject;
443 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
444 DALI_TEST_CHECK( !textEditor1 );
446 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
447 DALI_TEST_CHECK( !textEditor2 );
451 int UtcDaliToolkitTextEditorCopyConstructorP(void)
453 ToolkitTestApplication application;
454 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
455 TextEditor textEditor = TextEditor::New();
456 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
458 TextEditor copy( textEditor );
459 DALI_TEST_CHECK( copy );
460 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
464 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
466 ToolkitTestApplication application;
467 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
468 TextEditor textEditor = TextEditor::New();
469 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
471 TextEditor copy = textEditor;
472 DALI_TEST_CHECK( copy );
473 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
477 int UtcDaliTextEditorNewP(void)
479 ToolkitTestApplication application;
480 tet_infoline(" UtcDaliToolkitTextEditorNewP");
481 TextEditor textEditor = TextEditor::New();
482 DALI_TEST_CHECK( textEditor );
486 // Positive test case for a method
487 int UtcDaliTextEditorGetPropertyP(void)
489 ToolkitTestApplication application;
490 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
491 TextEditor editor = TextEditor::New();
492 DALI_TEST_CHECK( editor );
494 // Check Property Indices are correct
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
545 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
546 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
547 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
548 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
549 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
554 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
557 Property::Map imageMap;
558 imageMap[mapKey] =mapValue;
560 editor.SetProperty( property , imageMap );
561 Property::Value propValue = editor.GetProperty( property );
562 Property::Map* resultMap = propValue.GetMap();
564 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
572 // Positive test case for a method
573 int UtcDaliTextEditorSetPropertyP(void)
575 ToolkitTestApplication application;
576 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
577 TextEditor editor = TextEditor::New();
578 DALI_TEST_CHECK( editor );
579 Stage::GetCurrent().Add( editor );
581 // Note - we can't check the defaults since the stylesheets are platform-specific
583 // Check the render backend property.
584 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
585 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
587 // Check text property.
588 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
589 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
591 // Check text's color property
592 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
593 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
595 // Check font properties.
596 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
597 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
599 Property::Map fontStyleMapSet;
600 Property::Map fontStyleMapGet;
601 Property::Value* slantValue = NULL;
603 fontStyleMapSet.Insert( "weight", "bold" );
604 fontStyleMapSet.Insert( "width", "condensed" );
605 fontStyleMapSet.Insert( "slant", "italic" );
607 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
608 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
609 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
610 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
612 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
613 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
616 fontStyleMapSet.Clear();
617 fontStyleMapSet.Insert( "weight", "normal" );
618 fontStyleMapSet.Insert( "slant", "oblique" );
619 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
620 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
621 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
622 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
624 fontStyleMapSet.Clear();
625 fontStyleMapSet.Insert( "slant", "roman" );
626 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
627 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
629 // Replace 'roman' for 'normal'.
630 slantValue = fontStyleMapGet.Find( "slant" );
631 if( NULL != slantValue )
633 if( "normal" == slantValue->Get<std::string>() )
635 fontStyleMapGet["slant"] = "roman";
638 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
639 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
641 fontStyleMapSet.Clear();
643 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
644 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
645 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
646 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
648 // Check that the Alignment properties can be correctly set
649 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
650 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
652 // Check scroll properties.
653 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
654 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
655 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
656 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
658 // Check cursor properties
659 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
660 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
661 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
662 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
664 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
665 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
666 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
667 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
668 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
669 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
670 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
671 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
673 // Check handle images
674 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
675 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
676 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
677 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
678 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
680 // Check handle images
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
682 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
683 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
684 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
685 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
686 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
688 // Check the highlight color
689 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
690 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
692 // Decoration bounding box
693 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
694 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
696 // Check the enable markup property.
697 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
698 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
699 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
701 // Check input color property.
702 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
703 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
705 // Check input font properties.
706 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
707 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
709 fontStyleMapSet.Clear();
710 fontStyleMapSet.Insert( "weight", "bold" );
711 fontStyleMapSet.Insert( "width", "condensed" );
712 fontStyleMapSet.Insert( "slant", "italic" );
714 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
715 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
716 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
717 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
719 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
720 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
722 // Reset input font style.
723 fontStyleMapSet.Clear();
724 fontStyleMapSet.Insert( "weight", "normal" );
725 fontStyleMapSet.Insert( "slant", "oblique" );
727 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
728 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
729 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
730 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
732 fontStyleMapSet.Clear();
733 fontStyleMapSet.Insert( "slant", "roman" );
735 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
736 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
738 // Replace 'roman' for 'normal'.
739 slantValue = fontStyleMapGet.Find( "slant" );
740 if( NULL != slantValue )
742 if( "normal" == slantValue->Get<std::string>() )
744 fontStyleMapGet["slant"] = "roman";
747 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
748 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
750 fontStyleMapSet.Clear();
752 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
753 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
754 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
755 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
757 // Check the line spacing property
758 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
759 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
760 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
762 // Check the input line spacing property
763 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
764 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
765 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
767 // Check the underline property
769 Property::Map underlineMapSet;
770 Property::Map underlineMapGet;
772 underlineMapSet.Insert( "enable", "true" );
773 underlineMapSet.Insert( "color", "red" );
774 underlineMapSet.Insert( "height", "1" );
776 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
778 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
779 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
780 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
782 // Check the input underline property
783 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
784 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
786 // Check the shadow property
787 Property::Map shadowMapSet;
788 Property::Map shadowMapGet;
790 shadowMapSet.Insert( "color", Color::GREEN );
791 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
792 shadowMapSet.Insert( "blurRadius", 3.0f );
794 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
796 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
797 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
798 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
800 // Check the input shadow property
801 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
802 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
804 // Check the emboss property
805 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
806 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
808 // Check the input emboss property
809 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
810 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
812 // Check the outline property
814 // Test string type first
815 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
816 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
817 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
819 // Then test the property map type
820 Property::Map outlineMapSet;
821 Property::Map outlineMapGet;
823 outlineMapSet["color"] = Color::RED;
824 outlineMapSet["width"] = 2.0f;
826 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
828 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
829 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
830 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
832 // Check the input outline property
833 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
834 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
836 // Check the smooth scroll property
837 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
838 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
839 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
841 // Check the smooth scroll duration property
842 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
843 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
845 // Check the scroll bar property
846 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
847 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
848 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
850 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
851 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
852 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
853 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
855 // Check the pixel size of font
856 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
857 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
859 // Check placeholder text properties.
860 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
861 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
863 // Check placeholder text's color property.
864 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
865 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
867 // Check the enable selection property
868 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
869 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
871 // Check the placeholder property with pixel size
872 Property::Map placeholderPixelSizeMapSet;
873 Property::Map placeholderPixelSizeMapGet;
874 Property::Map placeholderFontstyleMap;
875 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
876 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
877 placeholderPixelSizeMapSet["color"] = Color::BLUE;
878 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
879 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
881 placeholderFontstyleMap.Insert( "weight", "bold" );
882 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
883 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
885 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
886 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
888 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
889 Property::Map placeholderConversionMap;
890 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
891 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
892 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
893 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
894 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
895 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
897 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
899 // Check the placeholder property with point size
900 Property::Map placeholderMapSet;
901 Property::Map placeholderMapGet;
902 placeholderMapSet["text"] = "Setting Placeholder Text";
903 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
904 placeholderMapSet["color"] = Color::RED;
905 placeholderMapSet["fontFamily"] = "Arial";
906 placeholderMapSet["pointSize"] = 12.0f;
907 // Check the placeholder font style property
908 placeholderFontstyleMap.Clear();
910 placeholderFontstyleMap.Insert( "weight", "bold" );
911 placeholderFontstyleMap.Insert( "width", "condensed" );
912 placeholderFontstyleMap.Insert( "slant", "italic" );
913 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
914 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
916 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
917 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
919 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
920 placeholderConversionMap.Clear();
921 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
922 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
923 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
924 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
925 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
926 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
927 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
930 placeholderFontstyleMap.Clear();
931 placeholderFontstyleMap.Insert( "weight", "normal" );
932 placeholderFontstyleMap.Insert( "slant", "oblique" );
933 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
934 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
936 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
937 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
938 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
939 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
941 placeholderFontstyleMap.Clear();
942 placeholderFontstyleMap.Insert( "slant", "roman" );
943 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
944 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
946 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
948 placeholderFontstyleMap.Clear();
949 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
951 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
952 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
953 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
954 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
955 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
957 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
958 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
960 application.SendNotification();
961 application.Render();
966 // Positive Atlas Text Renderer test
967 int utcDaliTextEditorAtlasRenderP(void)
969 ToolkitTestApplication application;
970 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
971 StyleManager styleManager = StyleManager::Get();
972 styleManager.ApplyDefaultTheme();
973 TextEditor editor = TextEditor::New();
974 DALI_TEST_CHECK( editor );
976 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
978 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
980 Stage::GetCurrent().Add( editor );
984 // Render some text with the shared atlas backend
985 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
986 application.SendNotification();
987 application.Render();
991 tet_result(TET_FAIL);
996 // Positive test for the textChanged signal.
997 int utcDaliTextEditorTextChangedP(void)
999 ToolkitTestApplication application;
1000 tet_infoline(" utcDaliTextEditorTextChangedP");
1001 TextEditor editor = TextEditor::New();
1002 DALI_TEST_CHECK( editor );
1004 Stage::GetCurrent().Add( editor );
1006 // connect to the text changed signal.
1007 ConnectionTracker* testTracker = new ConnectionTracker();
1008 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1009 bool textChangedSignal = false;
1010 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1012 gTextChangedCallBackCalled = false;
1013 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1014 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1015 DALI_TEST_CHECK( textChangedSignal );
1017 application.SendNotification();
1019 editor.SetKeyInputFocus();
1021 gTextChangedCallBackCalled = false;
1022 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1023 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1028 int utcDaliTextEditorInputStyleChanged01(void)
1030 ToolkitTestApplication application;
1031 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1033 // The text-editor emits signals when the input style changes. These changes of style are
1034 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1035 // can't be emitted during the size negotiation as the callbacks may update the UI.
1036 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1037 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1038 application.CreateAdaptor();
1042 char* pathNamePtr = get_current_dir_name();
1043 const std::string pathName( pathNamePtr );
1044 free( pathNamePtr );
1046 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1047 fontClient.SetDpi( 93u, 93u );
1049 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1050 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1052 TextEditor editor = TextEditor::New();
1053 DALI_TEST_CHECK( editor );
1056 editor.SetSize( 300.f, 50.f );
1057 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1058 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1060 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1061 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1063 // connect to the text changed signal.
1064 ConnectionTracker* testTracker = new ConnectionTracker();
1065 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1066 bool inputStyleChangedSignal = false;
1067 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1069 Stage::GetCurrent().Add( editor );
1071 // Render and notify
1072 application.SendNotification();
1073 application.Render();
1075 // Executes the idle callbacks added by the text control on the change of input style.
1076 application.RunIdles();
1078 gInputStyleChangedCallbackCalled = false;
1079 gInputStyleMask = TextEditor::InputStyle::NONE;
1080 inputStyleChangedSignal = false;
1082 // Create a tap event to touch the text editor.
1083 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1084 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1086 // Render and notify
1087 application.SendNotification();
1088 application.Render();
1090 // Executes the idle callbacks added by the text control on the change of input style.
1091 application.RunIdles();
1093 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1094 if( gInputStyleChangedCallbackCalled )
1096 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1098 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1099 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1101 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1102 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1104 DALI_TEST_CHECK( inputStyleChangedSignal );
1106 gInputStyleChangedCallbackCalled = false;
1107 gInputStyleMask = TextEditor::InputStyle::NONE;
1108 inputStyleChangedSignal = false;
1110 // Create a tap event to touch the text editor.
1111 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1112 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1114 // Render and notify
1115 application.SendNotification();
1116 application.Render();
1118 // Executes the idle callbacks added by the text control on the change of input style.
1119 application.RunIdles();
1121 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1122 DALI_TEST_CHECK( !inputStyleChangedSignal );
1124 gInputStyleChangedCallbackCalled = false;
1125 gInputStyleMask = TextEditor::InputStyle::NONE;
1126 inputStyleChangedSignal = false;
1128 // Create a tap event to touch the text editor.
1129 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1130 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1132 // Render and notify
1133 application.SendNotification();
1134 application.Render();
1136 // Executes the idle callbacks added by the text control on the change of input style.
1137 application.RunIdles();
1139 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1140 if( gInputStyleChangedCallbackCalled )
1142 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1144 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1145 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1147 DALI_TEST_CHECK( inputStyleChangedSignal );
1149 gInputStyleChangedCallbackCalled = false;
1150 gInputStyleMask = TextEditor::InputStyle::NONE;
1151 inputStyleChangedSignal = false;
1153 // Create a tap event to touch the text editor.
1154 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1155 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1157 // Render and notify
1158 application.SendNotification();
1159 application.Render();
1161 // Executes the idle callbacks added by the text control on the change of input style.
1162 application.RunIdles();
1164 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1165 if( gInputStyleChangedCallbackCalled )
1167 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1169 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1170 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1172 Property::Map fontStyleMapSet;
1173 Property::Map fontStyleMapGet;
1175 fontStyleMapSet.Insert( "weight", "bold" );
1177 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1178 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1179 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1181 DALI_TEST_CHECK( inputStyleChangedSignal );
1183 gInputStyleChangedCallbackCalled = false;
1184 gInputStyleMask = TextEditor::InputStyle::NONE;
1185 inputStyleChangedSignal = false;
1187 // Create a tap event to touch the text editor.
1188 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1189 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1191 // Render and notify
1192 application.SendNotification();
1193 application.Render();
1195 // Executes the idle callbacks added by the text control on the change of input style.
1196 application.RunIdles();
1198 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1199 DALI_TEST_CHECK( !inputStyleChangedSignal );
1201 gInputStyleChangedCallbackCalled = false;
1202 gInputStyleMask = TextEditor::InputStyle::NONE;
1203 inputStyleChangedSignal = false;
1205 // Create a tap event to touch the text editor.
1206 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1207 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1209 // Render and notify
1210 application.SendNotification();
1211 application.Render();
1213 // Executes the idle callbacks added by the text control on the change of input style.
1214 application.RunIdles();
1216 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1217 if( gInputStyleChangedCallbackCalled )
1219 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1221 Property::Map fontStyleMapSet;
1222 Property::Map fontStyleMapGet;
1224 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1225 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1226 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1228 DALI_TEST_CHECK( inputStyleChangedSignal );
1230 gInputStyleChangedCallbackCalled = false;
1231 gInputStyleMask = TextEditor::InputStyle::NONE;
1232 inputStyleChangedSignal = false;
1234 // Create a tap event to touch the text editor.
1235 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1236 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1238 // Render and notify
1239 application.SendNotification();
1240 application.Render();
1242 // Executes the idle callbacks added by the text control on the change of input style.
1243 application.RunIdles();
1245 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1246 DALI_TEST_CHECK( !inputStyleChangedSignal );
1251 int utcDaliTextEditorInputStyleChanged02(void)
1253 ToolkitTestApplication application;
1254 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1256 // The text-editor emits signals when the input style changes. These changes of style are
1257 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1258 // can't be emitted during the size negotiation as the callbacks may update the UI.
1259 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1260 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1261 application.CreateAdaptor();
1265 char* pathNamePtr = get_current_dir_name();
1266 const std::string pathName( pathNamePtr );
1267 free( pathNamePtr );
1269 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1270 fontClient.SetDpi( 93u, 93u );
1272 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1273 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1275 TextEditor editor = TextEditor::New();
1276 DALI_TEST_CHECK( editor );
1279 editor.SetSize( 300.f, 50.f );
1280 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1281 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1283 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1284 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>" );
1286 // connect to the text changed signal.
1287 ConnectionTracker* testTracker = new ConnectionTracker();
1288 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1289 bool inputStyleChangedSignal = false;
1290 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1292 Stage::GetCurrent().Add( editor );
1294 // Render and notify
1295 application.SendNotification();
1296 application.Render();
1298 // Executes the idle callbacks added by the text control on the change of input style.
1299 application.RunIdles();
1301 gInputStyleChangedCallbackCalled = false;
1302 gInputStyleMask = TextEditor::InputStyle::NONE;
1303 inputStyleChangedSignal = false;
1305 // Create a tap event to touch the text editor.
1306 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1307 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1308 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1309 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1311 // Render and notify
1312 application.SendNotification();
1313 application.Render();
1315 // Executes the idle callbacks added by the text control on the change of input style.
1316 application.RunIdles();
1318 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1319 if( gInputStyleChangedCallbackCalled )
1321 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1322 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1323 TextEditor::InputStyle::POINT_SIZE |
1324 TextEditor::InputStyle::COLOR ),
1327 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1328 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1330 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1331 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1333 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1334 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1336 DALI_TEST_CHECK( inputStyleChangedSignal );
1338 gInputStyleChangedCallbackCalled = false;
1339 gInputStyleMask = TextEditor::InputStyle::NONE;
1340 inputStyleChangedSignal = false;
1342 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1344 // Render and notify
1345 application.SendNotification();
1346 application.Render();
1348 // Executes the idle callbacks added by the text control on the change of input style.
1349 application.RunIdles();
1351 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1352 if( gInputStyleChangedCallbackCalled )
1354 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1355 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1358 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1359 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1361 DALI_TEST_CHECK( inputStyleChangedSignal );
1363 gInputStyleChangedCallbackCalled = false;
1364 gInputStyleMask = TextEditor::InputStyle::NONE;
1365 inputStyleChangedSignal = false;
1367 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1369 // Render and notify
1370 application.SendNotification();
1371 application.Render();
1373 // Executes the idle callbacks added by the text control on the change of input style.
1374 application.RunIdles();
1376 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1377 DALI_TEST_CHECK( !inputStyleChangedSignal );
1379 gInputStyleChangedCallbackCalled = false;
1380 gInputStyleMask = TextEditor::InputStyle::NONE;
1381 inputStyleChangedSignal = false;
1383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1385 // Render and notify
1386 application.SendNotification();
1387 application.Render();
1389 // Executes the idle callbacks added by the text control on the change of input style.
1390 application.RunIdles();
1392 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1393 if( gInputStyleChangedCallbackCalled )
1395 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1396 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1399 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1400 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1402 DALI_TEST_CHECK( inputStyleChangedSignal );
1404 gInputStyleChangedCallbackCalled = false;
1405 gInputStyleMask = TextEditor::InputStyle::NONE;
1406 inputStyleChangedSignal = false;
1408 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1410 Property::Map fontStyleMapSet;
1411 fontStyleMapSet.Insert( "weight", "thin" );
1412 fontStyleMapSet.Insert( "width", "condensed" );
1413 fontStyleMapSet.Insert( "slant", "italic" );
1415 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1416 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1417 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1419 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1420 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1421 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1422 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1424 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1426 // Render and notify
1427 application.SendNotification();
1428 application.Render();
1430 // Executes the idle callbacks added by the text control on the change of input style.
1431 application.RunIdles();
1433 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1434 DALI_TEST_CHECK( !inputStyleChangedSignal );
1436 // Create a tap event to touch the text editor.
1437 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1438 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1440 // Render and notify
1441 application.SendNotification();
1442 application.Render();
1444 // Executes the idle callbacks added by the text control on the change of input style.
1445 application.RunIdles();
1447 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1448 if( gInputStyleChangedCallbackCalled )
1450 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1451 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1452 TextEditor::InputStyle::POINT_SIZE |
1453 TextEditor::InputStyle::FONT_STYLE |
1454 TextEditor::InputStyle::LINE_SPACING |
1455 TextEditor::InputStyle::UNDERLINE |
1456 TextEditor::InputStyle::SHADOW |
1457 TextEditor::InputStyle::EMBOSS |
1458 TextEditor::InputStyle::OUTLINE ),
1461 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1462 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1464 DALI_TEST_CHECK( inputStyleChangedSignal );
1466 gInputStyleChangedCallbackCalled = false;
1467 gInputStyleMask = TextEditor::InputStyle::NONE;
1468 inputStyleChangedSignal = false;
1470 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1472 fontStyleMapSet.Clear();
1473 fontStyleMapSet.Insert( "weight", "black" );
1474 fontStyleMapSet.Insert( "width", "expanded" );
1475 fontStyleMapSet.Insert( "slant", "oblique" );
1477 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1479 // Create a tap event to touch the text editor.
1480 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1481 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1483 // Render and notify
1484 application.SendNotification();
1485 application.Render();
1487 // Executes the idle callbacks added by the text control on the change of input style.
1488 application.RunIdles();
1490 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1491 if( gInputStyleChangedCallbackCalled )
1493 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1494 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1495 TextEditor::InputStyle::POINT_SIZE |
1496 TextEditor::InputStyle::FONT_STYLE ),
1499 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1500 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1502 DALI_TEST_CHECK( inputStyleChangedSignal );
1507 int utcDaliTextEditorEvent01(void)
1509 ToolkitTestApplication application;
1510 tet_infoline(" utcDaliTextEditorEvent01");
1512 // Creates a tap event. After creating a tap event the text editor should
1513 // have the focus and add text with key events should be possible.
1515 TextEditor editor = TextEditor::New();
1516 DALI_TEST_CHECK( editor );
1518 Stage::GetCurrent().Add( editor );
1520 editor.SetSize( 300.f, 50.f );
1521 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1522 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1524 // Avoid a crash when core load gl resources.
1525 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1527 // Render and notify
1528 application.SendNotification();
1529 application.Render();
1531 // Add a key event but as the text editor has not the focus it should do nothing.
1532 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1534 // Render and notify
1535 application.SendNotification();
1536 application.Render();
1538 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1540 // Create a tap event to touch the text editor.
1541 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1542 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1544 // Render and notify
1545 application.SendNotification();
1546 application.Render();
1548 // Now the text editor has the focus, so it can handle the key events.
1549 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1550 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1552 // Render and notify
1553 application.SendNotification();
1554 application.Render();
1556 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1558 // Create a second text editor and send key events to it.
1559 TextEditor editor2 = TextEditor::New();
1561 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1562 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1563 editor2.SetSize( 100.f, 100.f );
1564 editor2.SetPosition( 100.f, 100.f );
1566 Stage::GetCurrent().Add( editor2 );
1568 // Render and notify
1569 application.SendNotification();
1570 application.Render();
1572 // Create a tap event on the second text editor.
1573 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1574 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // The second text editor has the focus. It should handle the key events.
1581 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1582 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1584 // Render and notify
1585 application.SendNotification();
1586 application.Render();
1588 // Check the text has been added to the second text editor.
1589 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1594 int utcDaliTextEditorEvent02(void)
1596 ToolkitTestApplication application;
1597 tet_infoline(" utcDaliTextEditorEvent02");
1599 // Checks if the right number of actors are created.
1601 TextEditor editor = TextEditor::New();
1602 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1603 DALI_TEST_CHECK( editor );
1605 Stage::GetCurrent().Add( editor );
1607 editor.SetSize( 300.f, 50.f );
1608 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1609 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1611 // Avoid a crash when core load gl resources.
1612 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1614 // Render and notify
1615 application.SendNotification();
1616 application.Render();
1618 // Check there are the expected number of children (the stencil).
1619 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1621 Actor stencil = editor.GetChildAt( 0u );
1623 // Create a tap event to touch the text editor.
1624 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1625 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1627 // Render and notify
1628 application.SendNotification();
1629 application.Render();
1631 Actor layer = editor.GetChildAt( 1u );
1632 DALI_TEST_CHECK( layer.IsLayer() );
1634 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1635 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1637 // Now the text editor has the focus, so it can handle the key events.
1638 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1639 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1641 // Render and notify
1642 application.SendNotification();
1643 application.Render();
1645 // Checks the cursor and the renderer have been created.
1646 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1647 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1649 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1650 DALI_TEST_CHECK( cursor );
1652 // The stencil actor has a container with all the actors which contain the text renderers.
1653 Actor container = stencil.GetChildAt( 0u );
1654 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1656 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1657 DALI_TEST_CHECK( renderer );
1660 // Move the cursor and check the position changes.
1661 Vector3 position1 = cursor.GetCurrentPosition();
1663 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1664 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1666 // Render and notify
1667 application.SendNotification();
1668 application.Render();
1670 Vector3 position2 = cursor.GetCurrentPosition();
1672 DALI_TEST_CHECK( position2.x < position1.x );
1674 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1675 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1677 // Render and notify
1678 application.SendNotification();
1679 application.Render();
1681 Vector3 position3 = cursor.GetCurrentPosition();
1683 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1685 // Send some taps and check the cursor positions.
1687 // Try to tap at the beginning.
1688 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1689 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1691 // Render and notify
1692 application.SendNotification();
1693 application.Render();
1695 // Cursor position should be the same than position1.
1696 Vector3 position4 = cursor.GetCurrentPosition();
1698 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1700 // Tap away from the start position.
1701 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1702 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1704 // Render and notify
1705 application.SendNotification();
1706 application.Render();
1708 Vector3 position5 = cursor.GetCurrentPosition();
1710 DALI_TEST_CHECK( position5.x > position4.x );
1712 // Remove all the text.
1713 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1714 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1715 editor.SetProperty( TextEditor::Property::TEXT, "" );
1717 // Render and notify
1718 application.SendNotification();
1719 application.Render();
1721 // Cursor position should be the same than position2.
1722 Vector3 position6 = cursor.GetCurrentPosition();
1724 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1726 // Should not be a renderer.
1727 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1732 int utcDaliTextEditorEvent03(void)
1734 ToolkitTestApplication application;
1735 tet_infoline(" utcDaliTextEditorEvent03");
1737 // Checks if the highlight actor is created.
1739 TextEditor editor = TextEditor::New();
1740 DALI_TEST_CHECK( editor );
1742 Stage::GetCurrent().Add( editor );
1744 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1745 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1746 editor.SetSize( 30.f, 50.f );
1747 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1748 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1750 // Avoid a crash when core load gl resources.
1751 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1753 // Render and notify
1754 application.SendNotification();
1755 application.Render();
1757 // Send some taps and check text controller with clipboard window
1758 Dali::Clipboard clipboard = Clipboard::Get();
1759 clipboard.ShowClipboard();
1760 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1761 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1762 clipboard.HideClipboard();
1764 // Render and notify
1765 application.SendNotification();
1766 application.Render();
1768 // Tap first to get the focus.
1769 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1770 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1772 // Render and notify
1773 application.SendNotification();
1774 application.Render();
1776 // Double tap to select a word.
1777 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1778 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1780 // Render and notify
1781 application.SendNotification();
1782 application.Render();
1784 // The stencil actor should have two actors: the renderer and the highlight actor.
1785 Actor stencil = editor.GetChildAt( 0u );
1787 // Highlight needs to be drawn before text, so should come first in child order
1788 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1789 DALI_TEST_CHECK( highlight );
1791 // The stencil actor has a container with all the actors which contain the text renderers.
1792 Actor container = stencil.GetChildAt( 1u );
1793 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1795 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1796 DALI_TEST_CHECK( renderer );
1799 // Double tap out of bounds
1800 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1801 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1803 // Render and notify
1804 application.SendNotification();
1805 application.Render();
1807 // The stencil actor should have one actors: the renderer actor.
1808 stencil = editor.GetChildAt( 0u );
1810 // The stencil actor has a container with all the actors which contain the text renderers.
1811 container = stencil.GetChildAt( 0u );
1812 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1814 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1815 DALI_TEST_CHECK( renderer );
1819 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1820 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1822 // Render and notify
1823 application.SendNotification();
1824 application.Render();
1829 int utcDaliTextEditorEvent04(void)
1831 ToolkitTestApplication application;
1832 tet_infoline(" utcDaliTextEditorEvent04");
1834 // Checks if the highlight actor is created.
1836 TextEditor editor = TextEditor::New();
1837 DALI_TEST_CHECK( editor );
1839 Stage::GetCurrent().Add( editor );
1841 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1842 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1843 editor.SetSize( 100.f, 50.f );
1844 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1845 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1847 // Avoid a crash when core load gl resources.
1848 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1850 // Render and notify
1851 application.SendNotification();
1852 application.Render();
1854 // Tap on the text editor
1855 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1856 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1862 // Move at the end of the text.
1863 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1864 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 // Render and notify
1867 application.SendNotification();
1868 application.Render();
1870 for( unsigned int index = 0u; index < 10u; ++index )
1872 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1873 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1881 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1883 // Render and notify
1884 application.SendNotification();
1885 application.Render();
1887 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1889 // Add some key events
1890 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1891 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1893 // Render and notify
1894 application.SendNotification();
1895 application.Render();
1897 for( unsigned int index = 0u; index < 10u; ++index )
1899 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1900 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1908 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1910 // Render and notify
1911 application.SendNotification();
1912 application.Render();
1914 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1919 int utcDaliTextEditorEvent05(void)
1921 ToolkitTestApplication application;
1922 tet_infoline(" utcDaliTextEditorEvent05");
1924 // Checks if the highlight actor is created.
1926 TextEditor editor = TextEditor::New();
1927 DALI_TEST_CHECK( editor );
1929 Stage::GetCurrent().Add( editor );
1931 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1932 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1933 editor.SetSize( 50.f, 50.f );
1934 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1935 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1936 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1937 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1938 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1939 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1940 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1942 // Avoid a crash when core load gl resources.
1943 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 // Tap on the text editor
1950 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1951 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1953 // Render and notify
1954 application.SendNotification();
1955 application.Render();
1957 // Move at the end of the text.
1958 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1959 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1961 // Render and notify
1962 application.SendNotification();
1963 application.Render();
1965 for( unsigned int index = 0u; index < 10u; ++index )
1968 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1970 // Render and notify
1971 application.SendNotification();
1972 application.Render();
1974 // Modify duration after scroll is enabled
1975 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1977 // Continuous scroll left to increase coverage
1978 for( unsigned int index = 0u; index < 10u; ++index )
1980 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1982 // Render and notify
1983 application.SendNotification();
1984 application.Render();
1986 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1987 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1988 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1989 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1990 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1992 // Press Escape to increase coverage
1993 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1994 application.SendNotification();
1995 application.Render();
1997 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
2002 int utcDaliTextEditorEvent06(void)
2004 ToolkitTestApplication application;
2005 tet_infoline(" utcDaliTextEditorEvent06");
2007 // Checks if the highlight actor is created.
2009 TextEditor editor = TextEditor::New();
2010 DALI_TEST_CHECK( editor );
2012 Stage::GetCurrent().Add( editor );
2014 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2015 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2016 editor.SetSize( 100.f, 50.f );
2017 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2018 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2020 // Avoid a crash when core load gl resources.
2021 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2023 // Render and notify
2024 application.SendNotification();
2025 application.Render();
2027 // Tap on the text editor
2028 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2029 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 // Move to seconds line of the text.
2036 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2038 // Render and notify
2039 application.SendNotification();
2040 application.Render();
2042 float layoutHeight = editor.GetHeightForWidth( 100.f );
2045 // Add another script characters ( glyph height is defferent )
2046 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2047 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2049 // Delete characters
2050 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2051 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2053 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2055 // Render and notify
2056 application.SendNotification();
2057 application.Render();
2059 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2062 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2063 application.SendNotification();
2064 application.Render();
2066 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2067 application.SendNotification();
2068 application.Render();
2070 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2071 application.SendNotification();
2072 application.Render();
2074 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2075 application.SendNotification();
2076 application.Render();
2078 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2079 application.SendNotification();
2080 application.Render();
2082 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2083 application.SendNotification();
2084 application.Render();
2086 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2087 application.SendNotification();
2088 application.Render();
2093 int utcDaliTextEditorEvent07(void)
2095 ToolkitTestApplication application;
2096 tet_infoline(" utcDaliTextEditorEvent07");
2098 // Checks if the highlight actor is created.
2100 TextEditor editor = TextEditor::New();
2101 DALI_TEST_CHECK( editor );
2103 Stage::GetCurrent().Add( editor );
2105 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2106 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2107 editor.SetSize( 100.f, 50.f );
2108 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2109 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2111 // Avoid a crash when core load gl resources.
2112 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2114 // Render and notify
2115 application.SendNotification();
2116 application.Render();
2118 // Tap on the text editor
2119 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2120 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Move to second line of the text.
2127 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 // Render and notify
2130 application.SendNotification();
2131 application.Render();
2133 // Select some text in the right of the current cursor position
2134 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2136 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2139 // Render and notify
2140 application.SendNotification();
2141 application.Render();
2143 // Cut the selected text
2144 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2145 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 ) );
2147 // Render and notify
2148 application.SendNotification();
2149 application.Render();
2151 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2153 // Select some text in the left of the current cursor position
2154 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2156 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2159 // Render and notify
2160 application.SendNotification();
2161 application.Render();
2163 // Copy the selected text
2164 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 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 ) );
2167 // Render and notify
2168 application.SendNotification();
2169 application.Render();
2171 // Move the cursor to the third line
2172 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2173 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 // Paste the selected text at the current cursor position
2180 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2181 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 ) );
2183 // Render and notify
2184 application.SendNotification();
2185 application.Render();
2187 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2190 // Disable Shift Selection
2191 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2193 // Test to select some text in the right of the current cursor position
2194 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2196 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2197 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // Cut the selected text
2204 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2205 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 ) );
2207 // Render and notify
2208 application.SendNotification();
2209 application.Render();
2211 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2212 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2214 // Test to select some text in the left of the current cursor position
2215 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2217 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // Copy the selected text
2225 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2226 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 ) );
2228 // Render and notify
2229 application.SendNotification();
2230 application.Render();
2232 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2233 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2238 int utcDaliTextEditorEvent08(void)
2240 ToolkitTestApplication application;
2241 tet_infoline(" utcDaliTextEditorEvent08");
2243 // Checks if the highlight actor is released correctly.
2245 TextEditor editor = TextEditor::New();
2246 DALI_TEST_CHECK( editor );
2248 Stage::GetCurrent().Add( editor );
2250 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2251 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2252 editor.SetSize( 100.f, 50.f );
2253 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2254 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2256 // Avoid a crash when core load gl resources.
2257 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 // Tap on the text editor
2264 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2265 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2267 // Render and notify
2268 application.SendNotification();
2269 application.Render();
2271 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2272 // Test to select some text in the left of the current cursor position
2273 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 // Render and notify
2279 application.SendNotification();
2280 application.Render();
2282 // Test to the left selection handle position and the right selection handle position
2283 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2285 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2286 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 // Render and notify
2289 application.SendNotification();
2290 application.Render();
2292 // Test to select full text in the left of the current cursor position
2293 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2300 // Render and notify
2301 application.SendNotification();
2302 application.Render();
2304 // Test to release the current full text selection
2305 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2306 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 // Render and notify
2309 application.SendNotification();
2310 application.Render();
2312 // Test to move the current cursor position correctly
2313 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2320 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 // Render and notify
2323 application.SendNotification();
2324 application.Render();
2326 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2328 // Test to select some text in the right of the current cursor position
2329 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2330 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2331 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2337 // Test the cursor position with right arrow key
2338 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2340 // Render and notify
2341 application.SendNotification();
2342 application.Render();
2345 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2347 // Render and notify
2348 application.SendNotification();
2349 application.Render();
2351 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2353 // Test to select some text in the left of the current cursor position
2354 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2357 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2358 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2364 // Test the cursor position with left arrow key
2365 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 // Render and notify
2368 application.SendNotification();
2369 application.Render();
2372 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2374 // Render and notify
2375 application.SendNotification();
2376 application.Render();
2378 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2380 // Test to select some text in the right of the current cursor position
2381 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2384 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2390 // Test the cursor position with left arrow key
2391 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2398 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2400 // Render and notify
2401 application.SendNotification();
2402 application.Render();
2404 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2406 // Test to select some text in the left of the current cursor position
2407 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2409 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2410 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2416 // Test the cursor position with right arrow key
2417 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2424 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2426 // Render and notify
2427 application.SendNotification();
2428 application.Render();
2430 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2435 int utcDaliTextEditorHandles(void)
2437 ToolkitTestApplication application;
2438 tet_infoline(" utcDaliTextEditorHandles");
2440 TextEditor editor = TextEditor::New();
2441 DALI_TEST_CHECK( editor );
2443 Stage::GetCurrent().Add( editor );
2445 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2446 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2447 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2448 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2450 Property::Map imagePropertyMap;
2451 imagePropertyMap["type"] = "BufferImage";
2452 imagePropertyMap["width"] = 40;
2453 imagePropertyMap["height"] = 40;
2455 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2456 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2457 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2458 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2460 editor.SetSize( 30.f, 500.f );
2461 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2462 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2464 // Avoid a crash when core load gl resources.
2465 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2467 // Render and notify
2468 application.SendNotification();
2469 application.Render();
2471 // Tap first to get the focus.
2472 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2473 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2475 // Render and notify
2476 application.SendNotification();
2477 application.Render();
2479 // Tap to create the grab handle.
2480 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2481 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2483 // Render and notify
2484 application.SendNotification();
2485 application.Render();
2487 // Get the active layer where the text's decoration is added.
2488 Actor activeLayer = editor.GetChildAt( 1u );
2490 // Get the handle's actor.
2491 Actor handle = activeLayer.GetChildAt( 1u );
2492 handle.SetSize( 100.f, 100.f );
2494 // Render and notify
2495 application.SendNotification();
2496 application.Render();
2498 // Touch the grab handle to set it as pressed.
2499 Vector2 touchPos( 10.0f, 50.0f );
2500 Dali::Integration::TouchEvent event;
2501 event = Dali::Integration::TouchEvent();
2502 event.AddPoint( GetPointDownInside( touchPos ) );
2503 application.ProcessEvent( event );
2505 // Render and notify
2506 application.SendNotification();
2507 application.Render();
2509 // drag grab handle right
2510 SendPan(application, Gesture::Possible, touchPos);
2511 SendPan(application, Gesture::Started, touchPos);
2513 Wait(application, 100);
2515 for(int i = 0;i<20;i++)
2517 SendPan(application, Gesture::Continuing, touchPos);
2522 SendPan(application, Gesture::Finished, touchPos);
2525 // Release the grab handle.
2526 event = Dali::Integration::TouchEvent();
2527 event.AddPoint( GetPointUpInside( touchPos ) );
2528 application.ProcessEvent( event );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Tap first to get the focus.
2535 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2536 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2542 // Double tap to select a word and create the selection handles.
2543 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2544 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2546 // Render and notify
2547 application.SendNotification();
2548 application.Render();
2550 touchPos = Vector2( 10.0f, 50.0f );
2552 // Touch the left selection handle to set it as pressed.
2553 event = Dali::Integration::TouchEvent();
2554 event.AddPoint( GetPointDownInside( touchPos ) );
2555 application.ProcessEvent( event );
2557 // Render and notify
2558 application.SendNotification();
2559 application.Render();
2561 // drag the left selection handle right
2562 SendPan(application, Gesture::Possible, touchPos);
2563 SendPan(application, Gesture::Started, touchPos);
2565 Wait(application, 100);
2567 for(int i = 0;i<20;i++)
2569 SendPan(application, Gesture::Continuing, touchPos);
2574 SendPan(application, Gesture::Finished, touchPos);
2577 // Release the left selection handle.
2578 event = Dali::Integration::TouchEvent();
2579 event.AddPoint( GetPointUpInside( touchPos ) );
2580 application.ProcessEvent( event );
2582 // Render and notify
2583 application.SendNotification();
2584 application.Render();
2589 int utcDaliTextEditorUnderPropertyStringP(void)
2591 ToolkitTestApplication application;
2592 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2593 TextEditor editor = TextEditor::New();
2594 DALI_TEST_CHECK( editor );
2596 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2598 Stage::GetCurrent().Add( editor );
2600 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2601 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2603 tet_infoline("Set underline settings with a map");
2604 // Check the input underline property
2605 Property::Map underlineMapSet;
2606 Property::Map underlineMapGet;
2607 underlineMapSet.Insert( "enable", "true" );
2608 underlineMapSet.Insert( "color", "blue" );
2609 underlineMapSet.Insert( "height", "2" );
2611 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2612 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2613 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2614 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2616 tet_infoline("Set underline settings with a string");
2617 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2618 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2621 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2623 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2624 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2625 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2626 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2628 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2633 int utcDaliTextEditorShadowPropertyStringP(void)
2635 ToolkitTestApplication application;
2636 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2638 TextEditor editor = TextEditor::New();
2640 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2642 Stage::GetCurrent().Add( editor );
2644 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2646 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2650 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2655 int utcDaliTextEditorFontStylePropertyStringP(void)
2657 ToolkitTestApplication application;
2658 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2660 TextEditor editor = TextEditor::New();
2662 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2664 Stage::GetCurrent().Add( editor );
2666 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2668 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2672 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2677 int utcDaliTextEditorGetPropertyLinecountP(void)
2679 ToolkitTestApplication application;
2681 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2685 TextEditor editor = TextEditor::New();
2686 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2687 editor.SetProperty( TextEditor::Property::TEXT,
2688 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2690 Stage::GetCurrent().Add( editor );
2692 editor.SetSize( 100.0f, 100.0f );
2693 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2694 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2696 editor.SetSize( 50.0f, 100.0f );
2697 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2698 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2703 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2706 ToolkitTestApplication application;
2707 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2709 TextEditor editor = TextEditor::New();
2710 DALI_TEST_CHECK( editor );
2712 Stage::GetCurrent().Add( editor );
2714 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2715 editor.SetSize( 50.f, 50.f );
2716 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2717 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2718 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2719 editor.SetKeyboardFocusable(true);
2721 bool startedCalled = false;
2722 bool finishedCalled = false;
2724 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2725 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2727 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2729 // Render and notify
2730 application.SendNotification();
2731 application.Render();
2733 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2734 application.SendNotification();
2735 application.Render(6000);
2737 application.SendNotification();
2738 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2739 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2744 int UtcDaliToolkitTextEditorTextWrapMode(void)
2746 ToolkitTestApplication application;
2747 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2751 TextEditor editor = TextEditor::New();
2752 editor.SetSize( 150.0f, 300.f );
2753 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2755 Stage::GetCurrent().Add( editor );
2757 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2758 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2760 application.SendNotification();
2761 application.Render();
2763 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2764 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2766 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2767 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2769 application.SendNotification();
2770 application.Render();
2772 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2773 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2775 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2776 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2778 application.SendNotification();
2779 application.Render();
2781 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2782 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2784 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2785 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2787 application.SendNotification();
2788 application.Render();
2790 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2791 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2796 int UtcDaliTextEditorSetPaddingProperty(void)
2798 ToolkitTestApplication application;
2799 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2801 TextEditor editor = TextEditor::New();
2802 DALI_TEST_CHECK( editor );
2803 editor.SetSize( 300.f, 50.f );
2804 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2805 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2806 Stage::GetCurrent().Add( editor );
2808 application.SendNotification();
2809 application.Render();
2811 Vector3 originalSize = editor.GetNaturalSize();
2813 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2815 application.SendNotification();
2816 application.Render();
2818 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2820 Vector3 paddingAddedSize = editor.GetNaturalSize();
2822 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2824 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2829 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2831 ToolkitTestApplication application;
2832 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2834 TextEditor editor = TextEditor::New();
2835 DALI_TEST_CHECK( editor );
2836 editor.SetSize( 300.f, 50.f );
2837 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2838 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2839 Stage::GetCurrent().Add( editor );
2841 application.SendNotification();
2842 application.Render();
2844 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2845 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2847 // Check the enable shift selection property
2848 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2849 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2851 application.SendNotification();
2852 application.Render();
2857 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2859 ToolkitTestApplication application;
2860 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2862 TextEditor editor = TextEditor::New();
2863 DALI_TEST_CHECK( editor );
2864 editor.SetSize( 300.f, 50.f );
2865 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2866 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2867 Stage::GetCurrent().Add( editor );
2869 application.SendNotification();
2870 application.Render();
2872 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2873 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2875 // Check the enable grab handle property
2876 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2877 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2879 application.SendNotification();
2880 application.Render();
2885 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2887 ToolkitTestApplication application;
2888 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2890 TextEditor editor = TextEditor::New();
2891 DALI_TEST_CHECK( editor );
2892 editor.SetSize( 300.f, 50.f );
2893 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2894 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2895 Stage::GetCurrent().Add( editor );
2897 application.SendNotification();
2898 application.Render();
2900 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2901 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2903 // Check the enable match system language direction property
2904 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2905 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2907 application.SendNotification();
2908 application.Render();
2913 int UtcDaliTextEditorGetInputMethodContext(void)
2915 ToolkitTestApplication application;
2916 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2918 TextEditor editor = TextEditor::New();
2919 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );