2 * Copyright (c) 2016 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.
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/devel-api/adaptor-framework/clipboard.h>
24 #include <dali/integration-api/events/key-event-integ.h>
25 #include <dali/integration-api/events/tap-gesture-event.h>
26 #include <dali-toolkit-test-suite-utils.h>
27 #include <dali-toolkit/dali-toolkit.h>
30 using namespace Toolkit;
32 void dali_texteditor_startup(void)
34 test_return_value = TET_UNDEF;
37 void dali_texteditor_cleanup(void)
39 test_return_value = TET_PASS;
45 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
46 const char* const PROPERTY_NAME_TEXT = "text";
47 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
48 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
49 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
50 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
51 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
52 const char* const PROPERTY_NAME_SCROLL_THRESHOLD = "scrollThreshold";
53 const char* const PROPERTY_NAME_SCROLL_SPEED = "scrollSpeed";
54 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR = "primaryCursorColor";
55 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR = "secondaryCursorColor";
56 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK = "enableCursorBlink";
57 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL = "cursorBlinkInterval";
58 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION = "cursorBlinkDuration";
59 const char* const PROPERTY_NAME_CURSOR_WIDTH = "cursorWidth";
60 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE = "grabHandleImage";
61 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE = "grabHandlePressedImage";
62 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT = "selectionHandleImageLeft";
63 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT = "selectionHandleImageRight";
64 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT = "selectionHandlePressedImageLeft";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT = "selectionHandleMarkerImageLeft";
67 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT = "selectionHandleMarkerImageRight";
68 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR = "selectionHighlightColor";
69 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX = "decorationBoundingBox";
70 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
71 const char* const PROPERTY_NAME_INPUT_COLOR = "inputColor";
72 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY = "inputFontFamily";
73 const char* const PROPERTY_NAME_INPUT_FONT_STYLE = "inputFontStyle";
74 const char* const PROPERTY_NAME_INPUT_POINT_SIZE = "inputPointSize";
76 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
77 const char* const PROPERTY_NAME_INPUT_LINE_SPACING = "inputLineSpacing";
78 const char* const PROPERTY_NAME_UNDERLINE = "underline";
79 const char* const PROPERTY_NAME_INPUT_UNDERLINE = "inputUnderline";
80 const char* const PROPERTY_NAME_SHADOW = "shadow";
81 const char* const PROPERTY_NAME_INPUT_SHADOW = "inputShadow";
82 const char* const PROPERTY_NAME_EMBOSS = "emboss";
83 const char* const PROPERTY_NAME_INPUT_EMBOSS = "inputEmboss";
84 const char* const PROPERTY_NAME_OUTLINE = "outline";
85 const char* const PROPERTY_NAME_INPUT_OUTLINE = "inputOutline";
87 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
89 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
91 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
92 const float TO_MILLISECONDS = 1000.f;
93 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
95 const float SCROLL_THRESHOLD = 10.f;
96 const float SCROLL_SPEED = 300.f;
98 const unsigned int DEFAULT_FONT_SIZE = 1152u;
99 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
101 static bool gTextChangedCallBackCalled;
102 static bool gInputStyleChangedCallbackCalled;
103 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
105 struct CallbackFunctor
107 CallbackFunctor(bool* callbackFlag)
108 : mCallbackFlag( callbackFlag )
114 *mCallbackFlag = true;
119 static void TestTextChangedCallback( TextEditor control )
121 tet_infoline(" TestTextChangedCallback");
123 gTextChangedCallBackCalled = true;
126 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
128 tet_infoline(" TestInputStyleChangedCallback");
130 gInputStyleChangedCallbackCalled = true;
131 gInputStyleMask = mask;
134 // Generate a TapGestureEvent to send to Core.
135 Integration::TapGestureEvent GenerateTap(
136 Gesture::State state,
137 unsigned int numberOfTaps,
138 unsigned int numberOfTouches,
141 Integration::TapGestureEvent tap( state );
143 tap.numberOfTaps = numberOfTaps;
144 tap.numberOfTouches = numberOfTouches;
150 // Generate a KeyEvent to send to Core.
151 Integration::KeyEvent GenerateKey( const std::string& keyName,
152 const std::string& keyString,
155 unsigned long timeStamp,
156 const Integration::KeyEvent::State& keyState )
158 return Integration::KeyEvent( keyName,
166 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
168 if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
170 for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
172 const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
174 Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
175 if( NULL != valueSet )
177 if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
179 tet_printf( " Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
185 tet_printf( " The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
196 int UtcDaliToolkitTextEditorConstructorP(void)
198 ToolkitTestApplication application;
199 tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
200 TextEditor textEditor;
201 DALI_TEST_CHECK( !textEditor );
205 int UtcDaliToolkitTextEditorNewP(void)
207 ToolkitTestApplication application;
208 tet_infoline(" UtcDaliToolkitTextEditorNewP");
209 TextEditor textEditor = TextEditor::New();
210 DALI_TEST_CHECK( textEditor );
214 int UtcDaliToolkitTextEditorDownCastP(void)
216 ToolkitTestApplication application;
217 tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
218 TextEditor textEditor1 = TextEditor::New();
219 BaseHandle object( textEditor1 );
221 TextEditor textEditor2 = TextEditor::DownCast( object );
222 DALI_TEST_CHECK( textEditor2 );
224 TextEditor textEditor3 = DownCast< TextEditor >( object );
225 DALI_TEST_CHECK( textEditor3 );
229 int UtcDaliToolkitTextEditorDownCastN(void)
231 ToolkitTestApplication application;
232 tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
233 BaseHandle uninitializedObject;
234 TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
235 DALI_TEST_CHECK( !textEditor1 );
237 TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
238 DALI_TEST_CHECK( !textEditor2 );
242 int UtcDaliToolkitTextEditorCopyConstructorP(void)
244 ToolkitTestApplication application;
245 tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
246 TextEditor textEditor = TextEditor::New();
247 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
249 TextEditor copy( textEditor );
250 DALI_TEST_CHECK( copy );
251 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
255 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
257 ToolkitTestApplication application;
258 tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
259 TextEditor textEditor = TextEditor::New();
260 textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
262 TextEditor copy = textEditor;
263 DALI_TEST_CHECK( copy );
264 DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
268 int UtcDaliTextEditorNewP(void)
270 ToolkitTestApplication application;
271 tet_infoline(" UtcDaliToolkitTextEditorNewP");
272 TextEditor textEditor = TextEditor::New();
273 DALI_TEST_CHECK( textEditor );
277 // Positive test case for a method
278 int UtcDaliTextEditorGetPropertyP(void)
280 ToolkitTestApplication application;
281 tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
282 TextEditor editor = TextEditor::New();
283 DALI_TEST_CHECK( editor );
285 // Check Property Indices are correct
286 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
287 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
288 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
289 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
290 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
291 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
292 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
293 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
294 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
295 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
296 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
297 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
298 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
299 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
300 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
301 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
302 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
303 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
304 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
305 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
306 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
307 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
308 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
309 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
310 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
311 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
312 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
313 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
314 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
315 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
317 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
318 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
319 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
320 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
321 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
322 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
323 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
324 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
325 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
326 DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
331 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
334 Property::Map imageMap;
335 imageMap[mapKey] =mapValue;
337 editor.SetProperty( property , imageMap );
338 Property::Value propValue = editor.GetProperty( property );
339 Property::Map* resultMap = propValue.GetMap();
341 if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
349 // Positive test case for a method
350 int UtcDaliTextEditorSetPropertyP(void)
352 ToolkitTestApplication application;
353 tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
354 TextEditor editor = TextEditor::New();
355 DALI_TEST_CHECK( editor );
356 Stage::GetCurrent().Add( editor );
358 // Note - we can't check the defaults since the stylesheets are platform-specific
360 // Check the render backend property.
361 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
362 DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
364 // Check text property.
365 editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
366 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
368 // Check text's color property
369 editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
370 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
372 // Check font properties.
373 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
374 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
376 Property::Map fontStyleMapSet;
377 Property::Map fontStyleMapGet;
378 Property::Value* slantValue = NULL;
380 fontStyleMapSet.Insert( "weight", "bold" );
381 fontStyleMapSet.Insert( "width", "condensed" );
382 fontStyleMapSet.Insert( "slant", "italic" );
384 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
385 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
386 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
387 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
389 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
390 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
393 fontStyleMapSet.Clear();
394 fontStyleMapSet.Insert( "weight", "normal" );
395 fontStyleMapSet.Insert( "slant", "oblique" );
396 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
397 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
398 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
399 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
401 fontStyleMapSet.Clear();
402 fontStyleMapSet.Insert( "slant", "roman" );
403 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
404 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
406 // Replace 'roman' for 'normal'.
407 slantValue = fontStyleMapGet.Find( "slant" );
408 if( NULL != slantValue )
410 if( "normal" == slantValue->Get<std::string>() )
412 fontStyleMapGet["slant"] = "roman";
415 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
416 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
418 fontStyleMapSet.Clear();
420 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
421 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::FONT_STYLE );
422 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
423 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
425 // Check that the Alignment properties can be correctly set
426 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
427 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
429 // Check scroll properties.
430 editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
431 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
432 editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
433 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
435 // Check cursor properties
436 editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
437 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
438 editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
439 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
441 editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
442 DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
443 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
444 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
445 editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
446 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
447 editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
448 DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
450 // Check handle images
451 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
452 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
453 editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
454 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
455 editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
457 // Check handle images
458 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" ) );
459 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" ) );
460 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" ) );
461 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" ) );
462 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" ) );
463 DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" ) );
465 // Check the highlight color
466 editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
467 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
469 // Decoration bounding box
470 editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
471 DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
473 // Check the enable markup property.
474 DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
475 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
476 DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
478 // Check input color property.
479 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
480 DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
482 // Check input font properties.
483 editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
484 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
486 fontStyleMapSet.Clear();
487 fontStyleMapSet.Insert( "weight", "bold" );
488 fontStyleMapSet.Insert( "width", "condensed" );
489 fontStyleMapSet.Insert( "slant", "italic" );
491 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
492 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
493 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
494 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
496 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
497 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
499 // Reset input font style.
500 fontStyleMapSet.Clear();
501 fontStyleMapSet.Insert( "weight", "normal" );
502 fontStyleMapSet.Insert( "slant", "oblique" );
504 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
505 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
506 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
507 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
509 fontStyleMapSet.Clear();
510 fontStyleMapSet.Insert( "slant", "roman" );
512 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
513 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
515 // Replace 'roman' for 'normal'.
516 slantValue = fontStyleMapGet.Find( "slant" );
517 if( NULL != slantValue )
519 if( "normal" == slantValue->Get<std::string>() )
521 fontStyleMapGet["slant"] = "roman";
524 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
525 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
527 fontStyleMapSet.Clear();
529 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
530 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
531 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
532 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
534 // Check the line spacing property
535 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
536 editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
537 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
539 // Check the input line spacing property
540 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
541 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
542 DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
544 // Check the underline property
546 Property::Map underlineMapSet;
547 Property::Map underlineMapGet;
549 underlineMapSet.Insert( "enable", "true" );
550 underlineMapSet.Insert( "color", "red" );
551 underlineMapSet.Insert( "height", "1" );
553 editor.SetProperty( TextEditor::Property::UNDERLINE, underlineMapSet );
555 underlineMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::UNDERLINE );
556 DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
557 DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
559 // Check the input underline property
560 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
561 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
563 // Check the shadow property
564 Property::Map shadowMapSet;
565 Property::Map shadowMapGet;
567 shadowMapSet.Insert( "color", "green" );
568 shadowMapSet.Insert( "offset", "2 2" );
570 editor.SetProperty( TextEditor::Property::SHADOW, shadowMapSet );
572 shadowMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::SHADOW );
573 DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
574 DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
576 // Check the input shadow property
577 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
578 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
580 // Check the emboss property
581 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
582 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
584 // Check the input emboss property
585 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
586 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
588 // Check the outline property
589 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
590 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
592 // Check the input outline property
593 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
594 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
599 // Positive Atlas Text Renderer test
600 int utcDaliTextEditorAtlasRenderP(void)
602 ToolkitTestApplication application;
603 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
604 StyleManager styleManager = StyleManager::Get();
605 styleManager.ApplyDefaultTheme();
606 TextEditor editor = TextEditor::New();
607 DALI_TEST_CHECK( editor );
609 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
611 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
613 Stage::GetCurrent().Add( editor );
617 // Render some text with the shared atlas backend
618 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
619 application.SendNotification();
620 application.Render();
624 tet_result(TET_FAIL);
629 // Positive test for the textChanged signal.
630 int utcDaliTextEditorTextChangedP(void)
632 ToolkitTestApplication application;
633 tet_infoline(" utcDaliTextEditorTextChangedP");
634 TextEditor editor = TextEditor::New();
635 DALI_TEST_CHECK( editor );
637 Stage::GetCurrent().Add( editor );
639 // connect to the text changed signal.
640 ConnectionTracker* testTracker = new ConnectionTracker();
641 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
642 bool textChangedSignal = false;
643 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
645 gTextChangedCallBackCalled = false;
646 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
647 DALI_TEST_CHECK( gTextChangedCallBackCalled );
648 DALI_TEST_CHECK( textChangedSignal );
650 application.SendNotification();
652 editor.SetKeyInputFocus();
654 gTextChangedCallBackCalled = false;
655 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
656 DALI_TEST_CHECK( gTextChangedCallBackCalled );
661 int utcDaliTextEditorInputStyleChanged01(void)
663 ToolkitTestApplication application;
664 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
666 // The text-editor emits signals when the input style changes. These changes of style are
667 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
668 // can't be emitted during the size negotiation as the callbacks may update the UI.
669 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
670 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
671 application.CreateAdaptor();
675 char* pathNamePtr = get_current_dir_name();
676 const std::string pathName( pathNamePtr );
679 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
680 fontClient.SetDpi( 93u, 93u );
682 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
683 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
685 TextEditor editor = TextEditor::New();
686 DALI_TEST_CHECK( editor );
689 editor.SetSize( 300.f, 50.f );
690 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
691 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
693 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
694 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
696 // connect to the text changed signal.
697 ConnectionTracker* testTracker = new ConnectionTracker();
698 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
699 bool inputStyleChangedSignal = false;
700 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
702 Stage::GetCurrent().Add( editor );
705 application.SendNotification();
706 application.Render();
708 // Executes the idle callbacks added by the text control on the change of input style.
709 application.RunIdles();
711 gInputStyleChangedCallbackCalled = false;
712 gInputStyleMask = TextEditor::InputStyle::NONE;
713 inputStyleChangedSignal = false;
715 // Create a tap event to touch the text editor.
716 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
717 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
720 application.SendNotification();
721 application.Render();
723 // Executes the idle callbacks added by the text control on the change of input style.
724 application.RunIdles();
726 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
727 if( gInputStyleChangedCallbackCalled )
729 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
731 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
732 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
734 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
735 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
737 DALI_TEST_CHECK( inputStyleChangedSignal );
739 gInputStyleChangedCallbackCalled = false;
740 gInputStyleMask = TextEditor::InputStyle::NONE;
741 inputStyleChangedSignal = false;
743 // Create a tap event to touch the text editor.
744 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
745 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
748 application.SendNotification();
749 application.Render();
751 // Executes the idle callbacks added by the text control on the change of input style.
752 application.RunIdles();
754 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
755 DALI_TEST_CHECK( !inputStyleChangedSignal );
757 gInputStyleChangedCallbackCalled = false;
758 gInputStyleMask = TextEditor::InputStyle::NONE;
759 inputStyleChangedSignal = false;
761 // Create a tap event to touch the text editor.
762 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
763 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
766 application.SendNotification();
767 application.Render();
769 // Executes the idle callbacks added by the text control on the change of input style.
770 application.RunIdles();
772 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
773 if( gInputStyleChangedCallbackCalled )
775 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
777 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
778 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
780 DALI_TEST_CHECK( inputStyleChangedSignal );
782 gInputStyleChangedCallbackCalled = false;
783 gInputStyleMask = TextEditor::InputStyle::NONE;
784 inputStyleChangedSignal = false;
786 // Create a tap event to touch the text editor.
787 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
788 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
791 application.SendNotification();
792 application.Render();
794 // Executes the idle callbacks added by the text control on the change of input style.
795 application.RunIdles();
797 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
798 if( gInputStyleChangedCallbackCalled )
800 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
802 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
803 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
805 Property::Map fontStyleMapSet;
806 Property::Map fontStyleMapGet;
808 fontStyleMapSet.Insert( "weight", "bold" );
810 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
811 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
812 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
814 DALI_TEST_CHECK( inputStyleChangedSignal );
816 gInputStyleChangedCallbackCalled = false;
817 gInputStyleMask = TextEditor::InputStyle::NONE;
818 inputStyleChangedSignal = false;
820 // Create a tap event to touch the text editor.
821 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
822 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
825 application.SendNotification();
826 application.Render();
828 // Executes the idle callbacks added by the text control on the change of input style.
829 application.RunIdles();
831 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
832 DALI_TEST_CHECK( !inputStyleChangedSignal );
834 gInputStyleChangedCallbackCalled = false;
835 gInputStyleMask = TextEditor::InputStyle::NONE;
836 inputStyleChangedSignal = false;
838 // Create a tap event to touch the text editor.
839 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
840 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
843 application.SendNotification();
844 application.Render();
846 // Executes the idle callbacks added by the text control on the change of input style.
847 application.RunIdles();
849 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
850 if( gInputStyleChangedCallbackCalled )
852 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
854 Property::Map fontStyleMapSet;
855 Property::Map fontStyleMapGet;
857 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
858 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
859 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
861 DALI_TEST_CHECK( inputStyleChangedSignal );
863 gInputStyleChangedCallbackCalled = false;
864 gInputStyleMask = TextEditor::InputStyle::NONE;
865 inputStyleChangedSignal = false;
867 // Create a tap event to touch the text editor.
868 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
869 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
872 application.SendNotification();
873 application.Render();
875 // Executes the idle callbacks added by the text control on the change of input style.
876 application.RunIdles();
878 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
879 DALI_TEST_CHECK( !inputStyleChangedSignal );
884 int utcDaliTextEditorInputStyleChanged02(void)
886 ToolkitTestApplication application;
887 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
889 // The text-editor emits signals when the input style changes. These changes of style are
890 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
891 // can't be emitted during the size negotiation as the callbacks may update the UI.
892 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
893 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
894 application.CreateAdaptor();
898 char* pathNamePtr = get_current_dir_name();
899 const std::string pathName( pathNamePtr );
902 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
903 fontClient.SetDpi( 93u, 93u );
905 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
906 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
908 TextEditor editor = TextEditor::New();
909 DALI_TEST_CHECK( editor );
912 editor.SetSize( 300.f, 50.f );
913 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
914 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
916 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
917 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>" );
919 // connect to the text changed signal.
920 ConnectionTracker* testTracker = new ConnectionTracker();
921 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
922 bool inputStyleChangedSignal = false;
923 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
925 Stage::GetCurrent().Add( editor );
928 application.SendNotification();
929 application.Render();
931 // Executes the idle callbacks added by the text control on the change of input style.
932 application.RunIdles();
934 gInputStyleChangedCallbackCalled = false;
935 gInputStyleMask = TextEditor::InputStyle::NONE;
936 inputStyleChangedSignal = false;
938 // Create a tap event to touch the text editor.
939 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
940 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
941 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
942 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
945 application.SendNotification();
946 application.Render();
948 // Executes the idle callbacks added by the text control on the change of input style.
949 application.RunIdles();
951 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
952 if( gInputStyleChangedCallbackCalled )
954 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
955 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
956 TextEditor::InputStyle::POINT_SIZE |
957 TextEditor::InputStyle::COLOR ),
960 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
961 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
963 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
964 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
966 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
967 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
969 DALI_TEST_CHECK( inputStyleChangedSignal );
971 gInputStyleChangedCallbackCalled = false;
972 gInputStyleMask = TextEditor::InputStyle::NONE;
973 inputStyleChangedSignal = false;
975 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
978 application.SendNotification();
979 application.Render();
981 // Executes the idle callbacks added by the text control on the change of input style.
982 application.RunIdles();
984 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
985 if( gInputStyleChangedCallbackCalled )
987 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
988 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
991 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
992 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
994 DALI_TEST_CHECK( inputStyleChangedSignal );
996 gInputStyleChangedCallbackCalled = false;
997 gInputStyleMask = TextEditor::InputStyle::NONE;
998 inputStyleChangedSignal = false;
1000 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1002 // Render and notify
1003 application.SendNotification();
1004 application.Render();
1006 // Executes the idle callbacks added by the text control on the change of input style.
1007 application.RunIdles();
1009 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1010 DALI_TEST_CHECK( !inputStyleChangedSignal );
1012 gInputStyleChangedCallbackCalled = false;
1013 gInputStyleMask = TextEditor::InputStyle::NONE;
1014 inputStyleChangedSignal = false;
1016 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1018 // Render and notify
1019 application.SendNotification();
1020 application.Render();
1022 // Executes the idle callbacks added by the text control on the change of input style.
1023 application.RunIdles();
1025 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1026 if( gInputStyleChangedCallbackCalled )
1028 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1029 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1032 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1033 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1035 DALI_TEST_CHECK( inputStyleChangedSignal );
1037 gInputStyleChangedCallbackCalled = false;
1038 gInputStyleMask = TextEditor::InputStyle::NONE;
1039 inputStyleChangedSignal = false;
1041 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1043 Property::Map fontStyleMapSet;
1044 fontStyleMapSet.Insert( "weight", "thin" );
1045 fontStyleMapSet.Insert( "width", "condensed" );
1046 fontStyleMapSet.Insert( "slant", "italic" );
1048 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1049 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1050 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1052 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1053 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1054 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1055 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1057 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1059 // Render and notify
1060 application.SendNotification();
1061 application.Render();
1063 // Executes the idle callbacks added by the text control on the change of input style.
1064 application.RunIdles();
1066 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1067 DALI_TEST_CHECK( !inputStyleChangedSignal );
1069 // Create a tap event to touch the text editor.
1070 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1071 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1073 // Render and notify
1074 application.SendNotification();
1075 application.Render();
1077 // Executes the idle callbacks added by the text control on the change of input style.
1078 application.RunIdles();
1080 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1081 if( gInputStyleChangedCallbackCalled )
1083 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1084 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1085 TextEditor::InputStyle::POINT_SIZE |
1086 TextEditor::InputStyle::FONT_STYLE |
1087 TextEditor::InputStyle::LINE_SPACING |
1088 TextEditor::InputStyle::UNDERLINE |
1089 TextEditor::InputStyle::SHADOW |
1090 TextEditor::InputStyle::EMBOSS |
1091 TextEditor::InputStyle::OUTLINE ),
1094 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1095 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1097 DALI_TEST_CHECK( inputStyleChangedSignal );
1099 gInputStyleChangedCallbackCalled = false;
1100 gInputStyleMask = TextEditor::InputStyle::NONE;
1101 inputStyleChangedSignal = false;
1103 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1105 fontStyleMapSet.Clear();
1106 fontStyleMapSet.Insert( "weight", "black" );
1107 fontStyleMapSet.Insert( "width", "expanded" );
1108 fontStyleMapSet.Insert( "slant", "oblique" );
1110 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1112 // Create a tap event to touch the text editor.
1113 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1114 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1116 // Render and notify
1117 application.SendNotification();
1118 application.Render();
1120 // Executes the idle callbacks added by the text control on the change of input style.
1121 application.RunIdles();
1123 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1124 if( gInputStyleChangedCallbackCalled )
1126 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1127 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1128 TextEditor::InputStyle::POINT_SIZE |
1129 TextEditor::InputStyle::FONT_STYLE ),
1132 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1133 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1135 DALI_TEST_CHECK( inputStyleChangedSignal );
1140 int utcDaliTextEditorEvent01(void)
1142 ToolkitTestApplication application;
1143 tet_infoline(" utcDaliTextEditorEvent01");
1145 // Creates a tap event. After creating a tap event the text editor should
1146 // have the focus and add text with key events should be possible.
1148 TextEditor editor = TextEditor::New();
1149 DALI_TEST_CHECK( editor );
1151 Stage::GetCurrent().Add( editor );
1153 editor.SetSize( 300.f, 50.f );
1154 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1155 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1157 // Avoid a crash when core load gl resources.
1158 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1160 // Render and notify
1161 application.SendNotification();
1162 application.Render();
1164 // Add a key event but as the text editor has not the focus it should do nothing.
1165 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1167 // Render and notify
1168 application.SendNotification();
1169 application.Render();
1171 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1173 // Create a tap event to touch the text editor.
1174 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1175 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1177 // Render and notify
1178 application.SendNotification();
1179 application.Render();
1181 // Now the text editor has the focus, so it can handle the key events.
1182 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1183 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1185 // Render and notify
1186 application.SendNotification();
1187 application.Render();
1189 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1191 // Create a second text editor and send key events to it.
1192 TextEditor editor2 = TextEditor::New();
1194 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1195 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1196 editor2.SetSize( 100.f, 100.f );
1197 editor2.SetPosition( 100.f, 100.f );
1199 Stage::GetCurrent().Add( editor2 );
1201 // Render and notify
1202 application.SendNotification();
1203 application.Render();
1205 // Create a tap event on the second text editor.
1206 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1207 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1209 // Render and notify
1210 application.SendNotification();
1211 application.Render();
1213 // The second text editor has the focus. It should handle the key events.
1214 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1215 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1217 // Render and notify
1218 application.SendNotification();
1219 application.Render();
1221 // Check the text has been added to the second text editor.
1222 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1227 int utcDaliTextEditorEvent02(void)
1229 ToolkitTestApplication application;
1230 tet_infoline(" utcDaliTextEditorEvent02");
1232 // Checks if the right number of actors are created.
1234 TextEditor editor = TextEditor::New();
1235 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1236 DALI_TEST_CHECK( editor );
1238 Stage::GetCurrent().Add( editor );
1240 editor.SetSize( 300.f, 50.f );
1241 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1242 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1244 // Avoid a crash when core load gl resources.
1245 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1247 // Render and notify
1248 application.SendNotification();
1249 application.Render();
1251 // Check there are the expected number of children (the stencil).
1252 DALI_TEST_EQUALS( editor.GetChildCount(), 1u, TEST_LOCATION );
1254 Actor stencil = editor.GetChildAt( 0u );
1256 // Create a tap event to touch the text editor.
1257 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1258 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1260 // Render and notify
1261 application.SendNotification();
1262 application.Render();
1264 Actor layer = editor.GetChildAt( 1u );
1265 DALI_TEST_CHECK( layer.IsLayer() );
1267 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1268 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1270 // Now the text editor has the focus, so it can handle the key events.
1271 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1272 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1274 // Render and notify
1275 application.SendNotification();
1276 application.Render();
1278 // Checks the cursor and the renderer have been created.
1279 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1280 DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
1282 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1283 DALI_TEST_CHECK( cursor );
1285 // The stencil actor has a container with all the actors which contain the text renderers.
1286 Actor container = stencil.GetChildAt( 0u );
1287 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1289 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1290 DALI_TEST_CHECK( renderer );
1293 // Move the cursor and check the position changes.
1294 Vector3 position1 = cursor.GetCurrentPosition();
1296 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1297 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1299 // Render and notify
1300 application.SendNotification();
1301 application.Render();
1303 Vector3 position2 = cursor.GetCurrentPosition();
1305 DALI_TEST_CHECK( position2.x < position1.x );
1307 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1308 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1310 // Render and notify
1311 application.SendNotification();
1312 application.Render();
1314 Vector3 position3 = cursor.GetCurrentPosition();
1316 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1318 // Send some taps and check the cursor positions.
1320 // Try to tap at the beginning.
1321 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1322 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1324 // Render and notify
1325 application.SendNotification();
1326 application.Render();
1328 // Cursor position should be the same than position1.
1329 Vector3 position4 = cursor.GetCurrentPosition();
1331 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1333 // Tap away from the start position.
1334 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1335 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1337 // Render and notify
1338 application.SendNotification();
1339 application.Render();
1341 Vector3 position5 = cursor.GetCurrentPosition();
1343 DALI_TEST_CHECK( position5.x > position4.x );
1345 // Remove all the text.
1346 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1347 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1348 editor.SetProperty( TextEditor::Property::TEXT, "" );
1350 // Render and notify
1351 application.SendNotification();
1352 application.Render();
1354 // Cursor position should be the same than position2.
1355 Vector3 position6 = cursor.GetCurrentPosition();
1357 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1359 // Should not be a renderer.
1360 DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
1365 int utcDaliTextEditorEvent03(void)
1367 ToolkitTestApplication application;
1368 tet_infoline(" utcDaliTextEditorEvent03");
1370 // Checks if the highlight actor is created.
1372 TextEditor editor = TextEditor::New();
1373 DALI_TEST_CHECK( editor );
1375 Stage::GetCurrent().Add( editor );
1377 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1378 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1379 editor.SetSize( 30.f, 50.f );
1380 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1381 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1383 // Avoid a crash when core load gl resources.
1384 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1386 // Render and notify
1387 application.SendNotification();
1388 application.Render();
1390 // Send some taps and check text controller with clipboard window
1391 Dali::Clipboard clipboard = Clipboard::Get();
1392 clipboard.ShowClipboard();
1393 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1394 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1395 clipboard.HideClipboard();
1397 // Render and notify
1398 application.SendNotification();
1399 application.Render();
1401 // Tap first to get the focus.
1402 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1403 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1405 // Render and notify
1406 application.SendNotification();
1407 application.Render();
1409 // Double tap to select a word.
1410 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1411 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1413 // Render and notify
1414 application.SendNotification();
1415 application.Render();
1417 // The stencil actor should have two actors: the renderer and the highlight actor.
1418 Actor stencil = editor.GetChildAt( 0u );
1420 // The stencil actor has a container with all the actors which contain the text renderers.
1421 Actor container = stencil.GetChildAt( 0u );
1422 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1424 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1425 DALI_TEST_CHECK( renderer );
1428 Renderer highlight = stencil.GetChildAt( 1u ).GetRendererAt( 0u );
1429 DALI_TEST_CHECK( highlight );
1434 int utcDaliTextEditorEvent04(void)
1436 ToolkitTestApplication application;
1437 tet_infoline(" utcDaliTextEditorEvent04");
1439 // Checks if the highlight actor is created.
1441 TextEditor editor = TextEditor::New();
1442 DALI_TEST_CHECK( editor );
1444 Stage::GetCurrent().Add( editor );
1446 editor.SetProperty( TextEditor::Property::TEXT, "Hello\nworl" );
1447 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1448 editor.SetSize( 100.f, 50.f );
1449 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1450 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1452 // Avoid a crash when core load gl resources.
1453 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1455 // Render and notify
1456 application.SendNotification();
1457 application.Render();
1459 // Tap on the text editor
1460 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1461 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1463 // Render and notify
1464 application.SendNotification();
1465 application.Render();
1467 // Move at the end of the text.
1468 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
1469 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::Down ) );
1471 // Render and notify
1472 application.SendNotification();
1473 application.Render();
1475 for( unsigned int index = 0u; index < 10u; ++index )
1477 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1478 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1480 // Render and notify
1481 application.SendNotification();
1482 application.Render();
1486 application.ProcessEvent( GenerateKey( "d", "d", 0, 0, 0, Integration::KeyEvent::Down ) );
1488 // Render and notify
1489 application.SendNotification();
1490 application.Render();
1492 DALI_TEST_EQUALS( "Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );
1494 // Add some key events
1495 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
1496 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_UP, 0, 0, Integration::KeyEvent::Down ) );
1498 // Render and notify
1499 application.SendNotification();
1500 application.Render();
1502 for( unsigned int index = 0u; index < 10u; ++index )
1504 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1505 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1507 // Render and notify
1508 application.SendNotification();
1509 application.Render();
1513 application.ProcessEvent( GenerateKey( " ", " ", 0, 0, 0, Integration::KeyEvent::Down ) );
1515 // Render and notify
1516 application.SendNotification();
1517 application.Render();
1519 DALI_TEST_EQUALS( " Hello\nworld", editor.GetProperty<std::string>( TextEditor::Property::TEXT ), TEST_LOCATION );