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& deviceName = DEFAULT_DEVICE_NAME,
221 const Device::Class::Type& deviceClass = Device::Class::NONE,
222 const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
224 return Integration::KeyEvent( keyName,
236 * Helper to generate PanGestureEvent
238 * @param[in] application Application instance
239 * @param[in] state The Gesture State
240 * @param[in] pos The current position of touch.
242 static void SendPan(ToolkitTestApplication& application, Gesture::State state, const Vector2& pos)
246 if( (state == Gesture::Started) ||
247 (state == Gesture::Possible) )
253 application.ProcessEvent( GeneratePan( state, last, pos, 16 ) );
260 * Simulate time passed by.
262 * @note this will always process at least 1 frame (1/60 sec)
264 * @param application Test application instance
265 * @param duration Time to pass in milliseconds.
266 * @return The actual time passed in milliseconds
268 static int Wait(ToolkitTestApplication& application, int duration = 0)
272 for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
274 application.SendNotification();
275 application.Render(RENDER_FRAME_INTERVAL);
276 time += RENDER_FRAME_INTERVAL;
282 Dali::Integration::Point GetPointDownInside( Vector2& pos )
284 Dali::Integration::Point point;
285 point.SetState( PointState::DOWN );
286 point.SetScreenPosition( pos );
290 Dali::Integration::Point GetPointUpInside( Vector2& pos )
292 Dali::Integration::Point point;
293 point.SetState( PointState::UP );
294 point.SetScreenPosition( pos );
298 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
300 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
302 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
304 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
306 Property::Value* valueSet = NULL;
307 if ( valueGet.first.type == Property::Key::INDEX )
309 valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
313 // Get Key is a string so searching Set Map for a string key
314 valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
317 if( NULL != valueSet )
319 if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
321 tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
324 else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
326 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
329 else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
331 tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
334 else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
336 tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
339 else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
341 Vector2 vector2Get = valueGet.second.Get<Vector2>();
342 Vector2 vector2Set = valueSet->Get<Vector2>();
343 tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
346 else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
348 Vector4 vector4Get = valueGet.second.Get<Vector4>();
349 Vector4 vector4Set = valueSet->Get<Vector4>();
350 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 );
356 if ( valueGet.first.type == Property::Key::INDEX )
358 tet_printf( " The key %d doesn't exist.", valueGet.first.indexKey );
362 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
372 class ScrollStateChangeCallback : public Dali::ConnectionTracker
375 ScrollStateChangeCallback(bool& startedCalled, bool& finishedCalled)
376 : mStartedCalled( startedCalled ),
377 mFinishedCalled( finishedCalled )
381 void Callback( TextEditor editor, TextEditor::Scroll::Type type )
383 if( type == TextEditor::Scroll::STARTED )
385 mStartedCalled = true;
387 else if( type == TextEditor::Scroll::FINISHED )
389 mFinishedCalled = true;
393 bool& mStartedCalled;
394 bool& mFinishedCalled;
399 int UtcDaliToolkitTextEditorConstructorP(void)
401 ToolkitTestApplication application;
402 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
403 TextEditor textEditor;
404 DALI_TEST_CHECK( !textEditor );
408 int UtcDaliToolkitTextEditorNewP(void)
410 ToolkitTestApplication application;
411 tet_infoline(" UtcDaliToolkitTextEditorNewP");
412 TextEditor textEditor = TextEditor::New();
413 DALI_TEST_CHECK( textEditor );
417 int UtcDaliToolkitTextEditorDownCastP(void)
419 ToolkitTestApplication application;
420 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
421 TextEditor textEditor1 = TextEditor::New();
422 BaseHandle object( textEditor1 );
424 TextEditor textEditor2 = TextEditor::DownCast( object );
425 DALI_TEST_CHECK( textEditor2 );
427 TextEditor textEditor3 = DownCast< TextEditor >( object );
428 DALI_TEST_CHECK( textEditor3 );
432 int UtcDaliToolkitTextEditorDownCastN(void)
434 ToolkitTestApplication application;
435 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
436 BaseHandle uninitializedObject;
437 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
438 DALI_TEST_CHECK( !textEditor1 );
440 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
441 DALI_TEST_CHECK( !textEditor2 );
445 int UtcDaliToolkitTextEditorCopyConstructorP(void)
447 ToolkitTestApplication application;
448 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
449 TextEditor textEditor = TextEditor::New();
450 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
452 TextEditor copy( textEditor );
453 DALI_TEST_CHECK( copy );
454 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
458 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
460 ToolkitTestApplication application;
461 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
462 TextEditor textEditor = TextEditor::New();
463 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
465 TextEditor copy = textEditor;
466 DALI_TEST_CHECK( copy );
467 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
471 int UtcDaliTextEditorNewP(void)
473 ToolkitTestApplication application;
474 tet_infoline(" UtcDaliToolkitTextEditorNewP");
475 TextEditor textEditor = TextEditor::New();
476 DALI_TEST_CHECK( textEditor );
480 // Positive test case for a method
481 int UtcDaliTextEditorGetPropertyP(void)
483 ToolkitTestApplication application;
484 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
485 TextEditor editor = TextEditor::New();
486 DALI_TEST_CHECK( editor );
488 // Check Property Indices are correct
489 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
490 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
491 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
492 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
493 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
494 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
495 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
496 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
497 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
498 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
499 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
500 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
501 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
502 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
503 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
504 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
505 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
506 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
507 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
508 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
509 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
510 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
511 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
512 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
513 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
514 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
515 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
516 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
517 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
518 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
520 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
521 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
522 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
523 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
524 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
525 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
526 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
527 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
528 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
529 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
530 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL ) == TextEditor::Property::SMOOTH_SCROLL );
531 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SMOOTH_SCROLL_DURATION ) == TextEditor::Property::SMOOTH_SCROLL_DURATION );
532 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SCROLL_BAR ) == TextEditor::Property::ENABLE_SCROLL_BAR );
533 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_SHOW_DURATION ) == TextEditor::Property::SCROLL_BAR_SHOW_DURATION );
534 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_BAR_FADE_DURATION ) == TextEditor::Property::SCROLL_BAR_FADE_DURATION );
535 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextEditor::Property::PIXEL_SIZE );
536 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_COUNT) == TextEditor::Property::LINE_COUNT );
537 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextEditor::Property::ENABLE_SELECTION );
538 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextEditor::Property::PLACEHOLDER );
539 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == DevelTextEditor::Property::PLACEHOLDER_TEXT );
540 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR );
541 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextEditor::Property::ENABLE_SHIFT_SELECTION );
542 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextEditor::Property::ENABLE_GRAB_HANDLE );
547 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
550 Property::Map imageMap;
551 imageMap[mapKey] =mapValue;
553 editor.SetProperty( property , imageMap );
554 Property::Value propValue = editor.GetProperty( property );
555 Property::Map* resultMap = propValue.GetMap();
557 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
565 // Positive test case for a method
566 int UtcDaliTextEditorSetPropertyP(void)
568 ToolkitTestApplication application;
569 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
570 TextEditor editor = TextEditor::New();
571 DALI_TEST_CHECK( editor );
572 Stage::GetCurrent().Add( editor );
574 // Note - we can't check the defaults since the stylesheets are platform-specific
576 // Check the render backend property.
577 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
578 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
580 // Check text property.
581 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
582 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
584 // Check text's color property
585 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
586 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
588 // Check font properties.
589 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
590 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
592 Property::Map fontStyleMapSet;
593 Property::Map fontStyleMapGet;
594 Property::Value* slantValue = NULL;
596 fontStyleMapSet.Insert( "weight", "bold" );
597 fontStyleMapSet.Insert( "width", "condensed" );
598 fontStyleMapSet.Insert( "slant", "italic" );
600 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
601 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
602 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
603 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
605 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
606 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
609 fontStyleMapSet.Clear();
610 fontStyleMapSet.Insert( "weight", "normal" );
611 fontStyleMapSet.Insert( "slant", "oblique" );
612 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
613 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
614 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
615 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
617 fontStyleMapSet.Clear();
618 fontStyleMapSet.Insert( "slant", "roman" );
619 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
620 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
622 // Replace 'roman' for 'normal'.
623 slantValue = fontStyleMapGet.Find( "slant" );
624 if( NULL != slantValue )
626 if( "normal" == slantValue->Get<std::string>() )
628 fontStyleMapGet["slant"] = "roman";
631 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
632 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
634 fontStyleMapSet.Clear();
636 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
637 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
638 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
639 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
641 // Check that the Alignment properties can be correctly set
642 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
643 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
645 // Check scroll properties.
646 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
647 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
648 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
649 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
651 // Check cursor properties
652 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
653 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
654 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
655 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
657 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
658 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
659 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
660 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
661 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
662 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
663 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
664 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
666 // Check handle images
667 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
668 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
669 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
670 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
671 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
673 // Check handle images
674 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
675 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
676 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
677 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
678 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
679 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
681 // Check the highlight color
682 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
683 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
685 // Decoration bounding box
686 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
687 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
689 // Check the enable markup property.
690 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
691 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
692 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
694 // Check input color property.
695 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
696 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
698 // Check input font properties.
699 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
700 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
702 fontStyleMapSet.Clear();
703 fontStyleMapSet.Insert( "weight", "bold" );
704 fontStyleMapSet.Insert( "width", "condensed" );
705 fontStyleMapSet.Insert( "slant", "italic" );
707 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
708 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
709 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
710 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
712 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
713 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
715 // Reset input font style.
716 fontStyleMapSet.Clear();
717 fontStyleMapSet.Insert( "weight", "normal" );
718 fontStyleMapSet.Insert( "slant", "oblique" );
720 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
721 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
722 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
723 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
725 fontStyleMapSet.Clear();
726 fontStyleMapSet.Insert( "slant", "roman" );
728 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
729 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
731 // Replace 'roman' for 'normal'.
732 slantValue = fontStyleMapGet.Find( "slant" );
733 if( NULL != slantValue )
735 if( "normal" == slantValue->Get<std::string>() )
737 fontStyleMapGet["slant"] = "roman";
740 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
741 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
743 fontStyleMapSet.Clear();
745 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
746 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
747 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
748 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
750 // Check the line spacing property
751 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
752 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
753 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
755 // Check the input line spacing property
756 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
757 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
758 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
760 // Check the underline property
762 Property::Map underlineMapSet;
763 Property::Map underlineMapGet;
765 underlineMapSet.Insert( "enable", "true" );
766 underlineMapSet.Insert( "color", "red" );
767 underlineMapSet.Insert( "height", "1" );
769 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
771 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
772 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
773 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
775 // Check the input underline property
776 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
777 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
779 // Check the shadow property
780 Property::Map shadowMapSet;
781 Property::Map shadowMapGet;
783 shadowMapSet.Insert( "color", Color::GREEN );
784 shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
785 shadowMapSet.Insert( "blurRadius", 3.0f );
787 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
789 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
790 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
791 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
793 // Check the input shadow property
794 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
795 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
797 // Check the emboss property
798 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
799 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
801 // Check the input emboss property
802 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
803 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
805 // Check the outline property
807 // Test string type first
808 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
809 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
810 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
812 // Then test the property map type
813 Property::Map outlineMapSet;
814 Property::Map outlineMapGet;
816 outlineMapSet["color"] = Color::RED;
817 outlineMapSet["width"] = 2.0f;
819 editor.SetProperty( TextEditor::Property::OUTLINE, outlineMapSet );
821 outlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::OUTLINE );
822 DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
823 DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
825 // Check the input outline property
826 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
827 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
829 // Check the smooth scroll property
830 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), false, TEST_LOCATION );
831 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
832 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
834 // Check the smooth scroll duration property
835 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
836 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
838 // Check the scroll bar property
839 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), false, TEST_LOCATION );
840 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
841 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
843 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
844 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
845 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
846 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
848 // Check the pixel size of font
849 editor.SetProperty( TextEditor::Property::PIXEL_SIZE, 20.f );
850 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
852 // Check placeholder text properties.
853 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
854 DALI_TEST_EQUALS( editor.GetProperty<std::string>( DevelTextEditor::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
856 // Check placeholder text's color property.
857 editor.SetProperty( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
858 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( DevelTextEditor::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
860 // Check the enable selection property
861 editor.SetProperty( TextEditor::Property::ENABLE_SELECTION, false );
862 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
864 // Check the placeholder property with pixel size
865 Property::Map placeholderPixelSizeMapSet;
866 Property::Map placeholderPixelSizeMapGet;
867 Property::Map placeholderFontstyleMap;
868 placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
869 placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
870 placeholderPixelSizeMapSet["color"] = Color::BLUE;
871 placeholderPixelSizeMapSet["fontFamily"] = "Arial";
872 placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
874 placeholderFontstyleMap.Insert( "weight", "bold" );
875 placeholderPixelSizeMapSet["fontStyle"] = placeholderFontstyleMap;
876 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
878 placeholderPixelSizeMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
879 DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
881 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
882 Property::Map placeholderConversionMap;
883 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
884 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
885 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
886 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
887 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
888 placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
890 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
892 // Check the placeholder property with point size
893 Property::Map placeholderMapSet;
894 Property::Map placeholderMapGet;
895 placeholderMapSet["text"] = "Setting Placeholder Text";
896 placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
897 placeholderMapSet["color"] = Color::RED;
898 placeholderMapSet["fontFamily"] = "Arial";
899 placeholderMapSet["pointSize"] = 12.0f;
900 // Check the placeholder font style property
901 placeholderFontstyleMap.Clear();
903 placeholderFontstyleMap.Insert( "weight", "bold" );
904 placeholderFontstyleMap.Insert( "width", "condensed" );
905 placeholderFontstyleMap.Insert( "slant", "italic" );
906 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
907 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
909 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
910 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
912 tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
913 placeholderConversionMap.Clear();
914 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderMapSet["text"];
915 placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderMapSet["textFocused"] ;
916 placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderMapSet["color"];
917 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
918 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderMapSet["fontFamily"];
919 placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderMapSet["pointSize"];
920 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
923 placeholderFontstyleMap.Clear();
924 placeholderFontstyleMap.Insert( "weight", "normal" );
925 placeholderFontstyleMap.Insert( "slant", "oblique" );
926 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
927 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
929 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
930 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
931 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
932 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
934 placeholderFontstyleMap.Clear();
935 placeholderFontstyleMap.Insert( "slant", "roman" );
936 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
937 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
939 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
941 placeholderFontstyleMap.Clear();
942 placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
944 editor.SetProperty( TextEditor::Property::PLACEHOLDER, placeholderMapSet );
945 placeholderMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::PLACEHOLDER );
946 DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
947 placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderMapSet["fontStyle"];
948 DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
950 editor.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
951 DALI_TEST_EQUALS( editor.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
953 application.SendNotification();
954 application.Render();
959 // Positive Atlas Text Renderer test
960 int utcDaliTextEditorAtlasRenderP(void)
962 ToolkitTestApplication application;
963 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
964 StyleManager styleManager = StyleManager::Get();
965 styleManager.ApplyDefaultTheme();
966 TextEditor editor = TextEditor::New();
967 DALI_TEST_CHECK( editor );
969 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
971 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
973 Stage::GetCurrent().Add( editor );
977 // Render some text with the shared atlas backend
978 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
979 application.SendNotification();
980 application.Render();
984 tet_result(TET_FAIL);
989 // Positive test for the textChanged signal.
990 int utcDaliTextEditorTextChangedP(void)
992 ToolkitTestApplication application;
993 tet_infoline(" utcDaliTextEditorTextChangedP");
994 TextEditor editor = TextEditor::New();
995 DALI_TEST_CHECK( editor );
997 Stage::GetCurrent().Add( editor );
999 // connect to the text changed signal.
1000 ConnectionTracker* testTracker = new ConnectionTracker();
1001 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
1002 bool textChangedSignal = false;
1003 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
1005 gTextChangedCallBackCalled = false;
1006 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
1007 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1008 DALI_TEST_CHECK( textChangedSignal );
1010 application.SendNotification();
1012 editor.SetKeyInputFocus();
1014 gTextChangedCallBackCalled = false;
1015 application.ProcessEvent( GenerateKey( "D", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1016 DALI_TEST_CHECK( gTextChangedCallBackCalled );
1021 int utcDaliTextEditorInputStyleChanged01(void)
1023 ToolkitTestApplication application;
1024 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
1026 // The text-editor emits signals when the input style changes. These changes of style are
1027 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1028 // can't be emitted during the size negotiation as the callbacks may update the UI.
1029 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1030 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1031 application.CreateAdaptor();
1035 char* pathNamePtr = get_current_dir_name();
1036 const std::string pathName( pathNamePtr );
1037 free( pathNamePtr );
1039 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1040 fontClient.SetDpi( 93u, 93u );
1042 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1043 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1045 TextEditor editor = TextEditor::New();
1046 DALI_TEST_CHECK( editor );
1049 editor.SetSize( 300.f, 50.f );
1050 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1051 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1053 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1054 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1056 // connect to the text changed signal.
1057 ConnectionTracker* testTracker = new ConnectionTracker();
1058 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1059 bool inputStyleChangedSignal = false;
1060 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1062 Stage::GetCurrent().Add( editor );
1064 // Render and notify
1065 application.SendNotification();
1066 application.Render();
1068 // Executes the idle callbacks added by the text control on the change of input style.
1069 application.RunIdles();
1071 gInputStyleChangedCallbackCalled = false;
1072 gInputStyleMask = TextEditor::InputStyle::NONE;
1073 inputStyleChangedSignal = false;
1075 // Create a tap event to touch the text editor.
1076 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1077 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
1079 // Render and notify
1080 application.SendNotification();
1081 application.Render();
1083 // Executes the idle callbacks added by the text control on the change of input style.
1084 application.RunIdles();
1086 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1087 if( gInputStyleChangedCallbackCalled )
1089 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
1091 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1092 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1094 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1095 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1097 DALI_TEST_CHECK( inputStyleChangedSignal );
1099 gInputStyleChangedCallbackCalled = false;
1100 gInputStyleMask = TextEditor::InputStyle::NONE;
1101 inputStyleChangedSignal = false;
1103 // Create a tap event to touch the text editor.
1104 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1105 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1107 // Render and notify
1108 application.SendNotification();
1109 application.Render();
1111 // Executes the idle callbacks added by the text control on the change of input style.
1112 application.RunIdles();
1114 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1115 DALI_TEST_CHECK( !inputStyleChangedSignal );
1117 gInputStyleChangedCallbackCalled = false;
1118 gInputStyleMask = TextEditor::InputStyle::NONE;
1119 inputStyleChangedSignal = false;
1121 // Create a tap event to touch the text editor.
1122 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1123 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
1125 // Render and notify
1126 application.SendNotification();
1127 application.Render();
1129 // Executes the idle callbacks added by the text control on the change of input style.
1130 application.RunIdles();
1132 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1133 if( gInputStyleChangedCallbackCalled )
1135 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
1137 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1138 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1140 DALI_TEST_CHECK( inputStyleChangedSignal );
1142 gInputStyleChangedCallbackCalled = false;
1143 gInputStyleMask = TextEditor::InputStyle::NONE;
1144 inputStyleChangedSignal = false;
1146 // Create a tap event to touch the text editor.
1147 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1148 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
1150 // Render and notify
1151 application.SendNotification();
1152 application.Render();
1154 // Executes the idle callbacks added by the text control on the change of input style.
1155 application.RunIdles();
1157 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1158 if( gInputStyleChangedCallbackCalled )
1160 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1162 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1163 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1165 Property::Map fontStyleMapSet;
1166 Property::Map fontStyleMapGet;
1168 fontStyleMapSet.Insert( "weight", "bold" );
1170 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1171 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1172 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1174 DALI_TEST_CHECK( inputStyleChangedSignal );
1176 gInputStyleChangedCallbackCalled = false;
1177 gInputStyleMask = TextEditor::InputStyle::NONE;
1178 inputStyleChangedSignal = false;
1180 // Create a tap event to touch the text editor.
1181 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1182 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
1184 // Render and notify
1185 application.SendNotification();
1186 application.Render();
1188 // Executes the idle callbacks added by the text control on the change of input style.
1189 application.RunIdles();
1191 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1192 DALI_TEST_CHECK( !inputStyleChangedSignal );
1194 gInputStyleChangedCallbackCalled = false;
1195 gInputStyleMask = TextEditor::InputStyle::NONE;
1196 inputStyleChangedSignal = false;
1198 // Create a tap event to touch the text editor.
1199 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1200 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
1202 // Render and notify
1203 application.SendNotification();
1204 application.Render();
1206 // Executes the idle callbacks added by the text control on the change of input style.
1207 application.RunIdles();
1209 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1210 if( gInputStyleChangedCallbackCalled )
1212 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
1214 Property::Map fontStyleMapSet;
1215 Property::Map fontStyleMapGet;
1217 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
1218 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1219 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1221 DALI_TEST_CHECK( inputStyleChangedSignal );
1223 gInputStyleChangedCallbackCalled = false;
1224 gInputStyleMask = TextEditor::InputStyle::NONE;
1225 inputStyleChangedSignal = false;
1227 // Create a tap event to touch the text editor.
1228 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1229 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
1231 // Render and notify
1232 application.SendNotification();
1233 application.Render();
1235 // Executes the idle callbacks added by the text control on the change of input style.
1236 application.RunIdles();
1238 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1239 DALI_TEST_CHECK( !inputStyleChangedSignal );
1244 int utcDaliTextEditorInputStyleChanged02(void)
1246 ToolkitTestApplication application;
1247 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
1249 // The text-editor emits signals when the input style changes. These changes of style are
1250 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1251 // can't be emitted during the size negotiation as the callbacks may update the UI.
1252 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
1253 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
1254 application.CreateAdaptor();
1258 char* pathNamePtr = get_current_dir_name();
1259 const std::string pathName( pathNamePtr );
1260 free( pathNamePtr );
1262 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1263 fontClient.SetDpi( 93u, 93u );
1265 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1266 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1268 TextEditor editor = TextEditor::New();
1269 DALI_TEST_CHECK( editor );
1272 editor.SetSize( 300.f, 50.f );
1273 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1274 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1276 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
1277 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>" );
1279 // connect to the text changed signal.
1280 ConnectionTracker* testTracker = new ConnectionTracker();
1281 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1282 bool inputStyleChangedSignal = false;
1283 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
1285 Stage::GetCurrent().Add( editor );
1287 // Render and notify
1288 application.SendNotification();
1289 application.Render();
1291 // Executes the idle callbacks added by the text control on the change of input style.
1292 application.RunIdles();
1294 gInputStyleChangedCallbackCalled = false;
1295 gInputStyleMask = TextEditor::InputStyle::NONE;
1296 inputStyleChangedSignal = false;
1298 // Create a tap event to touch the text editor.
1299 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1300 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
1301 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1302 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
1304 // Render and notify
1305 application.SendNotification();
1306 application.Render();
1308 // Executes the idle callbacks added by the text control on the change of input style.
1309 application.RunIdles();
1311 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1312 if( gInputStyleChangedCallbackCalled )
1314 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1315 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
1316 TextEditor::InputStyle::POINT_SIZE |
1317 TextEditor::InputStyle::COLOR ),
1320 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1321 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1323 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1324 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1326 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
1327 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1329 DALI_TEST_CHECK( inputStyleChangedSignal );
1331 gInputStyleChangedCallbackCalled = false;
1332 gInputStyleMask = TextEditor::InputStyle::NONE;
1333 inputStyleChangedSignal = false;
1335 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1337 // Render and notify
1338 application.SendNotification();
1339 application.Render();
1341 // Executes the idle callbacks added by the text control on the change of input style.
1342 application.RunIdles();
1344 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1345 if( gInputStyleChangedCallbackCalled )
1347 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1348 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1351 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1352 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
1354 DALI_TEST_CHECK( inputStyleChangedSignal );
1356 gInputStyleChangedCallbackCalled = false;
1357 gInputStyleMask = TextEditor::InputStyle::NONE;
1358 inputStyleChangedSignal = false;
1360 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1362 // Render and notify
1363 application.SendNotification();
1364 application.Render();
1366 // Executes the idle callbacks added by the text control on the change of input style.
1367 application.RunIdles();
1369 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1370 DALI_TEST_CHECK( !inputStyleChangedSignal );
1372 gInputStyleChangedCallbackCalled = false;
1373 gInputStyleMask = TextEditor::InputStyle::NONE;
1374 inputStyleChangedSignal = false;
1376 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1378 // Render and notify
1379 application.SendNotification();
1380 application.Render();
1382 // Executes the idle callbacks added by the text control on the change of input style.
1383 application.RunIdles();
1385 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1386 if( gInputStyleChangedCallbackCalled )
1388 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1389 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1392 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1393 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1395 DALI_TEST_CHECK( inputStyleChangedSignal );
1397 gInputStyleChangedCallbackCalled = false;
1398 gInputStyleMask = TextEditor::InputStyle::NONE;
1399 inputStyleChangedSignal = false;
1401 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1403 Property::Map fontStyleMapSet;
1404 fontStyleMapSet.Insert( "weight", "thin" );
1405 fontStyleMapSet.Insert( "width", "condensed" );
1406 fontStyleMapSet.Insert( "slant", "italic" );
1408 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1409 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1410 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1412 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1413 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1414 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1415 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1417 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1419 // Render and notify
1420 application.SendNotification();
1421 application.Render();
1423 // Executes the idle callbacks added by the text control on the change of input style.
1424 application.RunIdles();
1426 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1427 DALI_TEST_CHECK( !inputStyleChangedSignal );
1429 // Create a tap event to touch the text editor.
1430 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1431 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1433 // Render and notify
1434 application.SendNotification();
1435 application.Render();
1437 // Executes the idle callbacks added by the text control on the change of input style.
1438 application.RunIdles();
1440 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1441 if( gInputStyleChangedCallbackCalled )
1443 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1444 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1445 TextEditor::InputStyle::POINT_SIZE |
1446 TextEditor::InputStyle::FONT_STYLE |
1447 TextEditor::InputStyle::LINE_SPACING |
1448 TextEditor::InputStyle::UNDERLINE |
1449 TextEditor::InputStyle::SHADOW |
1450 TextEditor::InputStyle::EMBOSS |
1451 TextEditor::InputStyle::OUTLINE ),
1454 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1455 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1457 DALI_TEST_CHECK( inputStyleChangedSignal );
1459 gInputStyleChangedCallbackCalled = false;
1460 gInputStyleMask = TextEditor::InputStyle::NONE;
1461 inputStyleChangedSignal = false;
1463 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1465 fontStyleMapSet.Clear();
1466 fontStyleMapSet.Insert( "weight", "black" );
1467 fontStyleMapSet.Insert( "width", "expanded" );
1468 fontStyleMapSet.Insert( "slant", "oblique" );
1470 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1472 // Create a tap event to touch the text editor.
1473 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1474 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1476 // Render and notify
1477 application.SendNotification();
1478 application.Render();
1480 // Executes the idle callbacks added by the text control on the change of input style.
1481 application.RunIdles();
1483 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1484 if( gInputStyleChangedCallbackCalled )
1486 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1487 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1488 TextEditor::InputStyle::POINT_SIZE |
1489 TextEditor::InputStyle::FONT_STYLE ),
1492 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1493 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1495 DALI_TEST_CHECK( inputStyleChangedSignal );
1500 int utcDaliTextEditorEvent01(void)
1502 ToolkitTestApplication application;
1503 tet_infoline(" utcDaliTextEditorEvent01");
1505 // Creates a tap event. After creating a tap event the text editor should
1506 // have the focus and add text with key events should be possible.
1508 TextEditor editor = TextEditor::New();
1509 DALI_TEST_CHECK( editor );
1511 Stage::GetCurrent().Add( editor );
1513 editor.SetSize( 300.f, 50.f );
1514 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1515 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1517 // Avoid a crash when core load gl resources.
1518 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1520 // Render and notify
1521 application.SendNotification();
1522 application.Render();
1524 // Add a key event but as the text editor has not the focus it should do nothing.
1525 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1527 // Render and notify
1528 application.SendNotification();
1529 application.Render();
1531 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1533 // Create a tap event to touch the text editor.
1534 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1535 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1537 // Render and notify
1538 application.SendNotification();
1539 application.Render();
1541 // Now the text editor has the focus, so it can handle the key events.
1542 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1543 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1545 // Render and notify
1546 application.SendNotification();
1547 application.Render();
1549 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1551 // Create a second text editor and send key events to it.
1552 TextEditor editor2 = TextEditor::New();
1554 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1555 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1556 editor2.SetSize( 100.f, 100.f );
1557 editor2.SetPosition( 100.f, 100.f );
1559 Stage::GetCurrent().Add( editor2 );
1561 // Render and notify
1562 application.SendNotification();
1563 application.Render();
1565 // Create a tap event on the second text editor.
1566 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1567 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1569 // Render and notify
1570 application.SendNotification();
1571 application.Render();
1573 // The second text editor has the focus. It should handle the key events.
1574 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1575 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1577 // Render and notify
1578 application.SendNotification();
1579 application.Render();
1581 // Check the text has been added to the second text editor.
1582 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1587 int utcDaliTextEditorEvent02(void)
1589 ToolkitTestApplication application;
1590 tet_infoline(" utcDaliTextEditorEvent02");
1592 // Checks if the right number of actors are created.
1594 TextEditor editor = TextEditor::New();
1595 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1596 DALI_TEST_CHECK( editor );
1598 Stage::GetCurrent().Add( editor );
1600 editor.SetSize( 300.f, 50.f );
1601 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1602 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1604 // Avoid a crash when core load gl resources.
1605 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1607 // Render and notify
1608 application.SendNotification();
1609 application.Render();
1611 // Check there are the expected number of children (the stencil).
1612 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1614 Actor stencil = editor.GetChildAt( 0u );
1616 // Create a tap event to touch the text editor.
1617 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1618 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1620 // Render and notify
1621 application.SendNotification();
1622 application.Render();
1624 Actor layer = editor.GetChildAt( 1u );
1625 DALI_TEST_CHECK( layer.IsLayer() );
1627 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1628 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1630 // Now the text editor has the focus, so it can handle the key events.
1631 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1632 application.ProcessEvent( GenerateKey( "a", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1634 // Render and notify
1635 application.SendNotification();
1636 application.Render();
1638 // Checks the cursor and the renderer have been created.
1639 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1640 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1642 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1643 DALI_TEST_CHECK( cursor );
1645 // The stencil actor has a container with all the actors which contain the text renderers.
1646 Actor container = stencil.GetChildAt( 0u );
1647 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1649 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1650 DALI_TEST_CHECK( renderer );
1653 // Move the cursor and check the position changes.
1654 Vector3 position1 = cursor.GetCurrentPosition();
1656 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1657 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1659 // Render and notify
1660 application.SendNotification();
1661 application.Render();
1663 Vector3 position2 = cursor.GetCurrentPosition();
1665 DALI_TEST_CHECK( position2.x < position1.x );
1667 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1668 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1670 // Render and notify
1671 application.SendNotification();
1672 application.Render();
1674 Vector3 position3 = cursor.GetCurrentPosition();
1676 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1678 // Send some taps and check the cursor positions.
1680 // Try to tap at the beginning.
1681 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1682 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1684 // Render and notify
1685 application.SendNotification();
1686 application.Render();
1688 // Cursor position should be the same than position1.
1689 Vector3 position4 = cursor.GetCurrentPosition();
1691 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1693 // Tap away from the start position.
1694 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1695 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1697 // Render and notify
1698 application.SendNotification();
1699 application.Render();
1701 Vector3 position5 = cursor.GetCurrentPosition();
1703 DALI_TEST_CHECK( position5.x > position4.x );
1705 // Remove all the text.
1706 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1707 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1708 editor.SetProperty( TextEditor::Property::TEXT, "" );
1710 // Render and notify
1711 application.SendNotification();
1712 application.Render();
1714 // Cursor position should be the same than position2.
1715 Vector3 position6 = cursor.GetCurrentPosition();
1717 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1719 // Should not be a renderer.
1720 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1725 int utcDaliTextEditorEvent03(void)
1727 ToolkitTestApplication application;
1728 tet_infoline(" utcDaliTextEditorEvent03");
1730 // Checks if the highlight actor is created.
1732 TextEditor editor = TextEditor::New();
1733 DALI_TEST_CHECK( editor );
1735 Stage::GetCurrent().Add( editor );
1737 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1738 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1739 editor.SetSize( 30.f, 50.f );
1740 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1741 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1743 // Avoid a crash when core load gl resources.
1744 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1746 // Render and notify
1747 application.SendNotification();
1748 application.Render();
1750 // Send some taps and check text controller with clipboard window
1751 Dali::Clipboard clipboard = Clipboard::Get();
1752 clipboard.ShowClipboard();
1753 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1754 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1755 clipboard.HideClipboard();
1757 // Render and notify
1758 application.SendNotification();
1759 application.Render();
1761 // Tap first to get the focus.
1762 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1763 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1765 // Render and notify
1766 application.SendNotification();
1767 application.Render();
1769 // Double tap to select a word.
1770 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1771 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1773 // Render and notify
1774 application.SendNotification();
1775 application.Render();
1777 // The stencil actor should have two actors: the renderer and the highlight actor.
1778 Actor stencil = editor.GetChildAt( 0u );
1780 // Highlight needs to be drawn before text, so should come first in child order
1781 Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
1782 DALI_TEST_CHECK( highlight );
1784 // The stencil actor has a container with all the actors which contain the text renderers.
1785 Actor container = stencil.GetChildAt( 1u );
1786 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1788 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1789 DALI_TEST_CHECK( renderer );
1792 // Double tap out of bounds
1793 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1794 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 29.f, 25.0f ) ) );
1796 // Render and notify
1797 application.SendNotification();
1798 application.Render();
1800 // The stencil actor should have one actors: the renderer actor.
1801 stencil = editor.GetChildAt( 0u );
1803 // The stencil actor has a container with all the actors which contain the text renderers.
1804 container = stencil.GetChildAt( 0u );
1805 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1807 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1808 DALI_TEST_CHECK( renderer );
1812 application.ProcessEvent( GenerateLongPress( Gesture::Possible, 1u, Vector2( 1.f, 25.0f ) ) );
1813 application.ProcessEvent( GenerateLongPress( Gesture::Started, 1u, Vector2( 1.f, 25.0f ) ) );
1815 // Render and notify
1816 application.SendNotification();
1817 application.Render();
1822 int utcDaliTextEditorEvent04(void)
1824 ToolkitTestApplication application;
1825 tet_infoline(" utcDaliTextEditorEvent04");
1827 // Checks if the highlight actor is created.
1829 TextEditor editor = TextEditor::New();
1830 DALI_TEST_CHECK( editor );
1832 Stage::GetCurrent().Add( editor );
1834 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1835 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1836 editor.SetSize( 100.f, 50.f );
1837 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1838 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1840 // Avoid a crash when core load gl resources.
1841 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1843 // Render and notify
1844 application.SendNotification();
1845 application.Render();
1847 // Tap on the text editor
1848 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1849 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1851 // Render and notify
1852 application.SendNotification();
1853 application.Render();
1855 // Move at the end of the text.
1856 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1857 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1859 // Render and notify
1860 application.SendNotification();
1861 application.Render();
1863 for( unsigned int index = 0u; index < 10u; ++index )
1865 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1866 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1868 // Render and notify
1869 application.SendNotification();
1870 application.Render();
1874 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1876 // Render and notify
1877 application.SendNotification();
1878 application.Render();
1880 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1882 // Add some key events
1883 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1884 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1886 // Render and notify
1887 application.SendNotification();
1888 application.Render();
1890 for( unsigned int index = 0u; index < 10u; ++index )
1892 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1893 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1895 // Render and notify
1896 application.SendNotification();
1897 application.Render();
1901 application.ProcessEvent( GenerateKey( " ", " ", KEY_WHITE_SPACE_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1903 // Render and notify
1904 application.SendNotification();
1905 application.Render();
1907 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1912 int utcDaliTextEditorEvent05(void)
1914 ToolkitTestApplication application;
1915 tet_infoline(" utcDaliTextEditorEvent05");
1917 // Checks if the highlight actor is created.
1919 TextEditor editor = TextEditor::New();
1920 DALI_TEST_CHECK( editor );
1922 Stage::GetCurrent().Add( editor );
1924 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1925 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1926 editor.SetSize( 50.f, 50.f );
1927 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1928 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1929 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
1930 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.2f );
1931 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
1932 editor.SetProperty( TextEditor::Property::SCROLL_BAR_SHOW_DURATION, 0.3f );
1933 editor.SetProperty( TextEditor::Property::SCROLL_BAR_FADE_DURATION, 0.2f );
1935 // Avoid a crash when core load gl resources.
1936 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1938 // Render and notify
1939 application.SendNotification();
1940 application.Render();
1942 // Tap on the text editor
1943 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1944 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1946 // Render and notify
1947 application.SendNotification();
1948 application.Render();
1950 // Move at the end of the text.
1951 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1952 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1954 // Render and notify
1955 application.SendNotification();
1956 application.Render();
1958 for( unsigned int index = 0u; index < 10u; ++index )
1961 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1963 // Render and notify
1964 application.SendNotification();
1965 application.Render();
1967 // Modify duration after scroll is enabled
1968 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL_DURATION, 0.1f );
1970 // Continuous scroll left to increase coverage
1971 for( unsigned int index = 0u; index < 10u; ++index )
1973 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1975 // Render and notify
1976 application.SendNotification();
1977 application.Render();
1979 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SMOOTH_SCROLL_DURATION ), 0.1f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1980 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::SMOOTH_SCROLL ), true, TEST_LOCATION );
1981 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_SCROLL_BAR ), true, TEST_LOCATION );
1982 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_SHOW_DURATION ), 0.3f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1983 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_BAR_FADE_DURATION ), 0.2f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1985 // Press Escape to increase coverage
1986 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::Up, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1987 application.SendNotification();
1988 application.Render();
1990 DALI_TEST_CHECK( !editor.HasKeyInputFocus() );
1995 int utcDaliTextEditorEvent06(void)
1997 ToolkitTestApplication application;
1998 tet_infoline(" utcDaliTextEditorEvent06");
2000 // Checks if the highlight actor is created.
2002 TextEditor editor = TextEditor::New();
2003 DALI_TEST_CHECK( editor );
2005 Stage::GetCurrent().Add( editor );
2007 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2008 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2009 editor.SetSize( 100.f, 50.f );
2010 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2011 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2013 // Avoid a crash when core load gl resources.
2014 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2016 // Render and notify
2017 application.SendNotification();
2018 application.Render();
2020 // Tap on the text editor
2021 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2022 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2024 // Render and notify
2025 application.SendNotification();
2026 application.Render();
2028 // Move to seconds line of the text.
2029 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2031 // Render and notify
2032 application.SendNotification();
2033 application.Render();
2035 float layoutHeight = editor.GetHeightForWidth( 100.f );
2038 // Add another script characters ( glyph height is defferent )
2039 application.ProcessEvent( GenerateKey( "d", "ㅁ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2040 application.ProcessEvent( GenerateKey( "d", "ኢ", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2042 // Delete characters
2043 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2044 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2046 DALI_TEST_EQUALS( layoutHeight, editor.GetHeightForWidth( 100.f ), TEST_LOCATION );
2048 // Render and notify
2049 application.SendNotification();
2050 application.Render();
2052 DALI_TEST_EQUALS( "Hello\nworld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2055 application.ProcessEvent( GenerateKey( "", "", 0, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2056 application.SendNotification();
2057 application.Render();
2059 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2060 application.SendNotification();
2061 application.Render();
2063 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_UP, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2064 application.SendNotification();
2065 application.Render();
2067 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_VOLUME_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2068 application.SendNotification();
2069 application.Render();
2071 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2072 application.SendNotification();
2073 application.Render();
2075 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2076 application.SendNotification();
2077 application.Render();
2079 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2080 application.SendNotification();
2081 application.Render();
2086 int utcDaliTextEditorEvent07(void)
2088 ToolkitTestApplication application;
2089 tet_infoline(" utcDaliTextEditorEvent07");
2091 // Checks if the highlight actor is created.
2093 TextEditor editor = TextEditor::New();
2094 DALI_TEST_CHECK( editor );
2096 Stage::GetCurrent().Add( editor );
2098 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworld\nHello world" );
2099 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2100 editor.SetSize( 100.f, 50.f );
2101 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2102 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2104 // Avoid a crash when core load gl resources.
2105 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2107 // Render and notify
2108 application.SendNotification();
2109 application.Render();
2111 // Tap on the text editor
2112 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2113 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2115 // Render and notify
2116 application.SendNotification();
2117 application.Render();
2119 // Move to second line of the text.
2120 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2122 // Render and notify
2123 application.SendNotification();
2124 application.Render();
2126 // Select some text in the right of the current cursor position
2127 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2128 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2129 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2130 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2132 // Render and notify
2133 application.SendNotification();
2134 application.Render();
2136 // Cut the selected text
2137 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2138 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2140 // Render and notify
2141 application.SendNotification();
2142 application.Render();
2144 DALI_TEST_EQUALS( "Hello\nld\nHello world", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2146 // Select some text in the left of the current cursor position
2147 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2148 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2149 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2150 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2152 // Render and notify
2153 application.SendNotification();
2154 application.Render();
2156 // Copy the selected text
2157 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2158 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2160 // Render and notify
2161 application.SendNotification();
2162 application.Render();
2164 // Move the cursor to the third line
2165 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2166 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2168 // Render and notify
2169 application.SendNotification();
2170 application.Render();
2172 // Paste the selected text at the current cursor position
2173 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2174 application.ProcessEvent( GenerateKey( "v", "v", KEY_V_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2176 // Render and notify
2177 application.SendNotification();
2178 application.Render();
2180 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2183 // Disable Shift Selection
2184 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2186 // Test to select some text in the right of the current cursor position
2187 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2189 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2190 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2192 // Render and notify
2193 application.SendNotification();
2194 application.Render();
2196 // Cut the selected text
2197 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2198 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2200 // Render and notify
2201 application.SendNotification();
2202 application.Render();
2204 // The text isn't selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2205 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2207 // Test to select some text in the left of the current cursor position
2208 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2209 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2213 // Render and notify
2214 application.SendNotification();
2215 application.Render();
2217 // Copy the selected text
2218 application.ProcessEvent( GenerateKey( "", "", Dali::DevelKey::DALI_KEY_CONTROL_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2219 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, KEY_CONTROL_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2221 // Render and notify
2222 application.SendNotification();
2223 application.Render();
2225 // The text is not selected and not changed because of 'SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false )'
2226 DALI_TEST_EQUALS( "Hello\nld\nHello lo\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2231 int utcDaliTextEditorEvent08(void)
2233 ToolkitTestApplication application;
2234 tet_infoline(" utcDaliTextEditorEvent08");
2236 // Checks if the highlight actor is released correctly.
2238 TextEditor editor = TextEditor::New();
2239 DALI_TEST_CHECK( editor );
2241 Stage::GetCurrent().Add( editor );
2243 editor.SetProperty( TextEditor::Property::TEXT, "DALi" );
2244 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2245 editor.SetSize( 100.f, 50.f );
2246 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2247 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2249 // Avoid a crash when core load gl resources.
2250 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2252 // Render and notify
2253 application.SendNotification();
2254 application.Render();
2256 // Tap on the text editor
2257 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2258 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2260 // Render and notify
2261 application.SendNotification();
2262 application.Render();
2264 // When the left selection handle and the right selection handle are at the same position, the highlight box should be deactivated.
2265 // Test to select some text in the left of the current cursor position
2266 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2267 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2268 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2269 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271 // Render and notify
2272 application.SendNotification();
2273 application.Render();
2275 // Test to the left selection handle position and the right selection handle position
2276 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2277 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2278 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2279 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2281 // Render and notify
2282 application.SendNotification();
2283 application.Render();
2285 // Test to select full text in the left of the current cursor position
2286 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2287 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2288 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2289 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2290 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2291 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2293 // Render and notify
2294 application.SendNotification();
2295 application.Render();
2297 // Test to release the current full text selection
2298 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2299 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2301 // Render and notify
2302 application.SendNotification();
2303 application.Render();
2305 // Test to move the current cursor position correctly
2306 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2308 // Render and notify
2309 application.SendNotification();
2310 application.Render();
2313 application.ProcessEvent( GenerateKey( "d", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2315 // Render and notify
2316 application.SendNotification();
2317 application.Render();
2319 DALI_TEST_EQUALS( "DdALi", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2321 // Test to select some text in the right of the current cursor position
2322 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2323 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2324 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2326 // Render and notify
2327 application.SendNotification();
2328 application.Render();
2330 // Test the cursor position with right arrow key
2331 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2333 // Render and notify
2334 application.SendNotification();
2335 application.Render();
2338 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2340 // Render and notify
2341 application.SendNotification();
2342 application.Render();
2344 DALI_TEST_EQUALS( "DdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2346 // Test to select some text in the left of the current cursor position
2347 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2348 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2349 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2350 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2351 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2353 // Render and notify
2354 application.SendNotification();
2355 application.Render();
2357 // Test the cursor position with left arrow key
2358 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360 // Render and notify
2361 application.SendNotification();
2362 application.Render();
2365 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2367 // Render and notify
2368 application.SendNotification();
2369 application.Render();
2371 DALI_TEST_EQUALS( "DcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2373 // Test to select some text in the right of the current cursor position
2374 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2375 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2379 // Render and notify
2380 application.SendNotification();
2381 application.Render();
2383 // Test the cursor position with left arrow key
2384 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2386 // Render and notify
2387 application.SendNotification();
2388 application.Render();
2391 application.ProcessEvent( GenerateKey( "x", "x", KEY_X_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2393 // Render and notify
2394 application.SendNotification();
2395 application.Render();
2397 DALI_TEST_EQUALS( "DcxdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2399 // Test to select some text in the left of the current cursor position
2400 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2401 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2402 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2403 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2405 // Render and notify
2406 application.SendNotification();
2407 application.Render();
2409 // Test the cursor position with right arrow key
2410 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2412 // Render and notify
2413 application.SendNotification();
2414 application.Render();
2417 application.ProcessEvent( GenerateKey( "c", "c", KEY_C_CODE, 0, 0, Integration::KeyEvent::Down, DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2419 // Render and notify
2420 application.SendNotification();
2421 application.Render();
2423 DALI_TEST_EQUALS( "DcxcdALci", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
2428 int utcDaliTextEditorHandles(void)
2430 ToolkitTestApplication application;
2431 tet_infoline(" utcDaliTextEditorHandles");
2433 TextEditor editor = TextEditor::New();
2434 DALI_TEST_CHECK( editor );
2436 Stage::GetCurrent().Add( editor );
2438 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
2439 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2440 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, HANDLE_IMAGE_FILE_NAME );
2441 editor.SetProperty( TextEditor::Property::SMOOTH_SCROLL, true );
2443 Property::Map imagePropertyMap;
2444 imagePropertyMap["type"] = "BufferImage";
2445 imagePropertyMap["width"] = 40;
2446 imagePropertyMap["height"] = 40;
2448 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, imagePropertyMap );
2449 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, imagePropertyMap );
2450 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, imagePropertyMap );
2451 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, imagePropertyMap );
2453 editor.SetSize( 30.f, 500.f );
2454 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2455 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2457 // Avoid a crash when core load gl resources.
2458 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2460 // Render and notify
2461 application.SendNotification();
2462 application.Render();
2464 // Tap first to get the focus.
2465 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2466 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2468 // Render and notify
2469 application.SendNotification();
2470 application.Render();
2472 // Tap to create the grab handle.
2473 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2474 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2476 // Render and notify
2477 application.SendNotification();
2478 application.Render();
2480 // Get the active layer where the text's decoration is added.
2481 Actor activeLayer = editor.GetChildAt( 1u );
2483 // Get the handle's actor.
2484 Actor handle = activeLayer.GetChildAt( 1u );
2485 handle.SetSize( 100.f, 100.f );
2487 // Render and notify
2488 application.SendNotification();
2489 application.Render();
2491 // Touch the grab handle to set it as pressed.
2492 Vector2 touchPos( 10.0f, 50.0f );
2493 Dali::Integration::TouchEvent event;
2494 event = Dali::Integration::TouchEvent();
2495 event.AddPoint( GetPointDownInside( touchPos ) );
2496 application.ProcessEvent( event );
2498 // Render and notify
2499 application.SendNotification();
2500 application.Render();
2502 // drag grab handle right
2503 SendPan(application, Gesture::Possible, touchPos);
2504 SendPan(application, Gesture::Started, touchPos);
2506 Wait(application, 100);
2508 for(int i = 0;i<20;i++)
2510 SendPan(application, Gesture::Continuing, touchPos);
2515 SendPan(application, Gesture::Finished, touchPos);
2518 // Release the grab handle.
2519 event = Dali::Integration::TouchEvent();
2520 event.AddPoint( GetPointUpInside( touchPos ) );
2521 application.ProcessEvent( event );
2523 // Render and notify
2524 application.SendNotification();
2525 application.Render();
2527 // Tap first to get the focus.
2528 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2529 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
2531 // Render and notify
2532 application.SendNotification();
2533 application.Render();
2535 // Double tap to select a word and create the selection handles.
2536 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2537 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
2539 // Render and notify
2540 application.SendNotification();
2541 application.Render();
2543 touchPos = Vector2( 10.0f, 50.0f );
2545 // Touch the left selection handle to set it as pressed.
2546 event = Dali::Integration::TouchEvent();
2547 event.AddPoint( GetPointDownInside( touchPos ) );
2548 application.ProcessEvent( event );
2550 // Render and notify
2551 application.SendNotification();
2552 application.Render();
2554 // drag the left selection handle right
2555 SendPan(application, Gesture::Possible, touchPos);
2556 SendPan(application, Gesture::Started, touchPos);
2558 Wait(application, 100);
2560 for(int i = 0;i<20;i++)
2562 SendPan(application, Gesture::Continuing, touchPos);
2567 SendPan(application, Gesture::Finished, touchPos);
2570 // Release the left selection handle.
2571 event = Dali::Integration::TouchEvent();
2572 event.AddPoint( GetPointUpInside( touchPos ) );
2573 application.ProcessEvent( event );
2575 // Render and notify
2576 application.SendNotification();
2577 application.Render();
2582 int utcDaliTextEditorUnderPropertyStringP(void)
2584 ToolkitTestApplication application;
2585 tet_infoline(" utcDaliTextEditorUnderPropertyStringP");
2586 TextEditor editor = TextEditor::New();
2587 DALI_TEST_CHECK( editor );
2589 std::string underlineSettings1( "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
2591 Stage::GetCurrent().Add( editor );
2593 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2594 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), underlineSettings1, TEST_LOCATION );
2596 tet_infoline("Set underline settings with a map");
2597 // Check the input underline property
2598 Property::Map underlineMapSet;
2599 Property::Map underlineMapGet;
2600 underlineMapSet.Insert( "enable", "true" );
2601 underlineMapSet.Insert( "color", "blue" );
2602 underlineMapSet.Insert( "height", "2" );
2604 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
2605 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
2606 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
2607 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapSet, underlineMapGet ), true, TEST_LOCATION );
2609 tet_infoline("Set underline settings with a string");
2610 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettings1 );
2611 Property::Value value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2614 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2616 tet_infoline("Trying to set invalid underline settings, should not update and stay at previous settings");
2617 std::string underlineSettingsVoid( "{\"enable\":\"true\",\"coooolor\":\"blue\",\"heeeight\":\"4\"}" );
2618 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineSettingsVoid );
2619 value = editor.GetProperty( TextEditor::Property::UNDERLINE );
2621 DALI_TEST_EQUALS( result , underlineSettings1, TEST_LOCATION );
2626 int utcDaliTextEditorShadowPropertyStringP(void)
2628 ToolkitTestApplication application;
2629 tet_infoline(" utcDaliTextEditorUnderPropertyStringP Setting Shadow propeties by string");
2631 TextEditor editor = TextEditor::New();
2633 std::string shadowSettings( "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2635 Stage::GetCurrent().Add( editor );
2637 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\",\"blurRadius\":\"0\"}" );
2639 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::SHADOW );
2643 DALI_TEST_EQUALS( result, shadowSettings, TEST_LOCATION );
2648 int utcDaliTextEditorFontStylePropertyStringP(void)
2650 ToolkitTestApplication application;
2651 tet_infoline(" utcDaliTextEditorFontStylePropertyStringP Setting FontStyle propeties by string");
2653 TextEditor editor = TextEditor::New();
2655 std::string fontStyleSettings( "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2657 Stage::GetCurrent().Add( editor );
2659 editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
2661 Property::Value value = editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE );
2665 DALI_TEST_EQUALS( result, fontStyleSettings, TEST_LOCATION );
2670 int utcDaliTextEditorGetPropertyLinecountP(void)
2672 ToolkitTestApplication application;
2674 tet_infoline(" utcDaliTextEditorGetPropertyLinecount getting line count property");
2678 TextEditor editor = TextEditor::New();
2679 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10) ;
2680 editor.SetProperty( TextEditor::Property::TEXT,
2681 "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST ");
2683 Stage::GetCurrent().Add( editor );
2685 editor.SetSize( 100.0f, 100.0f );
2686 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2687 DALI_TEST_EQUALS( lineCount, 14, TEST_LOCATION );
2689 editor.SetSize( 50.0f, 100.0f );
2690 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2691 DALI_TEST_EQUALS( lineCount, 28, TEST_LOCATION );
2696 int utcDaliTextEditorScrollStateChangedSignalTest(void)
2699 ToolkitTestApplication application;
2700 tet_infoline(" UtcDaliTextEditorScrollStateChangedSignalTest");
2702 TextEditor editor = TextEditor::New();
2703 DALI_TEST_CHECK( editor );
2705 Stage::GetCurrent().Add( editor );
2707 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
2708 editor.SetSize( 50.f, 50.f );
2709 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2710 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2711 editor.SetProperty( TextEditor::Property::ENABLE_SCROLL_BAR, true );
2712 editor.SetKeyboardFocusable(true);
2714 bool startedCalled = false;
2715 bool finishedCalled = false;
2717 ScrollStateChangeCallback callback( startedCalled, finishedCalled );
2718 editor.ScrollStateChangedSignal().Connect( &callback, &ScrollStateChangeCallback::Callback );
2720 KeyboardFocusManager::Get().SetCurrentFocusActor( editor );
2722 // Render and notify
2723 application.SendNotification();
2724 application.Render();
2726 editor.SetProperty( TextEditor::Property::TEXT, "Long enough message for TextEditor!");
2727 application.SendNotification();
2728 application.Render(6000);
2730 application.SendNotification();
2731 DALI_TEST_EQUALS( startedCalled, true, TEST_LOCATION );
2732 DALI_TEST_EQUALS( finishedCalled, true, TEST_LOCATION );
2737 int UtcDaliToolkitTextEditorTextWrapMode(void)
2739 ToolkitTestApplication application;
2740 tet_infoline(" UtcDaliToolkitTextEditorTextWarpMode");
2744 TextEditor editor = TextEditor::New();
2745 editor.SetSize( 150.0f, 300.f );
2746 editor.SetProperty( TextEditor::Property::TEXT, "Hello world Hello world" );
2748 Stage::GetCurrent().Add( editor );
2750 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "WORD" );
2751 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2753 application.SendNotification();
2754 application.Render();
2756 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2757 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2759 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, "CHARACTER" );
2760 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2762 application.SendNotification();
2763 application.Render();
2765 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2766 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2768 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
2769 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
2771 application.SendNotification();
2772 application.Render();
2774 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2775 DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
2777 editor.SetProperty( TextEditor::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
2778 DALI_TEST_EQUALS( editor.GetProperty< int >( TextEditor::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
2780 application.SendNotification();
2781 application.Render();
2783 lineCount = editor.GetProperty<int>( TextEditor::Property::LINE_COUNT );
2784 DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2789 int UtcDaliTextEditorSetPaddingProperty(void)
2791 ToolkitTestApplication application;
2792 tet_infoline("UtcDaliTextEditorSetPaddingProperty\n");
2794 TextEditor editor = TextEditor::New();
2795 DALI_TEST_CHECK( editor );
2796 editor.SetSize( 300.f, 50.f );
2797 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2798 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2799 Stage::GetCurrent().Add( editor );
2801 application.SendNotification();
2802 application.Render();
2804 Vector3 originalSize = editor.GetNaturalSize();
2806 editor.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
2808 application.SendNotification();
2809 application.Render();
2811 DALI_TEST_EQUALS( editor.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
2813 Vector3 paddingAddedSize = editor.GetNaturalSize();
2815 DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2817 DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2822 int UtcDaliTextEditorEnableShiftSelectionProperty(void)
2824 ToolkitTestApplication application;
2825 tet_infoline("UtcDaliTextEditorEnableShiftSelectionProperty");
2827 TextEditor editor = TextEditor::New();
2828 DALI_TEST_CHECK( editor );
2829 editor.SetSize( 300.f, 50.f );
2830 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2831 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2832 Stage::GetCurrent().Add( editor );
2834 application.SendNotification();
2835 application.Render();
2837 // The default value of ENABLE_SHIFT_SELECTION is 'true'.
2838 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
2840 // Check the enable shift selection property
2841 editor.SetProperty( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION, false );
2842 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
2844 application.SendNotification();
2845 application.Render();
2850 int UtcDaliTextEditorEnableGrabHandleProperty(void)
2852 ToolkitTestApplication application;
2853 tet_infoline("UtcDaliTextEditorEnableGrabHandleProperty");
2855 TextEditor editor = TextEditor::New();
2856 DALI_TEST_CHECK( editor );
2857 editor.SetSize( 300.f, 50.f );
2858 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
2859 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
2860 Stage::GetCurrent().Add( editor );
2862 application.SendNotification();
2863 application.Render();
2865 // The default value of ENABLE_GRAB_HANDLE is 'true'.
2866 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
2868 // Check the enable grab handle property
2869 editor.SetProperty( DevelTextEditor::Property::ENABLE_GRAB_HANDLE, false );
2870 DALI_TEST_EQUALS( editor.GetProperty<bool>( DevelTextEditor::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
2872 application.SendNotification();
2873 application.Render();