2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <dali/public-api/rendering/renderer.h>
22 #include <dali/devel-api/adaptor-framework/clipboard.h>
23 #include <dali/devel-api/adaptor-framework/key-devel.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/touch-event-integ.h>
26 #include <dali/integration-api/events/tap-gesture-event.h>
27 #include <dali/integration-api/events/pan-gesture-event.h>
28 #include <dali/integration-api/events/long-press-gesture-event.h>
29 #include <dali-toolkit-test-suite-utils.h>
30 #include <dali-toolkit/dali-toolkit.h>
31 #include <dali-toolkit/devel-api/controls/text-controls/text-editor-devel.h>
34 using namespace Toolkit;
36 void dali_texteditor_startup(void)
38 test_return_value = TET_UNDEF;
41 void dali_texteditor_cleanup(void)
43 test_return_value = TET_PASS;
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
57 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
58 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
59 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
60 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
61 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
62 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
63 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
64 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
65 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
69 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
70 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
71 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
72 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
73 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
74 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
75 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
76 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
77 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
78 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
80 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
81 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
82 const char* const PROPERTY_NAME_UNDERLINE = "underline";
83 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
84 const char* const PROPERTY_NAME_SHADOW = "shadow";
85 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
86 const char* const PROPERTY_NAME_EMBOSS = "emboss";
87 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
88 const char* const PROPERTY_NAME_OUTLINE = "outline";
89 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
91 const char* const PROPERTY_NAME_SMOOTH_SCROLL = "smoothScroll";
92 const char* const PROPERTY_NAME_SMOOTH_SCROLL_DURATION = "smoothScrollDuration";
93 const char* const PROPERTY_NAME_ENABLE_SCROLL_BAR = "enableScrollBar";
94 const char* const PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION = "scrollBarShowDuration";
95 const char* const PROPERTY_NAME_SCROLL_BAR_FADE_DURATION = "scrollBarFadeDuration";
96 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
97 const char* const PROPERTY_NAME_LINE_COUNT = "lineCount";
98 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT = "placeholderText";
99 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR = "placeholderTextColor";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER = "placeholder";
102 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION = "enableShiftSelection";
103 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE = "enableGrabHandle";
105 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
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 unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
111 const float TO_MILLISECONDS = 1000.f;
112 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
113 const float RENDER_FRAME_INTERVAL = 16.66f;
115 const float SCROLL_THRESHOLD = 10.f;
116 const float SCROLL_SPEED = 300.f;
118 const unsigned int DEFAULT_FONT_SIZE = 1152u;
119 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
123 const int KEY_C_CODE = 54;
124 const int KEY_V_CODE = 55;
125 const int KEY_X_CODE = 53;
126 const int KEY_WHITE_SPACE_CODE = 65;
128 const int KEY_SHIFT_MODIFIER = 257;
129 const int KEY_CONTROL_MODIFIER = 258;
131 const char* HANDLE_IMAGE_FILE_NAME = TEST_RESOURCE_DIR "/insertpoint-icon.png";
133 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
135 static bool gTextChangedCallBackCalled;
136 static bool gInputStyleChangedCallbackCalled;
137 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
139 struct CallbackFunctor
141 CallbackFunctor(bool* callbackFlag)
142 : mCallbackFlag( callbackFlag )
148 *mCallbackFlag = true;
153 static void TestTextChangedCallback( TextEditor control )
155 tet_infoline(" TestTextChangedCallback");
157 gTextChangedCallBackCalled = true;
160 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
162 tet_infoline(" TestInputStyleChangedCallback");
164 gInputStyleChangedCallbackCalled = true;
165 gInputStyleMask = mask;
168 // Generate a TapGestureEvent to send to Core.
169 Integration::TapGestureEvent GenerateTap(
170 Gesture::State state,
171 unsigned int numberOfTaps,
172 unsigned int numberOfTouches,
175 Integration::TapGestureEvent tap( state );
177 tap.numberOfTaps = numberOfTaps;
178 tap.numberOfTouches = numberOfTouches;
184 Integration::LongPressGestureEvent GenerateLongPress(
185 Gesture::State state,
186 unsigned int numberOfTouches,
189 Integration::LongPressGestureEvent longPress( state );
191 longPress.numberOfTouches = numberOfTouches;
192 longPress.point = point;
196 // Generate a PanGestureEvent to send to Core
197 Integration::PanGestureEvent GeneratePan( Gesture::State state,
198 const Vector2& previousPosition,
199 const Vector2& currentPosition,
200 unsigned long timeDelta,
201 unsigned int numberOfTouches = 1u )
203 Integration::PanGestureEvent pan(state);
205 pan.previousPosition = previousPosition;
206 pan.currentPosition = currentPosition;
207 pan.timeDelta = timeDelta;
208 pan.numberOfTouches = numberOfTouches;
213 // Generate a KeyEvent to send to Core.
214 Integration::KeyEvent GenerateKey( const std::string& keyName,
215 const std::string& keyString,
218 unsigned long timeStamp,
219 const Integration::KeyEvent::State& keyState,
220 const std::string& compose = "",
221 const std::string& deviceName = DEFAULT_DEVICE_NAME,
222 const Device::Class::Type& deviceClass = Device::Class::NONE,
223 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
225 return Integration::KeyEvent( keyName,
238 * Helper to generate PanGestureEvent
240 * @param[in] application Application instance
241 * @param[in] state The Gesture State
242 * @param[in] pos The current position of touch.
244 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
248 if( (state == Gesture::Started) ||
249 (state == Gesture::Possible) )
255 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
262 * Simulate time passed by.
264 * @note this will always process at least 1 frame (1/60 sec)
266 * @param application Test application instance
267 * @param duration Time to pass in milliseconds.
268 * @return The actual time passed in milliseconds
270 static int Wait(ToolkitTestApplication& application, int duration = 0)
274 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
276 application.SendNotification();
277 application.Render(RENDER_FRAME_INTERVAL);
278 time += RENDER_FRAME_INTERVAL;
284 Dali::Integration::Point GetPointDownInside( Vector2& pos )
286 Dali::Integration::Point point;
287 point.SetState( PointState::DOWN );
288 point.SetScreenPosition( pos );
292 Dali::Integration::Point GetPointUpInside( Vector2& pos )
294 Dali::Integration::Point point;
295 point.SetState( PointState::UP );
296 point.SetScreenPosition( pos );
300 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
302 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
304 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
306 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
308 Property::Value* valueSet = NULL;
309 if ( valueGet.first.type == Property::Key::INDEX )
311 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
315 // Get Key is a string so searching Set Map for a string key
316 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
319 if( NULL != valueSet )
321 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
323 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
326 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
328 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
331 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
333 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
336 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
338 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
341 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
343 Vector2 vector2Get = valueGet.second.Get<Vector2>();
344 Vector2 vector2Set = valueSet->Get<Vector2>();
345 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
348 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
350 Vector4 vector4Get = valueGet.second.Get<Vector4>();
351 Vector4 vector4Set = valueSet->Get<Vector4>();
352 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 );
358 if ( valueGet.first.type == Property::Key::INDEX )
360 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
364 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
374 class ScrollStateChangeCallback : public Dali::ConnectionTracker
377 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
378 : mStartedCalled( startedCalled ),
379 mFinishedCalled( finishedCalled )
383 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
385 if( type == TextEditor::Scroll::STARTED )
387 mStartedCalled = true;
389 else if( type == TextEditor::Scroll::FINISHED )
391 mFinishedCalled = true;
395 bool& mStartedCalled;
396 bool& mFinishedCalled;
401 int UtcDaliToolkitTextEditorConstructorP(void)
403 ToolkitTestApplication application;
404 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
405 TextEditor textEditor;
406 DALI_TEST_CHECK( !textEditor );
410 int UtcDaliToolkitTextEditorNewP(void)
412 ToolkitTestApplication application;
413 tet_infoline(" UtcDaliToolkitTextEditorNewP");
414 TextEditor textEditor = TextEditor::New();
415 DALI_TEST_CHECK( textEditor );
419 int UtcDaliToolkitTextEditorDownCastP(void)
421 ToolkitTestApplication application;
422 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
423 TextEditor textEditor1 = TextEditor::New();
424 BaseHandle object( textEditor1 );
426 TextEditor textEditor2 = TextEditor::DownCast( object );
427 DALI_TEST_CHECK( textEditor2 );
429 TextEditor textEditor3 = DownCast< TextEditor >( object );
430 DALI_TEST_CHECK( textEditor3 );
434 int UtcDaliToolkitTextEditorDownCastN(void)
436 ToolkitTestApplication application;
437 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
438 BaseHandle uninitializedObject;
439 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
440 DALI_TEST_CHECK( !textEditor1 );
442 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
443 DALI_TEST_CHECK( !textEditor2 );
447 int UtcDaliToolkitTextEditorCopyConstructorP(void)
449 ToolkitTestApplication application;
450 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
451 TextEditor textEditor = TextEditor::New();
452 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
454 TextEditor copy( textEditor );
455 DALI_TEST_CHECK( copy );
456 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
460 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
462 ToolkitTestApplication application;
463 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
464 TextEditor textEditor = TextEditor::New();
465 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
467 TextEditor copy = textEditor;
468 DALI_TEST_CHECK( copy );
469 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
473 int UtcDaliTextEditorNewP(void)
475 ToolkitTestApplication application;
476 tet_infoline(" UtcDaliToolkitTextEditorNewP");
477 TextEditor textEditor = TextEditor::New();
478 DALI_TEST_CHECK( textEditor );
482 // Positive test case for a method
483 int UtcDaliTextEditorGetPropertyP(void)
485 ToolkitTestApplication application;
486 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
487 TextEditor editor = TextEditor::New();
488 DALI_TEST_CHECK( editor );
490 // Check Property Indices are correct
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
519 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
543 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
544 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
549 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
552 Property::Map imageMap;
553 imageMap[mapKey] =mapValue;
555 editor.SetProperty( property , imageMap );
556 Property::Value propValue = editor.GetProperty( property );
557 Property::Map* resultMap = propValue.GetMap();
559 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
567 // Positive test case for a method
568 int UtcDaliTextEditorSetPropertyP(void)
570 ToolkitTestApplication application;
571 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
572 TextEditor editor = TextEditor::New();
573 DALI_TEST_CHECK( editor );
574 Stage::GetCurrent().Add( editor );
576 // Note - we can't check the defaults since the stylesheets are platform-specific
578 // Check the render backend property.
579 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
580 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
582 // Check text property.
583 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
584 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
586 // Check text's color property
587 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
588 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
590 // Check font properties.
591 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
592 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
594 Property::Map fontStyleMapSet;
595 Property::Map fontStyleMapGet;
596 Property::Value* slantValue = NULL;
598 fontStyleMapSet.Insert( "weight", "bold" );
599 fontStyleMapSet.Insert( "width", "condensed" );
600 fontStyleMapSet.Insert( "slant", "italic" );
602 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
603 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
604 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
605 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
607 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
608 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
611 fontStyleMapSet.Clear();
612 fontStyleMapSet.Insert( "weight", "normal" );
613 fontStyleMapSet.Insert( "slant", "oblique" );
614 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
615 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
616 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
617 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
619 fontStyleMapSet.Clear();
620 fontStyleMapSet.Insert( "slant", "roman" );
621 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
622 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
624 // Replace 'roman' for 'normal'.
625 slantValue = fontStyleMapGet.Find( "slant" );
626 if( NULL != slantValue )
628 if( "normal" == slantValue->Get<std::string>() )
630 fontStyleMapGet["slant"] = "roman";
633 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
634 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
636 fontStyleMapSet.Clear();
638 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
639 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
640 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
641 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
643 // Check that the Alignment properties can be correctly set
644 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
645 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
647 // Check scroll properties.
648 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
649 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
650 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
651 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
653 // Check cursor properties
654 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
655 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
656 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
657 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
659 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
660 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
661 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
662 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
663 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
664 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
665 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
666 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
668 // Check handle images
669 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
670 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
671 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
672 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
673 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
675 // Check handle images
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
677 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
680 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
681 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
683 // Check the highlight color
684 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
685 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
687 // Decoration bounding box
688 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
689 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
691 // Check the enable markup property.
692 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
693 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
694 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
696 // Check input color property.
697 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
698 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
700 // Check input font properties.
701 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
702 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
704 fontStyleMapSet.Clear();
705 fontStyleMapSet.Insert( "weight", "bold" );
706 fontStyleMapSet.Insert( "width", "condensed" );
707 fontStyleMapSet.Insert( "slant", "italic" );
709 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
710 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
711 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
712 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
714 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
715 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 // Reset input font style.
718 fontStyleMapSet.Clear();
719 fontStyleMapSet.Insert( "weight", "normal" );
720 fontStyleMapSet.Insert( "slant", "oblique" );
722 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
723 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
724 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
725 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
727 fontStyleMapSet.Clear();
728 fontStyleMapSet.Insert( "slant", "roman" );
730 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
731 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
733 // Replace 'roman' for 'normal'.
734 slantValue = fontStyleMapGet.Find( "slant" );
735 if( NULL != slantValue )
737 if( "normal" == slantValue->Get<std::string>() )
739 fontStyleMapGet["slant"] = "roman";
742 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
743 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
745 fontStyleMapSet.Clear();
747 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
748 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
749 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
750 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
752 // Check the line spacing property
753 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
754 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
755 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
757 // Check the input line spacing property
758 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
759 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
760 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
762 // Check the underline property
764 Property::Map underlineMapSet;
765 Property::Map underlineMapGet;
767 underlineMapSet.Insert( "enable", "true" );
768 underlineMapSet.Insert( "color", "red" );
769 underlineMapSet.Insert( "height", "1" );
771 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
773 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
774 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
775 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
777 // Check the input underline property
778 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
779 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
781 // Check the shadow property
782 Property::Map shadowMapSet;
783 Property::Map shadowMapGet;
785 shadowMapSet.Insert( "color", Color::GREEN );
786 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
787 shadowMapSet.Insert( "blurRadius", 3.0f );
789 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
791 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
792 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
793 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
795 // Check the input shadow property
796 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
797 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
799 // Check the emboss property
800 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
801 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
803 // Check the input emboss property
804 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
805 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
807 // Check the outline property
809 // Test string type first
810 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
811 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
812 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
814 // Then test the property map type
815 Property::Map outlineMapSet;
816 Property::Map outlineMapGet;
818 outlineMapSet["color"] = Color::RED;
819 outlineMapSet["width"] = 2.0f;
821 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
823 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
824 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
825 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
827 // Check the input outline property
828 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
829 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
831 // Check the smooth scroll property
832 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
833 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
834 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
836 // Check the smooth scroll duration property
837 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
838 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
840 // Check the scroll bar property
841 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
842 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
843 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
845 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
846 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
847 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
848 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
850 // Check the pixel size of font
851 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
852 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
854 // Check placeholder text properties.
855 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
856 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
858 // Check placeholder text's color property.
859 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
860 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
862 // Check the enable selection property
863 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
864 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
866 // Check the placeholder property with pixel size
867 Property::Map placeholderPixelSizeMapSet;
868 Property::Map placeholderPixelSizeMapGet;
869 Property::Map placeholderFontstyleMap;
870 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
871 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
872 placeholderPixelSizeMapSet["color"] = Color::BLUE;
873 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
874 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
876 placeholderFontstyleMap.Insert( "weight", "bold" );
877 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
878 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
880 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
881 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
883 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
884 Property::Map placeholderConversionMap;
885 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
886 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
887 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
888 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
889 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
890 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
892 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
894 // Check the placeholder property with point size
895 Property::Map placeholderMapSet;
896 Property::Map placeholderMapGet;
897 placeholderMapSet["text"] = "Setting Placeholder Text";
898 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
899 placeholderMapSet["color"] = Color::RED;
900 placeholderMapSet["fontFamily"] = "Arial";
901 placeholderMapSet["pointSize"] = 12.0f;
902 // Check the placeholder font style property
903 placeholderFontstyleMap.Clear();
905 placeholderFontstyleMap.Insert( "weight", "bold" );
906 placeholderFontstyleMap.Insert( "width", "condensed" );
907 placeholderFontstyleMap.Insert( "slant", "italic" );
908 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
909 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
911 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
912 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
914 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
915 placeholderConversionMap.Clear();
916 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
917 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
918 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
919 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
920 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
921 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
922 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
925 placeholderFontstyleMap.Clear();
926 placeholderFontstyleMap.Insert( "weight", "normal" );
927 placeholderFontstyleMap.Insert( "slant", "oblique" );
928 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
929 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
931 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
932 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
933 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
934 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
936 placeholderFontstyleMap.Clear();
937 placeholderFontstyleMap.Insert( "slant", "roman" );
938 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
939 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
941 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
943 placeholderFontstyleMap.Clear();
944 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
946 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
947 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
948 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
949 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
950 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
952 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
953 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
955 application.SendNotification();
956 application.Render();
961 // Positive Atlas Text Renderer test
962 int utcDaliTextEditorAtlasRenderP(void)
964 ToolkitTestApplication application;
965 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
966 StyleManager styleManager = StyleManager::Get();
967 styleManager.ApplyDefaultTheme();
968 TextEditor editor = TextEditor::New();
969 DALI_TEST_CHECK( editor );
971 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
973 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
975 Stage::GetCurrent().Add( editor );
979 // Render some text with the shared atlas backend
980 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
981 application.SendNotification();
982 application.Render();
986 tet_result(TET_FAIL);
991 // Positive test for the textChanged signal.
992 int utcDaliTextEditorTextChangedP(void)
994 ToolkitTestApplication application;
995 tet_infoline(" utcDaliTextEditorTextChangedP");
996 TextEditor editor = TextEditor::New();
997 DALI_TEST_CHECK( editor );
999 Stage::GetCurrent().Add( editor );
1001 // connect to the text changed signal.
1002 ConnectionTracker* testTracker = new ConnectionTracker();
1003 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1004 bool textChangedSignal = false;
1005 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1007 gTextChangedCallBackCalled = false;
1008 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1009 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1010 DALI_TEST_CHECK( textChangedSignal );
1012 application.SendNotification();
1014 editor.SetKeyInputFocus();
1016 gTextChangedCallBackCalled = false;
1017 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1018 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1023 int utcDaliTextEditorInputStyleChanged01(void)
1025 ToolkitTestApplication application;
1026 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1028 // The text-editor emits signals when the input style changes. These changes of style are
1029 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1030 // can't be emitted during the size negotiation as the callbacks may update the UI.
1031 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1032 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1033 application.CreateAdaptor();
1037 char* pathNamePtr = get_current_dir_name();
1038 const std::string pathName( pathNamePtr );
1039 free( pathNamePtr );
1041 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1042 fontClient.SetDpi( 93u, 93u );
1044 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1045 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1047 TextEditor editor = TextEditor::New();
1048 DALI_TEST_CHECK( editor );
1051 editor.SetSize( 300.f, 50.f );
1052 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1053 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1055 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1056 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1058 // connect to the text changed signal.
1059 ConnectionTracker* testTracker = new ConnectionTracker();
1060 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1061 bool inputStyleChangedSignal = false;
1062 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1064 Stage::GetCurrent().Add( editor );
1066 // Render and notify
1067 application.SendNotification();
1068 application.Render();
1070 // Executes the idle callbacks added by the text control on the change of input style.
1071 application.RunIdles();
1073 gInputStyleChangedCallbackCalled = false;
1074 gInputStyleMask = TextEditor::InputStyle::NONE;
1075 inputStyleChangedSignal = false;
1077 // Create a tap event to touch the text editor.
1078 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1079 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1081 // Render and notify
1082 application.SendNotification();
1083 application.Render();
1085 // Executes the idle callbacks added by the text control on the change of input style.
1086 application.RunIdles();
1088 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1089 if( gInputStyleChangedCallbackCalled )
1091 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1093 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1094 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1096 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1097 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1099 DALI_TEST_CHECK( inputStyleChangedSignal );
1101 gInputStyleChangedCallbackCalled = false;
1102 gInputStyleMask = TextEditor::InputStyle::NONE;
1103 inputStyleChangedSignal = false;
1105 // Create a tap event to touch the text editor.
1106 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1107 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1109 // Render and notify
1110 application.SendNotification();
1111 application.Render();
1113 // Executes the idle callbacks added by the text control on the change of input style.
1114 application.RunIdles();
1116 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1117 DALI_TEST_CHECK( !inputStyleChangedSignal );
1119 gInputStyleChangedCallbackCalled = false;
1120 gInputStyleMask = TextEditor::InputStyle::NONE;
1121 inputStyleChangedSignal = false;
1123 // Create a tap event to touch the text editor.
1124 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1125 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1127 // Render and notify
1128 application.SendNotification();
1129 application.Render();
1131 // Executes the idle callbacks added by the text control on the change of input style.
1132 application.RunIdles();
1134 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1135 if( gInputStyleChangedCallbackCalled )
1137 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1139 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1140 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1142 DALI_TEST_CHECK( inputStyleChangedSignal );
1144 gInputStyleChangedCallbackCalled = false;
1145 gInputStyleMask = TextEditor::InputStyle::NONE;
1146 inputStyleChangedSignal = false;
1148 // Create a tap event to touch the text editor.
1149 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1150 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1152 // Render and notify
1153 application.SendNotification();
1154 application.Render();
1156 // Executes the idle callbacks added by the text control on the change of input style.
1157 application.RunIdles();
1159 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1160 if( gInputStyleChangedCallbackCalled )
1162 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1164 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1165 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1167 Property::Map fontStyleMapSet;
1168 Property::Map fontStyleMapGet;
1170 fontStyleMapSet.Insert( "weight", "bold" );
1172 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1173 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1174 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1176 DALI_TEST_CHECK( inputStyleChangedSignal );
1178 gInputStyleChangedCallbackCalled = false;
1179 gInputStyleMask = TextEditor::InputStyle::NONE;
1180 inputStyleChangedSignal = false;
1182 // Create a tap event to touch the text editor.
1183 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1184 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1186 // Render and notify
1187 application.SendNotification();
1188 application.Render();
1190 // Executes the idle callbacks added by the text control on the change of input style.
1191 application.RunIdles();
1193 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1194 DALI_TEST_CHECK( !inputStyleChangedSignal );
1196 gInputStyleChangedCallbackCalled = false;
1197 gInputStyleMask = TextEditor::InputStyle::NONE;
1198 inputStyleChangedSignal = false;
1200 // Create a tap event to touch the text editor.
1201 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1202 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1204 // Render and notify
1205 application.SendNotification();
1206 application.Render();
1208 // Executes the idle callbacks added by the text control on the change of input style.
1209 application.RunIdles();
1211 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1212 if( gInputStyleChangedCallbackCalled )
1214 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1216 Property::Map fontStyleMapSet;
1217 Property::Map fontStyleMapGet;
1219 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1220 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1221 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1223 DALI_TEST_CHECK( inputStyleChangedSignal );
1225 gInputStyleChangedCallbackCalled = false;
1226 gInputStyleMask = TextEditor::InputStyle::NONE;
1227 inputStyleChangedSignal = false;
1229 // Create a tap event to touch the text editor.
1230 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1231 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1233 // Render and notify
1234 application.SendNotification();
1235 application.Render();
1237 // Executes the idle callbacks added by the text control on the change of input style.
1238 application.RunIdles();
1240 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1241 DALI_TEST_CHECK( !inputStyleChangedSignal );
1246 int utcDaliTextEditorInputStyleChanged02(void)
1248 ToolkitTestApplication application;
1249 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1251 // The text-editor emits signals when the input style changes. These changes of style are
1252 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1253 // can't be emitted during the size negotiation as the callbacks may update the UI.
1254 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1255 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1256 application.CreateAdaptor();
1260 char* pathNamePtr = get_current_dir_name();
1261 const std::string pathName( pathNamePtr );
1262 free( pathNamePtr );
1264 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1265 fontClient.SetDpi( 93u, 93u );
1267 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1268 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1270 TextEditor editor = TextEditor::New();
1271 DALI_TEST_CHECK( editor );
1274 editor.SetSize( 300.f, 50.f );
1275 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1276 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1278 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1279 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>" );
1281 // connect to the text changed signal.
1282 ConnectionTracker* testTracker = new ConnectionTracker();
1283 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1284 bool inputStyleChangedSignal = false;
1285 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1287 Stage::GetCurrent().Add( editor );
1289 // Render and notify
1290 application.SendNotification();
1291 application.Render();
1293 // Executes the idle callbacks added by the text control on the change of input style.
1294 application.RunIdles();
1296 gInputStyleChangedCallbackCalled = false;
1297 gInputStyleMask = TextEditor::InputStyle::NONE;
1298 inputStyleChangedSignal = false;
1300 // Create a tap event to touch the text editor.
1301 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1302 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1303 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1304 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1306 // Render and notify
1307 application.SendNotification();
1308 application.Render();
1310 // Executes the idle callbacks added by the text control on the change of input style.
1311 application.RunIdles();
1313 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1314 if( gInputStyleChangedCallbackCalled )
1316 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1317 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1318 TextEditor::InputStyle::POINT_SIZE |
1319 TextEditor::InputStyle::COLOR ),
1322 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1323 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1325 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1326 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1328 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1329 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1331 DALI_TEST_CHECK( inputStyleChangedSignal );
1333 gInputStyleChangedCallbackCalled = false;
1334 gInputStyleMask = TextEditor::InputStyle::NONE;
1335 inputStyleChangedSignal = false;
1337 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1339 // Render and notify
1340 application.SendNotification();
1341 application.Render();
1343 // Executes the idle callbacks added by the text control on the change of input style.
1344 application.RunIdles();
1346 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1347 if( gInputStyleChangedCallbackCalled )
1349 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1350 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1353 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1354 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1356 DALI_TEST_CHECK( inputStyleChangedSignal );
1358 gInputStyleChangedCallbackCalled = false;
1359 gInputStyleMask = TextEditor::InputStyle::NONE;
1360 inputStyleChangedSignal = false;
1362 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1364 // Render and notify
1365 application.SendNotification();
1366 application.Render();
1368 // Executes the idle callbacks added by the text control on the change of input style.
1369 application.RunIdles();
1371 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1372 DALI_TEST_CHECK( !inputStyleChangedSignal );
1374 gInputStyleChangedCallbackCalled = false;
1375 gInputStyleMask = TextEditor::InputStyle::NONE;
1376 inputStyleChangedSignal = false;
1378 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1380 // Render and notify
1381 application.SendNotification();
1382 application.Render();
1384 // Executes the idle callbacks added by the text control on the change of input style.
1385 application.RunIdles();
1387 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1388 if( gInputStyleChangedCallbackCalled )
1390 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1391 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1394 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1395 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1397 DALI_TEST_CHECK( inputStyleChangedSignal );
1399 gInputStyleChangedCallbackCalled = false;
1400 gInputStyleMask = TextEditor::InputStyle::NONE;
1401 inputStyleChangedSignal = false;
1403 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1405 Property::Map fontStyleMapSet;
1406 fontStyleMapSet.Insert( "weight", "thin" );
1407 fontStyleMapSet.Insert( "width", "condensed" );
1408 fontStyleMapSet.Insert( "slant", "italic" );
1410 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1411 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1412 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1414 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1415 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1416 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1417 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1419 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1421 // Render and notify
1422 application.SendNotification();
1423 application.Render();
1425 // Executes the idle callbacks added by the text control on the change of input style.
1426 application.RunIdles();
1428 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1429 DALI_TEST_CHECK( !inputStyleChangedSignal );
1431 // Create a tap event to touch the text editor.
1432 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1433 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1435 // Render and notify
1436 application.SendNotification();
1437 application.Render();
1439 // Executes the idle callbacks added by the text control on the change of input style.
1440 application.RunIdles();
1442 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1443 if( gInputStyleChangedCallbackCalled )
1445 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1446 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1447 TextEditor::InputStyle::POINT_SIZE |
1448 TextEditor::InputStyle::FONT_STYLE |
1449 TextEditor::InputStyle::LINE_SPACING |
1450 TextEditor::InputStyle::UNDERLINE |
1451 TextEditor::InputStyle::SHADOW |
1452 TextEditor::InputStyle::EMBOSS |
1453 TextEditor::InputStyle::OUTLINE ),
1456 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1457 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1459 DALI_TEST_CHECK( inputStyleChangedSignal );
1461 gInputStyleChangedCallbackCalled = false;
1462 gInputStyleMask = TextEditor::InputStyle::NONE;
1463 inputStyleChangedSignal = false;
1465 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1467 fontStyleMapSet.Clear();
1468 fontStyleMapSet.Insert( "weight", "black" );
1469 fontStyleMapSet.Insert( "width", "expanded" );
1470 fontStyleMapSet.Insert( "slant", "oblique" );
1472 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1474 // Create a tap event to touch the text editor.
1475 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1476 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1478 // Render and notify
1479 application.SendNotification();
1480 application.Render();
1482 // Executes the idle callbacks added by the text control on the change of input style.
1483 application.RunIdles();
1485 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1486 if( gInputStyleChangedCallbackCalled )
1488 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1489 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1490 TextEditor::InputStyle::POINT_SIZE |
1491 TextEditor::InputStyle::FONT_STYLE ),
1494 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1495 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1497 DALI_TEST_CHECK( inputStyleChangedSignal );
1502 int utcDaliTextEditorEvent01(void)
1504 ToolkitTestApplication application;
1505 tet_infoline(" utcDaliTextEditorEvent01");
1507 // Creates a tap event. After creating a tap event the text editor should
1508 // have the focus and add text with key events should be possible.
1510 TextEditor editor = TextEditor::New();
1511 DALI_TEST_CHECK( editor );
1513 Stage::GetCurrent().Add( editor );
1515 editor.SetSize( 300.f, 50.f );
1516 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1517 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1519 // Avoid a crash when core load gl resources.
1520 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1522 // Render and notify
1523 application.SendNotification();
1524 application.Render();
1526 // Add a key event but as the text editor has not the focus it should do nothing.
1527 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1529 // Render and notify
1530 application.SendNotification();
1531 application.Render();
1533 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1535 // Create a tap event to touch the text editor.
1536 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1537 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1539 // Render and notify
1540 application.SendNotification();
1541 application.Render();
1543 // Now the text editor has the focus, so it can handle the key events.
1544 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1545 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1547 // Render and notify
1548 application.SendNotification();
1549 application.Render();
1551 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1553 // Create a second text editor and send key events to it.
1554 TextEditor editor2 = TextEditor::New();
1556 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1557 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1558 editor2.SetSize( 100.f, 100.f );
1559 editor2.SetPosition( 100.f, 100.f );
1561 Stage::GetCurrent().Add( editor2 );
1563 // Render and notify
1564 application.SendNotification();
1565 application.Render();
1567 // Create a tap event on the second text editor.
1568 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1569 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1571 // Render and notify
1572 application.SendNotification();
1573 application.Render();
1575 // The second text editor has the focus. It should handle the key events.
1576 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1577 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1579 // Render and notify
1580 application.SendNotification();
1581 application.Render();
1583 // Check the text has been added to the second text editor.
1584 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1589 int utcDaliTextEditorEvent02(void)
1591 ToolkitTestApplication application;
1592 tet_infoline(" utcDaliTextEditorEvent02");
1594 // Checks if the right number of actors are created.
1596 TextEditor editor = TextEditor::New();
1597 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1598 DALI_TEST_CHECK( editor );
1600 Stage::GetCurrent().Add( editor );
1602 editor.SetSize( 300.f, 50.f );
1603 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1604 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1606 // Avoid a crash when core load gl resources.
1607 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1609 // Render and notify
1610 application.SendNotification();
1611 application.Render();
1613 // Check there are the expected number of children (the stencil).
1614 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1616 Actor stencil = editor.GetChildAt( 0u );
1618 // Create a tap event to touch the text editor.
1619 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1620 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1622 // Render and notify
1623 application.SendNotification();
1624 application.Render();
1626 Actor layer = editor.GetChildAt( 1u );
1627 DALI_TEST_CHECK( layer.IsLayer() );
1629 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1630 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1632 // Now the text editor has the focus, so it can handle the key events.
1633 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1634 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1636 // Render and notify
1637 application.SendNotification();
1638 application.Render();
1640 // Checks the cursor and the renderer have been created.
1641 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1642 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1644 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1645 DALI_TEST_CHECK( cursor );
1647 // The stencil actor has a container with all the actors which contain the text renderers.
1648 Actor container = stencil.GetChildAt( 0u );
1649 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1651 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1652 DALI_TEST_CHECK( renderer );
1655 // Move the cursor and check the position changes.
1656 Vector3 position1 = cursor.GetCurrentPosition();
1658 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1659 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1661 // Render and notify
1662 application.SendNotification();
1663 application.Render();
1665 Vector3 position2 = cursor.GetCurrentPosition();
1667 DALI_TEST_CHECK( position2.x < position1.x );
1669 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1672 // Render and notify
1673 application.SendNotification();
1674 application.Render();
1676 Vector3 position3 = cursor.GetCurrentPosition();
1678 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1680 // Send some taps and check the cursor positions.
1682 // Try to tap at the beginning.
1683 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1684 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1686 // Render and notify
1687 application.SendNotification();
1688 application.Render();
1690 // Cursor position should be the same than position1.
1691 Vector3 position4 = cursor.GetCurrentPosition();
1693 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1695 // Tap away from the start position.
1696 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1697 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1699 // Render and notify
1700 application.SendNotification();
1701 application.Render();
1703 Vector3 position5 = cursor.GetCurrentPosition();
1705 DALI_TEST_CHECK( position5.x > position4.x );
1707 // Remove all the text.
1708 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1709 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1710 editor.SetProperty( TextEditor::Property::TEXT, "" );
1712 // Render and notify
1713 application.SendNotification();
1714 application.Render();
1716 // Cursor position should be the same than position2.
1717 Vector3 position6 = cursor.GetCurrentPosition();
1719 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1721 // Should not be a renderer.
1722 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1727 int utcDaliTextEditorEvent03(void)
1729 ToolkitTestApplication application;
1730 tet_infoline(" utcDaliTextEditorEvent03");
1732 // Checks if the highlight actor is created.
1734 TextEditor editor = TextEditor::New();
1735 DALI_TEST_CHECK( editor );
1737 Stage::GetCurrent().Add( editor );
1739 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1740 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1741 editor.SetSize( 30.f, 50.f );
1742 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1743 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1745 // Avoid a crash when core load gl resources.
1746 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1748 // Render and notify
1749 application.SendNotification();
1750 application.Render();
1752 // Send some taps and check text controller with clipboard window
1753 Dali::Clipboard clipboard = Clipboard::Get();
1754 clipboard.ShowClipboard();
1755 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1756 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1757 clipboard.HideClipboard();
1759 // Render and notify
1760 application.SendNotification();
1761 application.Render();
1763 // Tap first to get the focus.
1764 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1765 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1767 // Render and notify
1768 application.SendNotification();
1769 application.Render();
1771 // Double tap to select a word.
1772 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1773 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1775 // Render and notify
1776 application.SendNotification();
1777 application.Render();
1779 // The stencil actor should have two actors: the renderer and the highlight actor.
1780 Actor stencil = editor.GetChildAt( 0u );
1782 // Highlight needs to be drawn before text, so should come first in child order
1783 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1784 DALI_TEST_CHECK( highlight );
1786 // The stencil actor has a container with all the actors which contain the text renderers.
1787 Actor container = stencil.GetChildAt( 1u );
1788 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1790 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1791 DALI_TEST_CHECK( renderer );
1794 // Double tap out of bounds
1795 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1796 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1798 // Render and notify
1799 application.SendNotification();
1800 application.Render();
1802 // The stencil actor should have one actors: the renderer actor.
1803 stencil = editor.GetChildAt( 0u );
1805 // The stencil actor has a container with all the actors which contain the text renderers.
1806 container = stencil.GetChildAt( 0u );
1807 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1809 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1810 DALI_TEST_CHECK( renderer );
1814 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1815 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1817 // Render and notify
1818 application.SendNotification();
1819 application.Render();
1824 int utcDaliTextEditorEvent04(void)
1826 ToolkitTestApplication application;
1827 tet_infoline(" utcDaliTextEditorEvent04");
1829 // Checks if the highlight actor is created.
1831 TextEditor editor = TextEditor::New();
1832 DALI_TEST_CHECK( editor );
1834 Stage::GetCurrent().Add( editor );
1836 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1837 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1838 editor.SetSize( 100.f, 50.f );
1839 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1840 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1842 // Avoid a crash when core load gl resources.
1843 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1845 // Render and notify
1846 application.SendNotification();
1847 application.Render();
1849 // Tap on the text editor
1850 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1851 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1853 // Render and notify
1854 application.SendNotification();
1855 application.Render();
1857 // Move at the end of the text.
1858 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1859 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1861 // Render and notify
1862 application.SendNotification();
1863 application.Render();
1865 for( unsigned int index = 0u; index < 10u; ++index )
1867 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1868 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1870 // Render and notify
1871 application.SendNotification();
1872 application.Render();
1876 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1878 // Render and notify
1879 application.SendNotification();
1880 application.Render();
1882 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1884 // Add some key events
1885 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1886 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1888 // Render and notify
1889 application.SendNotification();
1890 application.Render();
1892 for( unsigned int index = 0u; index < 10u; ++index )
1894 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1895 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1897 // Render and notify
1898 application.SendNotification();
1899 application.Render();
1903 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1905 // Render and notify
1906 application.SendNotification();
1907 application.Render();
1909 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1914 int utcDaliTextEditorEvent05(void)
1916 ToolkitTestApplication application;
1917 tet_infoline(" utcDaliTextEditorEvent05");
1919 // Checks if the highlight actor is created.
1921 TextEditor editor = TextEditor::New();
1922 DALI_TEST_CHECK( editor );
1924 Stage::GetCurrent().Add( editor );
1926 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1927 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1928 editor.SetSize( 50.f, 50.f );
1929 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1930 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1931 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1932 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1933 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1934 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1935 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1937 // Avoid a crash when core load gl resources.
1938 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1940 // Render and notify
1941 application.SendNotification();
1942 application.Render();
1944 // Tap on the text editor
1945 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1946 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1948 // Render and notify
1949 application.SendNotification();
1950 application.Render();
1952 // Move at the end of the text.
1953 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1954 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1956 // Render and notify
1957 application.SendNotification();
1958 application.Render();
1960 for( unsigned int index = 0u; index < 10u; ++index )
1963 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1965 // Render and notify
1966 application.SendNotification();
1967 application.Render();
1969 // Modify duration after scroll is enabled
1970 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1972 // Continuous scroll left to increase coverage
1973 for( unsigned int index = 0u; index < 10u; ++index )
1975 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1977 // Render and notify
1978 application.SendNotification();
1979 application.Render();
1981 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1982 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1983 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1984 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1985 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1987 // Press Escape to increase coverage
1988 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1989 application.SendNotification();
1990 application.Render();
1992 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1997 int utcDaliTextEditorEvent06(void)
1999 ToolkitTestApplication application;
2000 tet_infoline(" utcDaliTextEditorEvent06");
2002 // Checks if the highlight actor is created.
2004 TextEditor editor = TextEditor::New();
2005 DALI_TEST_CHECK( editor );
2007 Stage::GetCurrent().Add( editor );
2009 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2010 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2011 editor.SetSize( 100.f, 50.f );
2012 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2013 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2015 // Avoid a crash when core load gl resources.
2016 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2018 // Render and notify
2019 application.SendNotification();
2020 application.Render();
2022 // Tap on the text editor
2023 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2024 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2026 // Render and notify
2027 application.SendNotification();
2028 application.Render();
2030 // Move to seconds line of the text.
2031 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2033 // Render and notify
2034 application.SendNotification();
2035 application.Render();
2037 float layoutHeight = editor.GetHeightForWidth( 100.f );
2040 // Add another script characters ( glyph height is defferent )
2041 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "ኢ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2044 // Delete characters
2045 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2048 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2050 // Render and notify
2051 application.SendNotification();
2052 application.Render();
2054 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2057 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2058 application.SendNotification();
2059 application.Render();
2061 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062 application.SendNotification();
2063 application.Render();
2065 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066 application.SendNotification();
2067 application.Render();
2069 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2070 application.SendNotification();
2071 application.Render();
2073 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2074 application.SendNotification();
2075 application.Render();
2077 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078 application.SendNotification();
2079 application.Render();
2081 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2082 application.SendNotification();
2083 application.Render();
2088 int utcDaliTextEditorEvent07(void)
2090 ToolkitTestApplication application;
2091 tet_infoline(" utcDaliTextEditorEvent07");
2093 // Checks if the highlight actor is created.
2095 TextEditor editor = TextEditor::New();
2096 DALI_TEST_CHECK( editor );
2098 Stage::GetCurrent().Add( editor );
2100 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2101 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2102 editor.SetSize( 100.f, 50.f );
2103 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2104 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2106 // Avoid a crash when core load gl resources.
2107 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2109 // Render and notify
2110 application.SendNotification();
2111 application.Render();
2113 // Tap on the text editor
2114 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2115 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2117 // Render and notify
2118 application.SendNotification();
2119 application.Render();
2121 // Move to second line of the text.
2122 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2124 // Render and notify
2125 application.SendNotification();
2126 application.Render();
2128 // Select some text in the right of the current cursor position
2129 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2130 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2131 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2132 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2134 // Render and notify
2135 application.SendNotification();
2136 application.Render();
2138 // Cut the selected text
2139 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2140 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 ) );
2142 // Render and notify
2143 application.SendNotification();
2144 application.Render();
2146 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2148 // Select some text in the left of the current cursor position
2149 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2150 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2151 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "",DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2152 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2154 // Render and notify
2155 application.SendNotification();
2156 application.Render();
2158 // Copy the selected text
2159 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 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 ) );
2162 // Render and notify
2163 application.SendNotification();
2164 application.Render();
2166 // Move the cursor to the third line
2167 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2170 // Render and notify
2171 application.SendNotification();
2172 application.Render();
2174 // Paste the selected text at the current cursor position
2175 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2176 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 ) );
2178 // Render and notify
2179 application.SendNotification();
2180 application.Render();
2182 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2185 // Disable Shift Selection
2186 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2188 // Test to select some text in the right of the current cursor position
2189 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2191 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2194 // Render and notify
2195 application.SendNotification();
2196 application.Render();
2198 // Cut the selected text
2199 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2200 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 ) );
2202 // Render and notify
2203 application.SendNotification();
2204 application.Render();
2206 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2207 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2209 // Test to select some text in the left of the current cursor position
2210 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2212 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2215 // Render and notify
2216 application.SendNotification();
2217 application.Render();
2219 // Copy the selected text
2220 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 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 ) );
2223 // Render and notify
2224 application.SendNotification();
2225 application.Render();
2227 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2228 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2233 int utcDaliTextEditorEvent08(void)
2235 ToolkitTestApplication application;
2236 tet_infoline(" utcDaliTextEditorEvent08");
2238 // Checks if the highlight actor is released correctly.
2240 TextEditor editor = TextEditor::New();
2241 DALI_TEST_CHECK( editor );
2243 Stage::GetCurrent().Add( editor );
2245 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2246 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2247 editor.SetSize( 100.f, 50.f );
2248 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2249 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2251 // Avoid a crash when core load gl resources.
2252 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2254 // Render and notify
2255 application.SendNotification();
2256 application.Render();
2258 // Tap on the text editor
2259 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2260 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2262 // Render and notify
2263 application.SendNotification();
2264 application.Render();
2266 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2267 // Test to select some text in the left of the current cursor position
2268 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2269 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2270 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2273 // Render and notify
2274 application.SendNotification();
2275 application.Render();
2277 // Test to the left selection handle position and the right selection handle position
2278 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2280 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2283 // Render and notify
2284 application.SendNotification();
2285 application.Render();
2287 // Test to select full text in the left of the current cursor position
2288 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2291 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2292 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2295 // Render and notify
2296 application.SendNotification();
2297 application.Render();
2299 // Test to release the current full text selection
2300 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2303 // Render and notify
2304 application.SendNotification();
2305 application.Render();
2307 // Test to move the current cursor position correctly
2308 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2310 // Render and notify
2311 application.SendNotification();
2312 application.Render();
2315 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2317 // Render and notify
2318 application.SendNotification();
2319 application.Render();
2321 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2323 // Test to select some text in the right of the current cursor position
2324 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2325 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2326 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2328 // Render and notify
2329 application.SendNotification();
2330 application.Render();
2332 // Test the cursor position with right arrow key
2333 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2335 // Render and notify
2336 application.SendNotification();
2337 application.Render();
2340 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342 // Render and notify
2343 application.SendNotification();
2344 application.Render();
2346 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2348 // Test to select some text in the left of the current cursor position
2349 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 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 ) );
2351 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2352 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2355 // Render and notify
2356 application.SendNotification();
2357 application.Render();
2359 // Test the cursor position with left arrow key
2360 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2362 // Render and notify
2363 application.SendNotification();
2364 application.Render();
2367 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2369 // Render and notify
2370 application.SendNotification();
2371 application.Render();
2373 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2375 // Test to select some text in the right of the current cursor position
2376 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2378 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2379 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2381 // Render and notify
2382 application.SendNotification();
2383 application.Render();
2385 // Test the cursor position with left arrow key
2386 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2388 // Render and notify
2389 application.SendNotification();
2390 application.Render();
2393 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, "x", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2395 // Render and notify
2396 application.SendNotification();
2397 application.Render();
2399 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2401 // Test to select some text in the left of the current cursor position
2402 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2403 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2404 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407 // Render and notify
2408 application.SendNotification();
2409 application.Render();
2411 // Test the cursor position with right arrow key
2412 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2414 // Render and notify
2415 application.SendNotification();
2416 application.Render();
2419 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, "c", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2421 // Render and notify
2422 application.SendNotification();
2423 application.Render();
2425 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2430 int utcDaliTextEditorHandles(void)
2432 ToolkitTestApplication application;
2433 tet_infoline(" utcDaliTextEditorHandles");
2435 TextEditor editor = TextEditor::New();
2436 DALI_TEST_CHECK( editor );
2438 Stage::GetCurrent().Add( editor );
2440 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2441 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2442 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2443 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2445 Property::Map imagePropertyMap;
2446 imagePropertyMap["type"] = "BufferImage";
2447 imagePropertyMap["width"] = 40;
2448 imagePropertyMap["height"] = 40;
2450 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2451 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2452 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2453 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2455 editor.SetSize( 30.f, 500.f );
2456 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2457 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2459 // Avoid a crash when core load gl resources.
2460 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2462 // Render and notify
2463 application.SendNotification();
2464 application.Render();
2466 // Tap first to get the focus.
2467 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2468 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2470 // Render and notify
2471 application.SendNotification();
2472 application.Render();
2474 // Tap to create the grab handle.
2475 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2476 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2478 // Render and notify
2479 application.SendNotification();
2480 application.Render();
2482 // Get the active layer where the text's decoration is added.
2483 Actor activeLayer = editor.GetChildAt( 1u );
2485 // Get the handle's actor.
2486 Actor handle = activeLayer.GetChildAt( 1u );
2487 handle.SetSize( 100.f, 100.f );
2489 // Render and notify
2490 application.SendNotification();
2491 application.Render();
2493 // Touch the grab handle to set it as pressed.
2494 Vector2 touchPos( 10.0f, 50.0f );
2495 Dali::Integration::TouchEvent event;
2496 event = Dali::Integration::TouchEvent();
2497 event.AddPoint( GetPointDownInside( touchPos ) );
2498 application.ProcessEvent( event );
2500 // Render and notify
2501 application.SendNotification();
2502 application.Render();
2504 // drag grab handle right
2505 SendPan(application, Gesture::Possible, touchPos);
2506 SendPan(application, Gesture::Started, touchPos);
2508 Wait(application, 100);
2510 for(int i = 0;i<20;i++)
2512 SendPan(application, Gesture::Continuing, touchPos);
2517 SendPan(application, Gesture::Finished, touchPos);
2520 // Release the grab handle.
2521 event = Dali::Integration::TouchEvent();
2522 event.AddPoint( GetPointUpInside( touchPos ) );
2523 application.ProcessEvent( event );
2525 // Render and notify
2526 application.SendNotification();
2527 application.Render();
2529 // Tap first to get the focus.
2530 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2531 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2533 // Render and notify
2534 application.SendNotification();
2535 application.Render();
2537 // Double tap to select a word and create the selection handles.
2538 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2539 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2541 // Render and notify
2542 application.SendNotification();
2543 application.Render();
2545 touchPos = Vector2( 10.0f, 50.0f );
2547 // Touch the left selection handle to set it as pressed.
2548 event = Dali::Integration::TouchEvent();
2549 event.AddPoint( GetPointDownInside( touchPos ) );
2550 application.ProcessEvent( event );
2552 // Render and notify
2553 application.SendNotification();
2554 application.Render();
2556 // drag the left selection handle right
2557 SendPan(application, Gesture::Possible, touchPos);
2558 SendPan(application, Gesture::Started, touchPos);
2560 Wait(application, 100);
2562 for(int i = 0;i<20;i++)
2564 SendPan(application, Gesture::Continuing, touchPos);
2569 SendPan(application, Gesture::Finished, touchPos);
2572 // Release the left selection handle.
2573 event = Dali::Integration::TouchEvent();
2574 event.AddPoint( GetPointUpInside( touchPos ) );
2575 application.ProcessEvent( event );
2577 // Render and notify
2578 application.SendNotification();
2579 application.Render();
2584 int utcDaliTextEditorUnderPropertyStringP(void)
2586 ToolkitTestApplication application;
2587 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2588 TextEditor editor = TextEditor::New();
2589 DALI_TEST_CHECK( editor );
2591 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2593 Stage::GetCurrent().Add( editor );
2595 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2596 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2598 tet_infoline("Set underline settings with a map");
2599 // Check the input underline property
2600 Property::Map underlineMapSet;
2601 Property::Map underlineMapGet;
2602 underlineMapSet.Insert( "enable", "true" );
2603 underlineMapSet.Insert( "color", "blue" );
2604 underlineMapSet.Insert( "height", "2" );
2606 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2607 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2608 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2609 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2611 tet_infoline("Set underline settings with a string");
2612 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2613 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2616 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2618 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2619 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2620 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2621 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2623 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2628 int utcDaliTextEditorShadowPropertyStringP(void)
2630 ToolkitTestApplication application;
2631 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2633 TextEditor editor = TextEditor::New();
2635 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2637 Stage::GetCurrent().Add( editor );
2639 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2641 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2645 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2650 int utcDaliTextEditorFontStylePropertyStringP(void)
2652 ToolkitTestApplication application;
2653 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2655 TextEditor editor = TextEditor::New();
2657 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2659 Stage::GetCurrent().Add( editor );
2661 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2663 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2667 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2672 int utcDaliTextEditorGetPropertyLinecountP(void)
2674 ToolkitTestApplication application;
2676 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2680 TextEditor editor = TextEditor::New();
2681 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2682 editor.SetProperty( TextEditor::Property::TEXT,
2683 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2685 Stage::GetCurrent().Add( editor );
2687 editor.SetSize( 100.0f, 100.0f );
2688 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2689 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2691 editor.SetSize( 50.0f, 100.0f );
2692 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2693 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2698 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2701 ToolkitTestApplication application;
2702 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2704 TextEditor editor = TextEditor::New();
2705 DALI_TEST_CHECK( editor );
2707 Stage::GetCurrent().Add( editor );
2709 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2710 editor.SetSize( 50.f, 50.f );
2711 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2712 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2713 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2714 editor.SetKeyboardFocusable(true);
2716 bool startedCalled = false;
2717 bool finishedCalled = false;
2719 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2720 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2722 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2724 // Render and notify
2725 application.SendNotification();
2726 application.Render();
2728 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2729 application.SendNotification();
2730 application.Render(6000);
2732 application.SendNotification();
2733 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2734 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2739 int UtcDaliToolkitTextEditorTextWrapMode(void)
2741 ToolkitTestApplication application;
2742 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2746 TextEditor editor = TextEditor::New();
2747 editor.SetSize( 150.0f, 300.f );
2748 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2750 Stage::GetCurrent().Add( editor );
2752 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2753 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2755 application.SendNotification();
2756 application.Render();
2758 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2759 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2761 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2762 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2764 application.SendNotification();
2765 application.Render();
2767 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2768 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2770 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2771 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2773 application.SendNotification();
2774 application.Render();
2776 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2777 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2779 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2780 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2782 application.SendNotification();
2783 application.Render();
2785 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2786 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2791 int UtcDaliTextEditorSetPaddingProperty(void)
2793 ToolkitTestApplication application;
2794 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2796 TextEditor editor = TextEditor::New();
2797 DALI_TEST_CHECK( editor );
2798 editor.SetSize( 300.f, 50.f );
2799 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2800 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2801 Stage::GetCurrent().Add( editor );
2803 application.SendNotification();
2804 application.Render();
2806 Vector3 originalSize = editor.GetNaturalSize();
2808 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2810 application.SendNotification();
2811 application.Render();
2813 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2815 Vector3 paddingAddedSize = editor.GetNaturalSize();
2817 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2819 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2824 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2826 ToolkitTestApplication application;
2827 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2829 TextEditor editor = TextEditor::New();
2830 DALI_TEST_CHECK( editor );
2831 editor.SetSize( 300.f, 50.f );
2832 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2833 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2834 Stage::GetCurrent().Add( editor );
2836 application.SendNotification();
2837 application.Render();
2839 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2840 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2842 // Check the enable shift selection property
2843 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2844 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2846 application.SendNotification();
2847 application.Render();
2852 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2854 ToolkitTestApplication application;
2855 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2857 TextEditor editor = TextEditor::New();
2858 DALI_TEST_CHECK( editor );
2859 editor.SetSize( 300.f, 50.f );
2860 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2861 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2862 Stage::GetCurrent().Add( editor );
2864 application.SendNotification();
2865 application.Render();
2867 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2868 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2870 // Check the enable grab handle property
2871 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2872 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2874 application.SendNotification();
2875 application.Render();
2880 int UtcDaliTextEditorGetInputMethodContext(void)
2882 ToolkitTestApplication application;
2883 tet_infoline("UtcDaliTextEditorGetInputMethodContext");
2885 TextEditor editor = TextEditor::New();
2886 DALI_TEST_CHECK( DevelTextEditor::GetInputMethodContext( editor ) );