2 * Copyright (c) 2019 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 Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
108 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
110 const float RENDER_FRAME_INTERVAL = 16.66f;
112 const unsigned int DEFAULT_FONT_SIZE = 1152u;
113 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
115 const int KEY_A_CODE = 38;
116 const int KEY_D_CODE = 40;
117 const int KEY_C_CODE = 54;
118 const int KEY_V_CODE = 55;
119 const int KEY_X_CODE = 53;
120 const int KEY_WHITE_SPACE_CODE = 65;
122 const int KEY_SHIFT_MODIFIER = 257;
123 const int KEY_CONTROL_MODIFIER = 258;
125 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
127 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
129 static bool gTextChangedCallBackCalled;
130 static bool gInputStyleChangedCallbackCalled;
131 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
133 struct CallbackFunctor
135 CallbackFunctor(bool* callbackFlag)
136 : mCallbackFlag( callbackFlag )
142 *mCallbackFlag = true;
147 static void TestTextChangedCallback( TextEditor control )
149 tet_infoline(" TestTextChangedCallback");
151 gTextChangedCallBackCalled = true;
154 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
156 tet_infoline(" TestInputStyleChangedCallback");
158 gInputStyleChangedCallbackCalled = true;
159 gInputStyleMask = mask;
162 // Generate a TapGestureEvent to send to Core.
163 Integration::TapGestureEvent GenerateTap(
164 Gesture::State state,
165 unsigned int numberOfTaps,
166 unsigned int numberOfTouches,
169 Integration::TapGestureEvent tap( state );
171 tap.numberOfTaps = numberOfTaps;
172 tap.numberOfTouches = numberOfTouches;
178 Integration::LongPressGestureEvent GenerateLongPress(
179 Gesture::State state,
180 unsigned int numberOfTouches,
183 Integration::LongPressGestureEvent longPress( state );
185 longPress.numberOfTouches = numberOfTouches;
186 longPress.point = point;
190 // Generate a PanGestureEvent to send to Core
191 Integration::PanGestureEvent GeneratePan( Gesture::State state,
192 const Vector2& previousPosition,
193 const Vector2& currentPosition,
194 unsigned long timeDelta,
195 unsigned int numberOfTouches = 1u )
197 Integration::PanGestureEvent pan(state);
199 pan.previousPosition = previousPosition;
200 pan.currentPosition = currentPosition;
201 pan.timeDelta = timeDelta;
202 pan.numberOfTouches = numberOfTouches;
207 // Generate a KeyEvent to send to Core.
208 Integration::KeyEvent GenerateKey( const std::string& keyName,
209 const std::string& logicalKey,
210 const std::string& keyString,
213 unsigned long timeStamp,
214 const Integration::KeyEvent::State& keyState,
215 const std::string& compose = "",
216 const std::string& deviceName = DEFAULT_DEVICE_NAME,
217 const Device::Class::Type& deviceClass = Device::Class::NONE,
218 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
220 return Integration::KeyEvent( keyName,
234 * Helper to generate PanGestureEvent
236 * @param[in] application Application instance
237 * @param[in] state The Gesture State
238 * @param[in] pos The current position of touch.
240 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
244 if( (state == Gesture::Started) ||
245 (state == Gesture::Possible) )
251 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
258 * Simulate time passed by.
260 * @note this will always process at least 1 frame (1/60 sec)
262 * @param application Test application instance
263 * @param duration Time to pass in milliseconds.
264 * @return The actual time passed in milliseconds
266 static int Wait(ToolkitTestApplication& application, int duration = 0)
270 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
272 application.SendNotification();
273 application.Render(RENDER_FRAME_INTERVAL);
274 time += RENDER_FRAME_INTERVAL;
280 Dali::Integration::Point GetPointDownInside( Vector2& pos )
282 Dali::Integration::Point point;
283 point.SetState( PointState::DOWN );
284 point.SetScreenPosition( pos );
288 Dali::Integration::Point GetPointUpInside( Vector2& pos )
290 Dali::Integration::Point point;
291 point.SetState( PointState::UP );
292 point.SetScreenPosition( pos );
296 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
298 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
300 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
302 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
304 Property::Value* valueSet = NULL;
305 if ( valueGet.first.type == Property::Key::INDEX )
307 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
311 // Get Key is a string so searching Set Map for a string key
312 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
315 if( NULL != valueSet )
317 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
319 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
322 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
324 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
327 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
329 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
332 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
334 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
337 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
339 Vector2 vector2Get = valueGet.second.Get<Vector2>();
340 Vector2 vector2Set = valueSet->Get<Vector2>();
341 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
344 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
346 Vector4 vector4Get = valueGet.second.Get<Vector4>();
347 Vector4 vector4Set = valueSet->Get<Vector4>();
348 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 );
354 if ( valueGet.first.type == Property::Key::INDEX )
356 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
360 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
370 class ScrollStateChangeCallback : public Dali::ConnectionTracker
373 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
374 : mStartedCalled( startedCalled ),
375 mFinishedCalled( finishedCalled )
379 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
381 if( type == TextEditor::Scroll::STARTED )
383 mStartedCalled = true;
385 else if( type == TextEditor::Scroll::FINISHED )
387 mFinishedCalled = true;
391 bool& mStartedCalled;
392 bool& mFinishedCalled;
397 int UtcDaliToolkitTextEditorConstructorP(void)
399 ToolkitTestApplication application;
400 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
401 TextEditor textEditor;
402 DALI_TEST_CHECK( !textEditor );
406 int UtcDaliToolkitTextEditorNewP(void)
408 ToolkitTestApplication application;
409 tet_infoline(" UtcDaliToolkitTextEditorNewP");
410 TextEditor textEditor = TextEditor::New();
411 DALI_TEST_CHECK( textEditor );
415 int UtcDaliToolkitTextEditorDownCastP(void)
417 ToolkitTestApplication application;
418 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
419 TextEditor textEditor1 = TextEditor::New();
420 BaseHandle object( textEditor1 );
422 TextEditor textEditor2 = TextEditor::DownCast( object );
423 DALI_TEST_CHECK( textEditor2 );
425 TextEditor textEditor3 = DownCast< TextEditor >( object );
426 DALI_TEST_CHECK( textEditor3 );
430 int UtcDaliToolkitTextEditorDownCastN(void)
432 ToolkitTestApplication application;
433 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
434 BaseHandle uninitializedObject;
435 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
436 DALI_TEST_CHECK( !textEditor1 );
438 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
439 DALI_TEST_CHECK( !textEditor2 );
443 int UtcDaliToolkitTextEditorCopyConstructorP(void)
445 ToolkitTestApplication application;
446 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
447 TextEditor textEditor = TextEditor::New();
448 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
450 TextEditor copy( textEditor );
451 DALI_TEST_CHECK( copy );
452 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
456 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
458 ToolkitTestApplication application;
459 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
460 TextEditor textEditor = TextEditor::New();
461 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
463 TextEditor copy = textEditor;
464 DALI_TEST_CHECK( copy );
465 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
469 int UtcDaliTextEditorNewP(void)
471 ToolkitTestApplication application;
472 tet_infoline(" UtcDaliToolkitTextEditorNewP");
473 TextEditor textEditor = TextEditor::New();
474 DALI_TEST_CHECK( textEditor );
478 // Positive test case for a method
479 int UtcDaliTextEditorGetPropertyP(void)
481 ToolkitTestApplication application;
482 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
483 TextEditor editor = TextEditor::New();
484 DALI_TEST_CHECK( editor );
486 // Check Property Indices are correct
487 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
488 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
546 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
549 Property::Map imageMap;
550 imageMap[mapKey] =mapValue;
552 editor.SetProperty( property , imageMap );
553 Property::Value propValue = editor.GetProperty( property );
554 Property::Map* resultMap = propValue.GetMap();
556 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
564 // Positive test case for a method
565 int UtcDaliTextEditorSetPropertyP(void)
567 ToolkitTestApplication application;
568 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
569 TextEditor editor = TextEditor::New();
570 DALI_TEST_CHECK( editor );
571 Stage::GetCurrent().Add( editor );
573 // Note - we can't check the defaults since the stylesheets are platform-specific
575 // Check the render backend property.
576 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
577 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
579 // Check text property.
580 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
581 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
583 // Check text's color property
584 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
585 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
587 // Check font properties.
588 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
589 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
591 Property::Map fontStyleMapSet;
592 Property::Map fontStyleMapGet;
593 Property::Value* slantValue = NULL;
595 fontStyleMapSet.Insert( "weight", "bold" );
596 fontStyleMapSet.Insert( "width", "condensed" );
597 fontStyleMapSet.Insert( "slant", "italic" );
599 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
600 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
601 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
602 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
604 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
605 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
608 fontStyleMapSet.Clear();
609 fontStyleMapSet.Insert( "weight", "normal" );
610 fontStyleMapSet.Insert( "slant", "oblique" );
611 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
612 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
613 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
614 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
616 fontStyleMapSet.Clear();
617 fontStyleMapSet.Insert( "slant", "roman" );
618 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
619 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
621 // Replace 'roman' for 'normal'.
622 slantValue = fontStyleMapGet.Find( "slant" );
623 if( NULL != slantValue )
625 if( "normal" == slantValue->Get<std::string>() )
627 fontStyleMapGet["slant"] = "roman";
630 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
631 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
633 fontStyleMapSet.Clear();
635 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
636 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
637 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
638 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
640 // Check that the Alignment properties can be correctly set
641 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
642 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
644 // Check scroll properties.
645 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
646 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
647 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
648 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
650 // Check cursor properties
651 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
652 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
653 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
654 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
656 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
657 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
658 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
659 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
660 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
661 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
662 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
663 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
665 // Check handle images
666 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
667 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
668 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
669 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
670 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
672 // Check handle images
673 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
677 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
680 // Check the highlight color
681 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
682 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
684 // Decoration bounding box
685 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
686 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
688 // Check the enable markup property.
689 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
690 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
691 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
693 // Check input color property.
694 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
695 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
697 // Check input font properties.
698 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
699 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
701 fontStyleMapSet.Clear();
702 fontStyleMapSet.Insert( "weight", "bold" );
703 fontStyleMapSet.Insert( "width", "condensed" );
704 fontStyleMapSet.Insert( "slant", "italic" );
706 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
707 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
708 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
709 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
711 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
712 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
714 // Reset input font style.
715 fontStyleMapSet.Clear();
716 fontStyleMapSet.Insert( "weight", "normal" );
717 fontStyleMapSet.Insert( "slant", "oblique" );
719 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
720 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
721 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
722 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
724 fontStyleMapSet.Clear();
725 fontStyleMapSet.Insert( "slant", "roman" );
727 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
728 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
730 // Replace 'roman' for 'normal'.
731 slantValue = fontStyleMapGet.Find( "slant" );
732 if( NULL != slantValue )
734 if( "normal" == slantValue->Get<std::string>() )
736 fontStyleMapGet["slant"] = "roman";
739 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
740 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
742 fontStyleMapSet.Clear();
744 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
745 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
746 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
747 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
749 // Check the line spacing property
750 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
751 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
752 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 // Check the input line spacing property
755 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
756 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
757 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
759 // Check the underline property
761 Property::Map underlineMapSet;
762 Property::Map underlineMapGet;
764 underlineMapSet.Insert( "enable", true );
765 underlineMapSet.Insert( "color", Color::RED );
766 underlineMapSet.Insert( "height", 1 );
768 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
770 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
771 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
772 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
774 // Check the input underline property
775 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
776 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
778 // Check the shadow property
779 Property::Map shadowMapSet;
780 Property::Map shadowMapGet;
782 shadowMapSet.Insert( "color", Color::GREEN );
783 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
784 shadowMapSet.Insert( "blurRadius", 3.0f );
786 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
788 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
789 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
790 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
792 // Check the input shadow property
793 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
794 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
796 // Check the emboss property
797 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
798 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
800 // Check the input emboss property
801 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
802 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
804 // Check the outline property
806 // Test string type first
807 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
808 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
809 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
811 // Then test the property map type
812 Property::Map outlineMapSet;
813 Property::Map outlineMapGet;
815 outlineMapSet["color"] = Color::RED;
816 outlineMapSet["width"] = 2.0f;
818 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
820 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
821 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
822 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
824 // Check the input outline property
825 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
826 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
828 // Check the smooth scroll property
829 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
830 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
831 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
833 // Check the smooth scroll duration property
834 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
835 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
837 // Check the scroll bar property
838 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
839 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
840 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
842 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
843 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
844 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
845 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
847 // Check the pixel size of font
848 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
849 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
851 // Check placeholder text properties.
852 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
853 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
855 // Check placeholder text's color property.
856 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
857 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
859 // Check the enable selection property
860 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
861 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
863 // Check the placeholder property with pixel size
864 Property::Map placeholderPixelSizeMapSet;
865 Property::Map placeholderPixelSizeMapGet;
866 Property::Map placeholderFontstyleMap;
867 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
868 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
869 placeholderPixelSizeMapSet["color"] = Color::BLUE;
870 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
871 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
873 placeholderFontstyleMap.Insert( "weight", "bold" );
874 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
875 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
877 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
878 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
880 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
881 Property::Map placeholderConversionMap;
882 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
883 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
884 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
885 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
886 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
887 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
889 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
891 // Check the placeholder property with point size
892 Property::Map placeholderMapSet;
893 Property::Map placeholderMapGet;
894 placeholderMapSet["text"] = "Setting Placeholder Text";
895 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
896 placeholderMapSet["color"] = Color::RED;
897 placeholderMapSet["fontFamily"] = "Arial";
898 placeholderMapSet["pointSize"] = 12.0f;
899 // Check the placeholder font style property
900 placeholderFontstyleMap.Clear();
902 placeholderFontstyleMap.Insert( "weight", "bold" );
903 placeholderFontstyleMap.Insert( "width", "condensed" );
904 placeholderFontstyleMap.Insert( "slant", "italic" );
905 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
906 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
908 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
909 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
911 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
912 placeholderConversionMap.Clear();
913 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
914 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
915 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
916 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
917 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
918 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
919 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
922 placeholderFontstyleMap.Clear();
923 placeholderFontstyleMap.Insert( "weight", "normal" );
924 placeholderFontstyleMap.Insert( "slant", "oblique" );
925 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
926 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
928 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
929 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
930 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
931 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
933 placeholderFontstyleMap.Clear();
934 placeholderFontstyleMap.Insert( "slant", "roman" );
935 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
936 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
938 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
940 placeholderFontstyleMap.Clear();
941 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
943 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
944 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
945 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
946 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
947 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
949 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
950 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
952 application.SendNotification();
953 application.Render();
958 // Positive Atlas Text Renderer test
959 int utcDaliTextEditorAtlasRenderP(void)
961 ToolkitTestApplication application;
962 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
963 StyleManager styleManager = StyleManager::Get();
964 styleManager.ApplyDefaultTheme();
965 TextEditor editor = TextEditor::New();
966 DALI_TEST_CHECK( editor );
968 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
970 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
972 Stage::GetCurrent().Add( editor );
976 // Render some text with the shared atlas backend
977 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
978 application.SendNotification();
979 application.Render();
983 tet_result(TET_FAIL);
988 // Positive test for the textChanged signal.
989 int utcDaliTextEditorTextChangedP(void)
991 ToolkitTestApplication application;
992 tet_infoline(" utcDaliTextEditorTextChangedP");
993 TextEditor editor = TextEditor::New();
994 DALI_TEST_CHECK( editor );
996 Stage::GetCurrent().Add( editor );
998 // connect to the text changed signal.
999 ConnectionTracker* testTracker = new ConnectionTracker();
1000 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1001 bool textChangedSignal = false;
1002 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1004 gTextChangedCallBackCalled = false;
1005 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1006 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1007 DALI_TEST_CHECK( textChangedSignal );
1009 application.SendNotification();
1011 editor.SetKeyInputFocus();
1013 gTextChangedCallBackCalled = false;
1014 application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1015 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1020 int utcDaliTextEditorInputStyleChanged01(void)
1022 ToolkitTestApplication application;
1023 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1025 // The text-editor emits signals when the input style changes. These changes of style are
1026 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1027 // can't be emitted during the size negotiation as the callbacks may update the UI.
1028 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1029 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1030 application.CreateAdaptor();
1034 char* pathNamePtr = get_current_dir_name();
1035 const std::string pathName( pathNamePtr );
1036 free( pathNamePtr );
1038 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1039 fontClient.SetDpi( 93u, 93u );
1041 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1042 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1044 TextEditor editor = TextEditor::New();
1045 DALI_TEST_CHECK( editor );
1048 editor.SetSize( 300.f, 50.f );
1049 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1050 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1052 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1053 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1055 // connect to the text changed signal.
1056 ConnectionTracker* testTracker = new ConnectionTracker();
1057 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1058 bool inputStyleChangedSignal = false;
1059 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1061 Stage::GetCurrent().Add( editor );
1063 // Render and notify
1064 application.SendNotification();
1065 application.Render();
1067 // Executes the idle callbacks added by the text control on the change of input style.
1068 application.RunIdles();
1070 gInputStyleChangedCallbackCalled = false;
1071 gInputStyleMask = TextEditor::InputStyle::NONE;
1072 inputStyleChangedSignal = false;
1074 // Create a tap event to touch the text editor.
1075 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1076 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1078 // Render and notify
1079 application.SendNotification();
1080 application.Render();
1082 // Executes the idle callbacks added by the text control on the change of input style.
1083 application.RunIdles();
1085 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1086 if( gInputStyleChangedCallbackCalled )
1088 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1090 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1091 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1093 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1094 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1096 DALI_TEST_CHECK( inputStyleChangedSignal );
1098 gInputStyleChangedCallbackCalled = false;
1099 gInputStyleMask = TextEditor::InputStyle::NONE;
1100 inputStyleChangedSignal = false;
1102 // Create a tap event to touch the text editor.
1103 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1104 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1106 // Render and notify
1107 application.SendNotification();
1108 application.Render();
1110 // Executes the idle callbacks added by the text control on the change of input style.
1111 application.RunIdles();
1113 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1114 DALI_TEST_CHECK( !inputStyleChangedSignal );
1116 gInputStyleChangedCallbackCalled = false;
1117 gInputStyleMask = TextEditor::InputStyle::NONE;
1118 inputStyleChangedSignal = false;
1120 // Create a tap event to touch the text editor.
1121 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1122 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1124 // Render and notify
1125 application.SendNotification();
1126 application.Render();
1128 // Executes the idle callbacks added by the text control on the change of input style.
1129 application.RunIdles();
1131 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1132 if( gInputStyleChangedCallbackCalled )
1134 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1136 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1137 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1139 DALI_TEST_CHECK( inputStyleChangedSignal );
1141 gInputStyleChangedCallbackCalled = false;
1142 gInputStyleMask = TextEditor::InputStyle::NONE;
1143 inputStyleChangedSignal = false;
1145 // Create a tap event to touch the text editor.
1146 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1147 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1149 // Render and notify
1150 application.SendNotification();
1151 application.Render();
1153 // Executes the idle callbacks added by the text control on the change of input style.
1154 application.RunIdles();
1156 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1157 if( gInputStyleChangedCallbackCalled )
1159 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1161 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1162 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1164 Property::Map fontStyleMapSet;
1165 Property::Map fontStyleMapGet;
1167 fontStyleMapSet.Insert( "weight", "bold" );
1169 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1170 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1171 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1173 DALI_TEST_CHECK( inputStyleChangedSignal );
1175 gInputStyleChangedCallbackCalled = false;
1176 gInputStyleMask = TextEditor::InputStyle::NONE;
1177 inputStyleChangedSignal = false;
1179 // Create a tap event to touch the text editor.
1180 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1181 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1183 // Render and notify
1184 application.SendNotification();
1185 application.Render();
1187 // Executes the idle callbacks added by the text control on the change of input style.
1188 application.RunIdles();
1190 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1191 DALI_TEST_CHECK( !inputStyleChangedSignal );
1193 gInputStyleChangedCallbackCalled = false;
1194 gInputStyleMask = TextEditor::InputStyle::NONE;
1195 inputStyleChangedSignal = false;
1197 // Create a tap event to touch the text editor.
1198 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1199 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1201 // Render and notify
1202 application.SendNotification();
1203 application.Render();
1205 // Executes the idle callbacks added by the text control on the change of input style.
1206 application.RunIdles();
1208 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1209 if( gInputStyleChangedCallbackCalled )
1211 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1213 Property::Map fontStyleMapSet;
1214 Property::Map fontStyleMapGet;
1216 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1217 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1218 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1220 DALI_TEST_CHECK( inputStyleChangedSignal );
1222 gInputStyleChangedCallbackCalled = false;
1223 gInputStyleMask = TextEditor::InputStyle::NONE;
1224 inputStyleChangedSignal = false;
1226 // Create a tap event to touch the text editor.
1227 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1228 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1230 // Render and notify
1231 application.SendNotification();
1232 application.Render();
1234 // Executes the idle callbacks added by the text control on the change of input style.
1235 application.RunIdles();
1237 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1238 DALI_TEST_CHECK( !inputStyleChangedSignal );
1243 int utcDaliTextEditorInputStyleChanged02(void)
1245 ToolkitTestApplication application;
1246 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1248 // The text-editor emits signals when the input style changes. These changes of style are
1249 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1250 // can't be emitted during the size negotiation as the callbacks may update the UI.
1251 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1252 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1253 application.CreateAdaptor();
1257 char* pathNamePtr = get_current_dir_name();
1258 const std::string pathName( pathNamePtr );
1259 free( pathNamePtr );
1261 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1262 fontClient.SetDpi( 93u, 93u );
1264 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1265 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1267 TextEditor editor = TextEditor::New();
1268 DALI_TEST_CHECK( editor );
1271 editor.SetSize( 300.f, 50.f );
1272 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1273 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1275 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1276 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>" );
1278 // connect to the text changed signal.
1279 ConnectionTracker* testTracker = new ConnectionTracker();
1280 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1281 bool inputStyleChangedSignal = false;
1282 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1284 Stage::GetCurrent().Add( editor );
1286 // Render and notify
1287 application.SendNotification();
1288 application.Render();
1290 // Executes the idle callbacks added by the text control on the change of input style.
1291 application.RunIdles();
1293 gInputStyleChangedCallbackCalled = false;
1294 gInputStyleMask = TextEditor::InputStyle::NONE;
1295 inputStyleChangedSignal = false;
1297 // Create a tap event to touch the text editor.
1298 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1299 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1300 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1301 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1303 // Render and notify
1304 application.SendNotification();
1305 application.Render();
1307 // Executes the idle callbacks added by the text control on the change of input style.
1308 application.RunIdles();
1310 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1311 if( gInputStyleChangedCallbackCalled )
1313 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1314 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1315 TextEditor::InputStyle::POINT_SIZE |
1316 TextEditor::InputStyle::COLOR ),
1319 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1320 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1322 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1323 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1325 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1326 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1328 DALI_TEST_CHECK( inputStyleChangedSignal );
1330 gInputStyleChangedCallbackCalled = false;
1331 gInputStyleMask = TextEditor::InputStyle::NONE;
1332 inputStyleChangedSignal = false;
1334 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1336 // Render and notify
1337 application.SendNotification();
1338 application.Render();
1340 // Executes the idle callbacks added by the text control on the change of input style.
1341 application.RunIdles();
1343 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1344 if( gInputStyleChangedCallbackCalled )
1346 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1347 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1350 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1351 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1353 DALI_TEST_CHECK( inputStyleChangedSignal );
1355 gInputStyleChangedCallbackCalled = false;
1356 gInputStyleMask = TextEditor::InputStyle::NONE;
1357 inputStyleChangedSignal = false;
1359 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1361 // Render and notify
1362 application.SendNotification();
1363 application.Render();
1365 // Executes the idle callbacks added by the text control on the change of input style.
1366 application.RunIdles();
1368 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1369 DALI_TEST_CHECK( !inputStyleChangedSignal );
1371 gInputStyleChangedCallbackCalled = false;
1372 gInputStyleMask = TextEditor::InputStyle::NONE;
1373 inputStyleChangedSignal = false;
1375 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1377 // Render and notify
1378 application.SendNotification();
1379 application.Render();
1381 // Executes the idle callbacks added by the text control on the change of input style.
1382 application.RunIdles();
1384 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1385 if( gInputStyleChangedCallbackCalled )
1387 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1388 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1391 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1392 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1394 DALI_TEST_CHECK( inputStyleChangedSignal );
1396 gInputStyleChangedCallbackCalled = false;
1397 gInputStyleMask = TextEditor::InputStyle::NONE;
1398 inputStyleChangedSignal = false;
1400 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1402 Property::Map fontStyleMapSet;
1403 fontStyleMapSet.Insert( "weight", "thin" );
1404 fontStyleMapSet.Insert( "width", "condensed" );
1405 fontStyleMapSet.Insert( "slant", "italic" );
1407 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1408 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1409 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1411 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1412 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1413 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1414 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1416 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1418 // Render and notify
1419 application.SendNotification();
1420 application.Render();
1422 // Executes the idle callbacks added by the text control on the change of input style.
1423 application.RunIdles();
1425 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1426 DALI_TEST_CHECK( !inputStyleChangedSignal );
1428 // Create a tap event to touch the text editor.
1429 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1430 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1432 // Render and notify
1433 application.SendNotification();
1434 application.Render();
1436 // Executes the idle callbacks added by the text control on the change of input style.
1437 application.RunIdles();
1439 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1440 if( gInputStyleChangedCallbackCalled )
1442 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1443 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1444 TextEditor::InputStyle::POINT_SIZE |
1445 TextEditor::InputStyle::FONT_STYLE |
1446 TextEditor::InputStyle::LINE_SPACING |
1447 TextEditor::InputStyle::UNDERLINE |
1448 TextEditor::InputStyle::SHADOW |
1449 TextEditor::InputStyle::EMBOSS |
1450 TextEditor::InputStyle::OUTLINE ),
1453 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1454 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1456 DALI_TEST_CHECK( inputStyleChangedSignal );
1458 gInputStyleChangedCallbackCalled = false;
1459 gInputStyleMask = TextEditor::InputStyle::NONE;
1460 inputStyleChangedSignal = false;
1462 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1464 fontStyleMapSet.Clear();
1465 fontStyleMapSet.Insert( "weight", "black" );
1466 fontStyleMapSet.Insert( "width", "expanded" );
1467 fontStyleMapSet.Insert( "slant", "oblique" );
1469 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1471 // Create a tap event to touch the text editor.
1472 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1473 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1475 // Render and notify
1476 application.SendNotification();
1477 application.Render();
1479 // Executes the idle callbacks added by the text control on the change of input style.
1480 application.RunIdles();
1482 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1483 if( gInputStyleChangedCallbackCalled )
1485 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1486 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1487 TextEditor::InputStyle::POINT_SIZE |
1488 TextEditor::InputStyle::FONT_STYLE ),
1491 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1492 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1494 DALI_TEST_CHECK( inputStyleChangedSignal );
1499 int utcDaliTextEditorEvent01(void)
1501 ToolkitTestApplication application;
1502 tet_infoline(" utcDaliTextEditorEvent01");
1504 // Creates a tap event. After creating a tap event the text editor should
1505 // have the focus and add text with key events should be possible.
1507 TextEditor editor = TextEditor::New();
1508 DALI_TEST_CHECK( editor );
1510 Stage::GetCurrent().Add( editor );
1512 editor.SetSize( 300.f, 50.f );
1513 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1514 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1516 // Avoid a crash when core load gl resources.
1517 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1519 // Render and notify
1520 application.SendNotification();
1521 application.Render();
1523 // Add a key event but as the text editor has not the focus it should do nothing.
1524 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1526 // Render and notify
1527 application.SendNotification();
1528 application.Render();
1530 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1532 // Create a tap event to touch the text editor.
1533 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1534 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1536 // Render and notify
1537 application.SendNotification();
1538 application.Render();
1540 // Now the text editor has the focus, so it can handle the key events.
1541 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1542 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1544 // Render and notify
1545 application.SendNotification();
1546 application.Render();
1548 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1550 // Create a second text editor and send key events to it.
1551 TextEditor editor2 = TextEditor::New();
1553 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1554 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1555 editor2.SetSize( 100.f, 100.f );
1556 editor2.SetPosition( 100.f, 100.f );
1558 Stage::GetCurrent().Add( editor2 );
1560 // Render and notify
1561 application.SendNotification();
1562 application.Render();
1564 // Create a tap event on the second text editor.
1565 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1566 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1568 // Render and notify
1569 application.SendNotification();
1570 application.Render();
1572 // The second text editor has the focus. It should handle the key events.
1573 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1574 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1576 // Render and notify
1577 application.SendNotification();
1578 application.Render();
1580 // Check the text has been added to the second text editor.
1581 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1586 int utcDaliTextEditorEvent02(void)
1588 ToolkitTestApplication application;
1589 tet_infoline(" utcDaliTextEditorEvent02");
1591 // Checks if the right number of actors are created.
1593 TextEditor editor = TextEditor::New();
1594 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1595 DALI_TEST_CHECK( editor );
1597 Stage::GetCurrent().Add( editor );
1599 editor.SetSize( 300.f, 50.f );
1600 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1601 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1603 // Avoid a crash when core load gl resources.
1604 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1606 // Render and notify
1607 application.SendNotification();
1608 application.Render();
1610 // Check there are the expected number of children (the stencil).
1611 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1613 Actor stencil = editor.GetChildAt( 0u );
1615 // Create a tap event to touch the text editor.
1616 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1617 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1619 // Render and notify
1620 application.SendNotification();
1621 application.Render();
1623 Actor layer = editor.GetChildAt( 1u );
1624 DALI_TEST_CHECK( layer.IsLayer() );
1626 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1627 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1629 // Now the text editor has the focus, so it can handle the key events.
1630 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1631 application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1633 // Render and notify
1634 application.SendNotification();
1635 application.Render();
1637 // Checks the cursor and the renderer have been created.
1638 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1639 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1641 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1642 DALI_TEST_CHECK( cursor );
1644 // The stencil actor has a container with all the actors which contain the text renderers.
1645 Actor container = stencil.GetChildAt( 0u );
1646 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1648 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1649 DALI_TEST_CHECK( renderer );
1652 // Move the cursor and check the position changes.
1653 Vector3 position1 = cursor.GetCurrentPosition();
1655 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1656 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1658 // Render and notify
1659 application.SendNotification();
1660 application.Render();
1662 Vector3 position2 = cursor.GetCurrentPosition();
1664 DALI_TEST_CHECK( position2.x < position1.x );
1666 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1667 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1669 // Render and notify
1670 application.SendNotification();
1671 application.Render();
1673 Vector3 position3 = cursor.GetCurrentPosition();
1675 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1677 // Send some taps and check the cursor positions.
1679 // Try to tap at the beginning.
1680 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1681 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1683 // Render and notify
1684 application.SendNotification();
1685 application.Render();
1687 // Cursor position should be the same than position1.
1688 Vector3 position4 = cursor.GetCurrentPosition();
1690 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1692 // Tap away from the start position.
1693 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1694 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1696 // Render and notify
1697 application.SendNotification();
1698 application.Render();
1700 Vector3 position5 = cursor.GetCurrentPosition();
1702 DALI_TEST_CHECK( position5.x > position4.x );
1704 // Remove all the text.
1705 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1706 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1707 editor.SetProperty( TextEditor::Property::TEXT, "" );
1709 // Render and notify
1710 application.SendNotification();
1711 application.Render();
1713 // Cursor position should be the same than position2.
1714 Vector3 position6 = cursor.GetCurrentPosition();
1716 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1718 // Should not be a renderer.
1719 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1724 int utcDaliTextEditorEvent03(void)
1726 ToolkitTestApplication application;
1727 tet_infoline(" utcDaliTextEditorEvent03");
1729 // Checks if the highlight actor is created.
1731 TextEditor editor = TextEditor::New();
1732 DALI_TEST_CHECK( editor );
1734 Stage::GetCurrent().Add( editor );
1736 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1737 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1738 editor.SetSize( 30.f, 50.f );
1739 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1740 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1742 // Avoid a crash when core load gl resources.
1743 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1745 // Render and notify
1746 application.SendNotification();
1747 application.Render();
1749 // Send some taps and check text controller with clipboard window
1750 Dali::Clipboard clipboard = Clipboard::Get();
1751 clipboard.ShowClipboard();
1752 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1753 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1754 clipboard.HideClipboard();
1756 // Render and notify
1757 application.SendNotification();
1758 application.Render();
1760 // Tap first to get the focus.
1761 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1762 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1764 // Render and notify
1765 application.SendNotification();
1766 application.Render();
1768 // Double tap to select a word.
1769 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1770 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1772 // Render and notify
1773 application.SendNotification();
1774 application.Render();
1776 // The stencil actor should have two actors: the renderer and the highlight actor.
1777 Actor stencil = editor.GetChildAt( 0u );
1779 // Highlight needs to be drawn before text, so should come first in child order
1780 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1781 DALI_TEST_CHECK( highlight );
1783 // The stencil actor has a container with all the actors which contain the text renderers.
1784 Actor container = stencil.GetChildAt( 1u );
1785 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1787 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1788 DALI_TEST_CHECK( renderer );
1791 // Double tap out of bounds
1792 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1793 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1795 // Render and notify
1796 application.SendNotification();
1797 application.Render();
1799 // The stencil actor should have one actors: the renderer actor.
1800 stencil = editor.GetChildAt( 0u );
1802 // The stencil actor has a container with all the actors which contain the text renderers.
1803 container = stencil.GetChildAt( 0u );
1804 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1806 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1807 DALI_TEST_CHECK( renderer );
1811 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1812 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1814 // Render and notify
1815 application.SendNotification();
1816 application.Render();
1821 int utcDaliTextEditorEvent04(void)
1823 ToolkitTestApplication application;
1824 tet_infoline(" utcDaliTextEditorEvent04");
1826 // Checks if the highlight actor is created.
1828 TextEditor editor = TextEditor::New();
1829 DALI_TEST_CHECK( editor );
1831 Stage::GetCurrent().Add( editor );
1833 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1834 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1835 editor.SetSize( 100.f, 50.f );
1836 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1837 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1839 // Avoid a crash when core load gl resources.
1840 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1842 // Render and notify
1843 application.SendNotification();
1844 application.Render();
1846 // Tap on the text editor
1847 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1848 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1850 // Render and notify
1851 application.SendNotification();
1852 application.Render();
1854 // Move at the end of the text.
1855 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1856 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1858 // Render and notify
1859 application.SendNotification();
1860 application.Render();
1862 for( unsigned int index = 0u; index < 10u; ++index )
1864 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1865 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1867 // Render and notify
1868 application.SendNotification();
1869 application.Render();
1873 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1875 // Render and notify
1876 application.SendNotification();
1877 application.Render();
1879 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1881 // Add some key events
1882 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1883 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1885 // Render and notify
1886 application.SendNotification();
1887 application.Render();
1889 for( unsigned int index = 0u; index < 10u; ++index )
1891 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1892 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1894 // Render and notify
1895 application.SendNotification();
1896 application.Render();
1900 application.ProcessEvent( GenerateKey( " ", "", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1902 // Render and notify
1903 application.SendNotification();
1904 application.Render();
1906 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1911 int utcDaliTextEditorEvent05(void)
1913 ToolkitTestApplication application;
1914 tet_infoline(" utcDaliTextEditorEvent05");
1916 // Checks if the highlight actor is created.
1918 TextEditor editor = TextEditor::New();
1919 DALI_TEST_CHECK( editor );
1921 Stage::GetCurrent().Add( editor );
1923 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1924 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1925 editor.SetSize( 50.f, 50.f );
1926 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1927 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1928 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1929 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1930 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1931 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1932 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1934 // Avoid a crash when core load gl resources.
1935 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1937 // Render and notify
1938 application.SendNotification();
1939 application.Render();
1941 // Tap on the text editor
1942 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1943 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1945 // Render and notify
1946 application.SendNotification();
1947 application.Render();
1949 // Move at the end of the text.
1950 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1951 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1953 // Render and notify
1954 application.SendNotification();
1955 application.Render();
1957 for( unsigned int index = 0u; index < 10u; ++index )
1960 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1962 // Render and notify
1963 application.SendNotification();
1964 application.Render();
1966 // Modify duration after scroll is enabled
1967 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1969 // Continuous scroll left to increase coverage
1970 for( unsigned int index = 0u; index < 10u; ++index )
1972 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1974 // Render and notify
1975 application.SendNotification();
1976 application.Render();
1978 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1979 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1980 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1981 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1982 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1984 // Press Escape to increase coverage
1985 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1986 application.SendNotification();
1987 application.Render();
1989 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1994 int utcDaliTextEditorEvent06(void)
1996 ToolkitTestApplication application;
1997 tet_infoline(" utcDaliTextEditorEvent06");
1999 // Checks if the highlight actor is created.
2001 TextEditor editor = TextEditor::New();
2002 DALI_TEST_CHECK( editor );
2004 Stage::GetCurrent().Add( editor );
2006 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2007 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2008 editor.SetSize( 100.f, 50.f );
2009 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2010 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2012 // Avoid a crash when core load gl resources.
2013 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2015 // Render and notify
2016 application.SendNotification();
2017 application.Render();
2019 // Tap on the text editor
2020 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2021 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2023 // Render and notify
2024 application.SendNotification();
2025 application.Render();
2027 // Move to seconds line of the text.
2028 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2030 // Render and notify
2031 application.SendNotification();
2032 application.Render();
2034 float layoutHeight = editor.GetHeightForWidth( 100.f );
2037 // Add another script characters ( glyph height is defferent )
2038 application.ProcessEvent( GenerateKey( "d", "", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2039 application.ProcessEvent( GenerateKey( "d", "", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2041 // Delete characters
2042 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2043 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2045 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2047 // Render and notify
2048 application.SendNotification();
2049 application.Render();
2051 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2054 application.ProcessEvent( GenerateKey( "", "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2055 application.SendNotification();
2056 application.Render();
2058 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2059 application.SendNotification();
2060 application.Render();
2062 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_VOLUME_UP, 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_VOLUME_DOWN, 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::DevelKey::DALI_KEY_DELETE, 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::DevelKey::DALI_KEY_CONTROL_LEFT, 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_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2079 application.SendNotification();
2080 application.Render();
2085 int utcDaliTextEditorEvent07(void)
2087 ToolkitTestApplication application;
2088 tet_infoline(" utcDaliTextEditorEvent07");
2090 // Checks if the highlight actor is created.
2092 TextEditor editor = TextEditor::New();
2093 DALI_TEST_CHECK( editor );
2095 Stage::GetCurrent().Add( editor );
2097 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2098 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2099 editor.SetSize( 100.f, 50.f );
2100 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2101 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2103 // Avoid a crash when core load gl resources.
2104 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2106 // Render and notify
2107 application.SendNotification();
2108 application.Render();
2110 // Tap on the text editor
2111 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2112 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2114 // Render and notify
2115 application.SendNotification();
2116 application.Render();
2118 // Move to second line of the text.
2119 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2121 // Render and notify
2122 application.SendNotification();
2123 application.Render();
2125 // Select some text in the right of the current cursor position
2126 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2127 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2131 // Render and notify
2132 application.SendNotification();
2133 application.Render();
2135 // Cut the selected text
2136 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2137 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 ) );
2139 // Render and notify
2140 application.SendNotification();
2141 application.Render();
2143 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2145 // Select some text in the left of the current cursor position
2146 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2147 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 // Render and notify
2152 application.SendNotification();
2153 application.Render();
2155 // Copy the selected text
2156 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2157 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 ) );
2159 // Render and notify
2160 application.SendNotification();
2161 application.Render();
2163 // Move the cursor to the third line
2164 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2165 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2167 // Render and notify
2168 application.SendNotification();
2169 application.Render();
2171 // Paste the selected text at the current cursor position
2172 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2173 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 ) );
2175 // Render and notify
2176 application.SendNotification();
2177 application.Render();
2179 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2182 // Disable Shift Selection
2183 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2185 // Test to select some text in the right of the current cursor position
2186 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2187 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 // Render and notify
2192 application.SendNotification();
2193 application.Render();
2195 // Cut the selected text
2196 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2197 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 ) );
2199 // Render and notify
2200 application.SendNotification();
2201 application.Render();
2203 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2204 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2206 // Test to select some text in the left of the current cursor position
2207 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2208 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 // Render and notify
2213 application.SendNotification();
2214 application.Render();
2216 // Copy the selected text
2217 application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218 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 ) );
2220 // Render and notify
2221 application.SendNotification();
2222 application.Render();
2224 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2225 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2230 int utcDaliTextEditorEvent08(void)
2232 ToolkitTestApplication application;
2233 tet_infoline(" utcDaliTextEditorEvent08");
2235 // Checks if the highlight actor is released correctly.
2237 TextEditor editor = TextEditor::New();
2238 DALI_TEST_CHECK( editor );
2240 Stage::GetCurrent().Add( editor );
2242 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2243 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2244 editor.SetSize( 100.f, 50.f );
2245 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2246 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2248 // Avoid a crash when core load gl resources.
2249 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2251 // Render and notify
2252 application.SendNotification();
2253 application.Render();
2255 // Tap on the text editor
2256 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2257 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2259 // Render and notify
2260 application.SendNotification();
2261 application.Render();
2263 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2264 // Test to select some text in the left of the current cursor position
2265 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2266 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 // Render and notify
2271 application.SendNotification();
2272 application.Render();
2274 // Test to the left selection handle position and the right selection handle position
2275 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2276 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 // Render and notify
2281 application.SendNotification();
2282 application.Render();
2284 // Test to select full text in the left of the current cursor position
2285 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2286 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2287 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 // Render and notify
2293 application.SendNotification();
2294 application.Render();
2296 // Test to release the current full text selection
2297 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 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 move the current cursor position correctly
2305 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2307 // Render and notify
2308 application.SendNotification();
2309 application.Render();
2312 application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2314 // Render and notify
2315 application.SendNotification();
2316 application.Render();
2318 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2320 // Test to select some text in the right of the current cursor position
2321 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2322 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 // Render and notify
2326 application.SendNotification();
2327 application.Render();
2329 // Test the cursor position with right arrow key
2330 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2332 // Render and notify
2333 application.SendNotification();
2334 application.Render();
2337 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2339 // Render and notify
2340 application.SendNotification();
2341 application.Render();
2343 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2345 // Test to select some text in the left of the current cursor position
2346 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2347 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2348 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2349 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 // Render and notify
2353 application.SendNotification();
2354 application.Render();
2356 // Test the cursor position with left arrow key
2357 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2359 // Render and notify
2360 application.SendNotification();
2361 application.Render();
2364 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2366 // Render and notify
2367 application.SendNotification();
2368 application.Render();
2370 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2372 // Test to select some text in the right of the current cursor position
2373 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2374 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 // Render and notify
2379 application.SendNotification();
2380 application.Render();
2382 // Test the cursor position with left arrow key
2383 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2385 // Render and notify
2386 application.SendNotification();
2387 application.Render();
2390 application.ProcessEvent( GenerateKey( "x", "", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2392 // Render and notify
2393 application.SendNotification();
2394 application.Render();
2396 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2398 // Test to select some text in the left of the current cursor position
2399 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2400 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2401 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2402 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 // Render and notify
2405 application.SendNotification();
2406 application.Render();
2408 // Test the cursor position with right arrow key
2409 application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2411 // Render and notify
2412 application.SendNotification();
2413 application.Render();
2416 application.ProcessEvent( GenerateKey( "c", "", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2418 // Render and notify
2419 application.SendNotification();
2420 application.Render();
2422 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2427 int utcDaliTextEditorHandles(void)
2429 ToolkitTestApplication application;
2430 tet_infoline(" utcDaliTextEditorHandles");
2432 TextEditor editor = TextEditor::New();
2433 DALI_TEST_CHECK( editor );
2435 Stage::GetCurrent().Add( editor );
2437 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2438 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2439 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2440 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2442 Property::Map imagePropertyMap;
2443 imagePropertyMap["type"] = "BufferImage";
2444 imagePropertyMap["width"] = 40;
2445 imagePropertyMap["height"] = 40;
2447 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2448 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2449 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2450 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2452 editor.SetSize( 30.f, 500.f );
2453 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2454 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2456 // Avoid a crash when core load gl resources.
2457 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2459 // Render and notify
2460 application.SendNotification();
2461 application.Render();
2463 // Tap first to get the focus.
2464 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2465 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2467 // Render and notify
2468 application.SendNotification();
2469 application.Render();
2471 // Tap to create the grab handle.
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 // Get the active layer where the text's decoration is added.
2480 Actor activeLayer = editor.GetChildAt( 1u );
2482 // Get the handle's actor.
2483 Actor handle = activeLayer.GetChildAt( 1u );
2484 handle.SetSize( 100.f, 100.f );
2486 // Render and notify
2487 application.SendNotification();
2488 application.Render();
2490 // Touch the grab handle to set it as pressed.
2491 Vector2 touchPos( 10.0f, 50.0f );
2492 Dali::Integration::TouchEvent event;
2493 event = Dali::Integration::TouchEvent();
2494 event.AddPoint( GetPointDownInside( touchPos ) );
2495 application.ProcessEvent( event );
2497 // Render and notify
2498 application.SendNotification();
2499 application.Render();
2501 // drag grab handle right
2502 SendPan(application, Gesture::Possible, touchPos);
2503 SendPan(application, Gesture::Started, touchPos);
2505 Wait(application, 100);
2507 for(int i = 0;i<20;i++)
2509 SendPan(application, Gesture::Continuing, touchPos);
2514 SendPan(application, Gesture::Finished, touchPos);
2517 // Release the grab handle.
2518 event = Dali::Integration::TouchEvent();
2519 event.AddPoint( GetPointUpInside( touchPos ) );
2520 application.ProcessEvent( event );
2522 // Render and notify
2523 application.SendNotification();
2524 application.Render();
2526 // Tap first to get the focus.
2527 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2528 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2530 // Render and notify
2531 application.SendNotification();
2532 application.Render();
2534 // Double tap to select a word and create the selection handles.
2535 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2536 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2538 // Render and notify
2539 application.SendNotification();
2540 application.Render();
2542 touchPos = Vector2( 10.0f, 50.0f );
2544 // Touch the left selection handle to set it as pressed.
2545 event = Dali::Integration::TouchEvent();
2546 event.AddPoint( GetPointDownInside( touchPos ) );
2547 application.ProcessEvent( event );
2549 // Render and notify
2550 application.SendNotification();
2551 application.Render();
2553 // drag the left selection handle right
2554 SendPan(application, Gesture::Possible, touchPos);
2555 SendPan(application, Gesture::Started, touchPos);
2557 Wait(application, 100);
2559 for(int i = 0;i<20;i++)
2561 SendPan(application, Gesture::Continuing, touchPos);
2566 SendPan(application, Gesture::Finished, touchPos);
2569 // Release the left selection handle.
2570 event = Dali::Integration::TouchEvent();
2571 event.AddPoint( GetPointUpInside( touchPos ) );
2572 application.ProcessEvent( event );
2574 // Render and notify
2575 application.SendNotification();
2576 application.Render();
2581 int utcDaliTextEditorUnderPropertyStringP(void)
2583 ToolkitTestApplication application;
2584 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2585 TextEditor editor = TextEditor::New();
2586 DALI_TEST_CHECK( editor );
2588 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2590 Stage::GetCurrent().Add( editor );
2592 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2593 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2595 tet_infoline("Set underline settings with a map");
2596 // Check the input underline property
2597 Property::Map underlineMapSet;
2598 Property::Map underlineMapGet;
2599 underlineMapSet.Insert( "enable", true );
2600 underlineMapSet.Insert( "color", Color::BLUE );
2601 underlineMapSet.Insert( "height", 2 );
2603 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2604 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2605 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2606 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2608 tet_infoline("Set underline settings with a string");
2609 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2610 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2613 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2615 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2616 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2617 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2618 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2620 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2625 int utcDaliTextEditorShadowPropertyStringP(void)
2627 ToolkitTestApplication application;
2628 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2630 TextEditor editor = TextEditor::New();
2632 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2634 Stage::GetCurrent().Add( editor );
2636 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2638 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2642 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2647 int utcDaliTextEditorFontStylePropertyStringP(void)
2649 ToolkitTestApplication application;
2650 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2652 TextEditor editor = TextEditor::New();
2654 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2656 Stage::GetCurrent().Add( editor );
2658 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2660 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2664 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2669 int utcDaliTextEditorGetPropertyLinecountP(void)
2671 ToolkitTestApplication application;
2673 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2677 TextEditor editor = TextEditor::New();
2678 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2679 editor.SetProperty( TextEditor::Property::TEXT,
2680 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2682 Stage::GetCurrent().Add( editor );
2684 editor.SetSize( 100.0f, 100.0f );
2685 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2686 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2688 editor.SetSize( 50.0f, 100.0f );
2689 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2690 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2695 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2698 ToolkitTestApplication application;
2699 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2701 TextEditor editor = TextEditor::New();
2702 DALI_TEST_CHECK( editor );
2704 Stage::GetCurrent().Add( editor );
2706 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2707 editor.SetSize( 50.f, 50.f );
2708 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2709 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2710 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2711 editor.SetKeyboardFocusable(true);
2713 bool startedCalled = false;
2714 bool finishedCalled = false;
2716 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2717 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2719 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2721 // Render and notify
2722 application.SendNotification();
2723 application.Render();
2725 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2726 application.SendNotification();
2727 application.Render(6000);
2729 application.SendNotification();
2730 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2731 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2736 int UtcDaliToolkitTextEditorTextWrapMode(void)
2738 ToolkitTestApplication application;
2739 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2743 TextEditor editor = TextEditor::New();
2744 editor.SetSize( 150.0f, 300.f );
2745 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2747 Stage::GetCurrent().Add( editor );
2749 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2750 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2752 application.SendNotification();
2753 application.Render();
2755 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2756 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2758 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2759 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2761 application.SendNotification();
2762 application.Render();
2764 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2765 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2767 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2768 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2770 application.SendNotification();
2771 application.Render();
2773 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2774 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2776 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2777 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2779 application.SendNotification();
2780 application.Render();
2782 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2783 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2788 int UtcDaliTextEditorSetPaddingProperty(void)
2790 ToolkitTestApplication application;
2791 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2793 TextEditor editor = TextEditor::New();
2794 DALI_TEST_CHECK( editor );
2795 editor.SetSize( 300.f, 50.f );
2796 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2797 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2798 Stage::GetCurrent().Add( editor );
2800 application.SendNotification();
2801 application.Render();
2803 Vector3 originalSize = editor.GetNaturalSize();
2805 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2807 application.SendNotification();
2808 application.Render();
2810 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2812 Vector3 paddingAddedSize = editor.GetNaturalSize();
2814 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2816 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2821 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2823 ToolkitTestApplication application;
2824 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2826 TextEditor editor = TextEditor::New();
2827 DALI_TEST_CHECK( editor );
2828 editor.SetSize( 300.f, 50.f );
2829 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2830 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2831 Stage::GetCurrent().Add( editor );
2833 application.SendNotification();
2834 application.Render();
2836 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2837 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2839 // Check the enable shift selection property
2840 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2841 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2843 application.SendNotification();
2844 application.Render();
2849 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2851 ToolkitTestApplication application;
2852 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2854 TextEditor editor = TextEditor::New();
2855 DALI_TEST_CHECK( editor );
2856 editor.SetSize( 300.f, 50.f );
2857 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2858 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2859 Stage::GetCurrent().Add( editor );
2861 application.SendNotification();
2862 application.Render();
2864 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2865 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2867 // Check the enable grab handle property
2868 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2869 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2871 application.SendNotification();
2872 application.Render();
2877 int UtcDaliTextEditorMatchSystemLanguageDirectionProperty(void)
2879 ToolkitTestApplication application;
2880 tet_infoline("UtcDaliTextEditorMatchSystemLanguageDirectionProperty");
2882 TextEditor editor = TextEditor::New();
2883 DALI_TEST_CHECK( editor );
2884 editor.SetSize( 300.f, 50.f );
2885 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2886 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2887 Stage::GetCurrent().Add( editor );
2889 application.SendNotification();
2890 application.Render();
2892 // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'false'.
2893 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
2895 // Check the enable match system language direction property
2896 editor.SetProperty( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
2897 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
2899 application.SendNotification();
2900 application.Render();
2905 int UtcDaliTextEditorGetInputMethodContext(void)
2907 ToolkitTestApplication application;
2908 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2910 TextEditor editor = TextEditor::New();
2911 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );