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
545 editor.SetProperty( TextEditor::Property::UNDERLINE, "{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}" );
546 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), std::string("{\"enable\":\"true\",\"color\":\"red\",\"height\":\"1\"}"), TEST_LOCATION );
548 // Check the input underline property
549 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
550 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
552 // Check the shadow property
553 editor.SetProperty( TextEditor::Property::SHADOW, "{\"color\":\"green\",\"offset\":\"2 2\"}" );
554 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::SHADOW ), std::string("{\"color\":\"green\",\"offset\":\"2 2\"}"), TEST_LOCATION );
556 // Check the input shadow property
557 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
558 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
560 // Check the emboss property
561 editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
562 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
564 // Check the input emboss property
565 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
566 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
568 // Check the outline property
569 editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
570 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
572 // Check the input outline property
573 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
574 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
579 // Positive Atlas Text Renderer test
580 int utcDaliTextEditorAtlasRenderP(void)
582 ToolkitTestApplication application;
583 tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
584 StyleManager styleManager = StyleManager::Get();
585 styleManager.ApplyDefaultTheme();
586 TextEditor editor = TextEditor::New();
587 DALI_TEST_CHECK( editor );
589 editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
591 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
593 Stage::GetCurrent().Add( editor );
597 // Render some text with the shared atlas backend
598 editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
599 application.SendNotification();
600 application.Render();
604 tet_result(TET_FAIL);
609 // Positive test for the textChanged signal.
610 int utcDaliTextEditorTextChangedP(void)
612 ToolkitTestApplication application;
613 tet_infoline(" utcDaliTextEditorTextChangedP");
614 TextEditor editor = TextEditor::New();
615 DALI_TEST_CHECK( editor );
617 Stage::GetCurrent().Add( editor );
619 // connect to the text changed signal.
620 ConnectionTracker* testTracker = new ConnectionTracker();
621 editor.TextChangedSignal().Connect( &TestTextChangedCallback );
622 bool textChangedSignal = false;
623 editor.ConnectSignal( testTracker, "textChanged", CallbackFunctor(&textChangedSignal) );
625 gTextChangedCallBackCalled = false;
626 editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
627 DALI_TEST_CHECK( gTextChangedCallBackCalled );
628 DALI_TEST_CHECK( textChangedSignal );
630 application.SendNotification();
632 editor.SetKeyInputFocus();
634 gTextChangedCallBackCalled = false;
635 application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
636 DALI_TEST_CHECK( gTextChangedCallBackCalled );
641 int utcDaliTextEditorInputStyleChanged01(void)
643 ToolkitTestApplication application;
644 tet_infoline(" utcDaliTextEditorInputStyleChanged01");
646 // The text-editor emits signals when the input style changes. These changes of style are
647 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
648 // can't be emitted during the size negotiation as the callbacks may update the UI.
649 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
650 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
651 application.CreateAdaptor();
655 char* pathNamePtr = get_current_dir_name();
656 const std::string pathName( pathNamePtr );
659 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
660 fontClient.SetDpi( 93u, 93u );
662 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
663 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
665 TextEditor editor = TextEditor::New();
666 DALI_TEST_CHECK( editor );
669 editor.SetSize( 300.f, 50.f );
670 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
671 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
673 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
674 editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
676 // connect to the text changed signal.
677 ConnectionTracker* testTracker = new ConnectionTracker();
678 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
679 bool inputStyleChangedSignal = false;
680 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
682 Stage::GetCurrent().Add( editor );
685 application.SendNotification();
686 application.Render();
688 // Executes the idle callbacks added by the text control on the change of input style.
689 application.RunIdles();
691 gInputStyleChangedCallbackCalled = false;
692 gInputStyleMask = TextEditor::InputStyle::NONE;
693 inputStyleChangedSignal = false;
695 // Create a tap event to touch the text editor.
696 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
697 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
700 application.SendNotification();
701 application.Render();
703 // Executes the idle callbacks added by the text control on the change of input style.
704 application.RunIdles();
706 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
707 if( gInputStyleChangedCallbackCalled )
709 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
711 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
712 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
714 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
715 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717 DALI_TEST_CHECK( inputStyleChangedSignal );
719 gInputStyleChangedCallbackCalled = false;
720 gInputStyleMask = TextEditor::InputStyle::NONE;
721 inputStyleChangedSignal = false;
723 // Create a tap event to touch the text editor.
724 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
725 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
728 application.SendNotification();
729 application.Render();
731 // Executes the idle callbacks added by the text control on the change of input style.
732 application.RunIdles();
734 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
735 DALI_TEST_CHECK( !inputStyleChangedSignal );
737 gInputStyleChangedCallbackCalled = false;
738 gInputStyleMask = TextEditor::InputStyle::NONE;
739 inputStyleChangedSignal = false;
741 // Create a tap event to touch the text editor.
742 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
743 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
746 application.SendNotification();
747 application.Render();
749 // Executes the idle callbacks added by the text control on the change of input style.
750 application.RunIdles();
752 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
753 if( gInputStyleChangedCallbackCalled )
755 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
757 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
758 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
760 DALI_TEST_CHECK( inputStyleChangedSignal );
762 gInputStyleChangedCallbackCalled = false;
763 gInputStyleMask = TextEditor::InputStyle::NONE;
764 inputStyleChangedSignal = false;
766 // Create a tap event to touch the text editor.
767 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
768 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
771 application.SendNotification();
772 application.Render();
774 // Executes the idle callbacks added by the text control on the change of input style.
775 application.RunIdles();
777 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
778 if( gInputStyleChangedCallbackCalled )
780 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
782 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
783 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
785 Property::Map fontStyleMapSet;
786 Property::Map fontStyleMapGet;
788 fontStyleMapSet.Insert( "weight", "bold" );
790 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
791 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
792 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
794 DALI_TEST_CHECK( inputStyleChangedSignal );
796 gInputStyleChangedCallbackCalled = false;
797 gInputStyleMask = TextEditor::InputStyle::NONE;
798 inputStyleChangedSignal = false;
800 // Create a tap event to touch the text editor.
801 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
802 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
805 application.SendNotification();
806 application.Render();
808 // Executes the idle callbacks added by the text control on the change of input style.
809 application.RunIdles();
811 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
812 DALI_TEST_CHECK( !inputStyleChangedSignal );
814 gInputStyleChangedCallbackCalled = false;
815 gInputStyleMask = TextEditor::InputStyle::NONE;
816 inputStyleChangedSignal = false;
818 // Create a tap event to touch the text editor.
819 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
820 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
823 application.SendNotification();
824 application.Render();
826 // Executes the idle callbacks added by the text control on the change of input style.
827 application.RunIdles();
829 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
830 if( gInputStyleChangedCallbackCalled )
832 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
834 Property::Map fontStyleMapSet;
835 Property::Map fontStyleMapGet;
837 fontStyleMapGet = editor.GetProperty<Property::Map>( TextEditor::Property::INPUT_FONT_STYLE );
838 DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
839 DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
841 DALI_TEST_CHECK( inputStyleChangedSignal );
843 gInputStyleChangedCallbackCalled = false;
844 gInputStyleMask = TextEditor::InputStyle::NONE;
845 inputStyleChangedSignal = false;
847 // Create a tap event to touch the text editor.
848 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
849 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
852 application.SendNotification();
853 application.Render();
855 // Executes the idle callbacks added by the text control on the change of input style.
856 application.RunIdles();
858 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
859 DALI_TEST_CHECK( !inputStyleChangedSignal );
864 int utcDaliTextEditorInputStyleChanged02(void)
866 ToolkitTestApplication application;
867 tet_infoline(" utcDaliTextEditorInputStyleChanged02");
869 // The text-editor emits signals when the input style changes. These changes of style are
870 // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
871 // can't be emitted during the size negotiation as the callbacks may update the UI.
872 // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
873 // This creates an implementation of the adaptor stub and a queue of idle callbacks.
874 application.CreateAdaptor();
878 char* pathNamePtr = get_current_dir_name();
879 const std::string pathName( pathNamePtr );
882 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
883 fontClient.SetDpi( 93u, 93u );
885 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
886 fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
888 TextEditor editor = TextEditor::New();
889 DALI_TEST_CHECK( editor );
892 editor.SetSize( 300.f, 50.f );
893 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
894 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
896 editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
897 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>" );
899 // connect to the text changed signal.
900 ConnectionTracker* testTracker = new ConnectionTracker();
901 editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
902 bool inputStyleChangedSignal = false;
903 editor.ConnectSignal( testTracker, "inputStyleChanged", CallbackFunctor(&inputStyleChangedSignal) );
905 Stage::GetCurrent().Add( editor );
908 application.SendNotification();
909 application.Render();
911 // Executes the idle callbacks added by the text control on the change of input style.
912 application.RunIdles();
914 gInputStyleChangedCallbackCalled = false;
915 gInputStyleMask = TextEditor::InputStyle::NONE;
916 inputStyleChangedSignal = false;
918 // Create a tap event to touch the text editor.
919 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
920 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
921 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
922 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
925 application.SendNotification();
926 application.Render();
928 // Executes the idle callbacks added by the text control on the change of input style.
929 application.RunIdles();
931 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
932 if( gInputStyleChangedCallbackCalled )
934 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
935 static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
936 TextEditor::InputStyle::POINT_SIZE |
937 TextEditor::InputStyle::COLOR ),
940 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
941 DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
943 const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
944 DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
946 const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
947 DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
949 DALI_TEST_CHECK( inputStyleChangedSignal );
951 gInputStyleChangedCallbackCalled = false;
952 gInputStyleMask = TextEditor::InputStyle::NONE;
953 inputStyleChangedSignal = false;
955 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
958 application.SendNotification();
959 application.Render();
961 // Executes the idle callbacks added by the text control on the change of input style.
962 application.RunIdles();
964 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
965 if( gInputStyleChangedCallbackCalled )
967 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
968 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
971 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
972 DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
974 DALI_TEST_CHECK( inputStyleChangedSignal );
976 gInputStyleChangedCallbackCalled = false;
977 gInputStyleMask = TextEditor::InputStyle::NONE;
978 inputStyleChangedSignal = false;
980 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
983 application.SendNotification();
984 application.Render();
986 // Executes the idle callbacks added by the text control on the change of input style.
987 application.RunIdles();
989 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
990 DALI_TEST_CHECK( !inputStyleChangedSignal );
992 gInputStyleChangedCallbackCalled = false;
993 gInputStyleMask = TextEditor::InputStyle::NONE;
994 inputStyleChangedSignal = false;
996 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
999 application.SendNotification();
1000 application.Render();
1002 // Executes the idle callbacks added by the text control on the change of input style.
1003 application.RunIdles();
1005 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1006 if( gInputStyleChangedCallbackCalled )
1008 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1009 static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
1012 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1013 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1015 DALI_TEST_CHECK( inputStyleChangedSignal );
1017 gInputStyleChangedCallbackCalled = false;
1018 gInputStyleMask = TextEditor::InputStyle::NONE;
1019 inputStyleChangedSignal = false;
1021 editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
1023 Property::Map fontStyleMapSet;
1024 fontStyleMapSet.Insert( "weight", "thin" );
1025 fontStyleMapSet.Insert( "width", "condensed" );
1026 fontStyleMapSet.Insert( "slant", "italic" );
1028 editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, fontStyleMapSet );
1029 editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
1030 editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
1032 editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
1033 editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
1034 editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
1035 editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
1037 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1039 // Render and notify
1040 application.SendNotification();
1041 application.Render();
1043 // Executes the idle callbacks added by the text control on the change of input style.
1044 application.RunIdles();
1046 DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1047 DALI_TEST_CHECK( !inputStyleChangedSignal );
1049 // Create a tap event to touch the text editor.
1050 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1051 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
1053 // Render and notify
1054 application.SendNotification();
1055 application.Render();
1057 // Executes the idle callbacks added by the text control on the change of input style.
1058 application.RunIdles();
1060 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1061 if( gInputStyleChangedCallbackCalled )
1063 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1064 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1065 TextEditor::InputStyle::POINT_SIZE |
1066 TextEditor::InputStyle::FONT_STYLE |
1067 TextEditor::InputStyle::LINE_SPACING |
1068 TextEditor::InputStyle::UNDERLINE |
1069 TextEditor::InputStyle::SHADOW |
1070 TextEditor::InputStyle::EMBOSS |
1071 TextEditor::InputStyle::OUTLINE ),
1074 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1075 DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1077 DALI_TEST_CHECK( inputStyleChangedSignal );
1079 gInputStyleChangedCallbackCalled = false;
1080 gInputStyleMask = TextEditor::InputStyle::NONE;
1081 inputStyleChangedSignal = false;
1083 editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
1085 fontStyleMapSet.Clear();
1086 fontStyleMapSet.Insert( "weight", "black" );
1087 fontStyleMapSet.Insert( "width", "expanded" );
1088 fontStyleMapSet.Insert( "slant", "oblique" );
1090 editor.SetProperty( TextEditor::Property::FONT_STYLE, fontStyleMapSet );
1092 // Create a tap event to touch the text editor.
1093 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1094 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
1096 // Render and notify
1097 application.SendNotification();
1098 application.Render();
1100 // Executes the idle callbacks added by the text control on the change of input style.
1101 application.RunIdles();
1103 DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1104 if( gInputStyleChangedCallbackCalled )
1106 DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
1107 static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
1108 TextEditor::InputStyle::POINT_SIZE |
1109 TextEditor::InputStyle::FONT_STYLE ),
1112 const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
1113 DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
1115 DALI_TEST_CHECK( inputStyleChangedSignal );
1120 int utcDaliTextEditorEvent01(void)
1122 ToolkitTestApplication application;
1123 tet_infoline(" utcDaliTextEditorEvent01");
1125 // Creates a tap event. After creating a tap event the text editor should
1126 // have the focus and add text with key events should be possible.
1128 TextEditor editor = TextEditor::New();
1129 DALI_TEST_CHECK( editor );
1131 Stage::GetCurrent().Add( editor );
1133 editor.SetSize( 300.f, 50.f );
1134 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1135 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1137 // Avoid a crash when core load gl resources.
1138 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1140 // Render and notify
1141 application.SendNotification();
1142 application.Render();
1144 // Add a key event but as the text editor has not the focus it should do nothing.
1145 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1147 // Render and notify
1148 application.SendNotification();
1149 application.Render();
1151 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1153 // Create a tap event to touch the text editor.
1154 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1155 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1157 // Render and notify
1158 application.SendNotification();
1159 application.Render();
1161 // Now the text editor has the focus, so it can handle the key events.
1162 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1163 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1165 // Render and notify
1166 application.SendNotification();
1167 application.Render();
1169 DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1171 // Create a second text editor and send key events to it.
1172 TextEditor editor2 = TextEditor::New();
1174 editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1175 editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1176 editor2.SetSize( 100.f, 100.f );
1177 editor2.SetPosition( 100.f, 100.f );
1179 Stage::GetCurrent().Add( editor2 );
1181 // Render and notify
1182 application.SendNotification();
1183 application.Render();
1185 // Create a tap event on the second text editor.
1186 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1187 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1189 // Render and notify
1190 application.SendNotification();
1191 application.Render();
1193 // The second text editor has the focus. It should handle the key events.
1194 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1195 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1197 // Render and notify
1198 application.SendNotification();
1199 application.Render();
1201 // Check the text has been added to the second text editor.
1202 DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1207 int utcDaliTextEditorEvent02(void)
1209 ToolkitTestApplication application;
1210 tet_infoline(" utcDaliTextEditorEvent02");
1212 // Checks if the right number of actors are created.
1214 TextEditor editor = TextEditor::New();
1215 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1216 DALI_TEST_CHECK( editor );
1218 Stage::GetCurrent().Add( editor );
1220 editor.SetSize( 300.f, 50.f );
1221 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1222 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1224 // Avoid a crash when core load gl resources.
1225 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1227 // Render and notify
1228 application.SendNotification();
1229 application.Render();
1231 // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
1232 DALI_TEST_EQUALS( editor.GetChildCount(), 2u, TEST_LOCATION );
1234 Actor offscreenRoot = editor.GetChildAt( 0u );
1235 DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1236 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1238 Actor offscreenImage = editor.GetChildAt( 1u );
1239 DALI_TEST_CHECK( offscreenImage );
1241 // Create a tap event to touch the text editor.
1242 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1243 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1245 // Render and notify
1246 application.SendNotification();
1247 application.Render();
1249 Actor layer = editor.GetChildAt( 2u );
1250 DALI_TEST_CHECK( layer.IsLayer() );
1252 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1253 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1255 // Now the text editor has the focus, so it can handle the key events.
1256 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1257 application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1259 // Render and notify
1260 application.SendNotification();
1261 application.Render();
1263 // Checks the cursor and the renderer have been created.
1264 DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1265 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
1267 Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1268 DALI_TEST_CHECK( cursor );
1270 CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1271 DALI_TEST_CHECK( camera );
1273 // The offscreen root actor has a container with all the actors which contain the text renderers.
1274 Actor container = offscreenRoot.GetChildAt( 1u );
1275 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1277 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1278 DALI_TEST_CHECK( renderer );
1281 // Move the cursor and check the position changes.
1282 Vector3 position1 = cursor.GetCurrentPosition();
1284 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1285 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1287 // Render and notify
1288 application.SendNotification();
1289 application.Render();
1291 Vector3 position2 = cursor.GetCurrentPosition();
1293 DALI_TEST_CHECK( position2.x < position1.x );
1295 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1296 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1298 // Render and notify
1299 application.SendNotification();
1300 application.Render();
1302 Vector3 position3 = cursor.GetCurrentPosition();
1304 DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1306 // Send some taps and check the cursor positions.
1308 // Try to tap at the beginning.
1309 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1310 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1312 // Render and notify
1313 application.SendNotification();
1314 application.Render();
1316 // Cursor position should be the same than position1.
1317 Vector3 position4 = cursor.GetCurrentPosition();
1319 DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1321 // Tap away from the start position.
1322 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1323 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1325 // Render and notify
1326 application.SendNotification();
1327 application.Render();
1329 Vector3 position5 = cursor.GetCurrentPosition();
1331 DALI_TEST_CHECK( position5.x > position4.x );
1333 // Remove all the text.
1334 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1335 application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1336 editor.SetProperty( TextEditor::Property::TEXT, "" );
1338 // Render and notify
1339 application.SendNotification();
1340 application.Render();
1342 // Cursor position should be the same than position2.
1343 Vector3 position6 = cursor.GetCurrentPosition();
1345 DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1347 // Should not be a renderer.
1348 DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
1353 int utcDaliTextEditorEvent03(void)
1355 ToolkitTestApplication application;
1356 tet_infoline(" utcDaliTextEditorEvent03");
1358 // Checks if the highlight actor is created.
1360 TextEditor editor = TextEditor::New();
1361 DALI_TEST_CHECK( editor );
1363 Stage::GetCurrent().Add( editor );
1365 editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1366 editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1367 editor.SetSize( 30.f, 50.f );
1368 editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1369 editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1371 // Avoid a crash when core load gl resources.
1372 application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1374 // Render and notify
1375 application.SendNotification();
1376 application.Render();
1378 // Send some taps and check text controller with clipboard window
1379 Dali::Clipboard clipboard = Clipboard::Get();
1380 clipboard.ShowClipboard();
1381 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1382 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1383 clipboard.HideClipboard();
1385 // Render and notify
1386 application.SendNotification();
1387 application.Render();
1389 // Tap first to get the focus.
1390 application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1391 application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1393 // Render and notify
1394 application.SendNotification();
1395 application.Render();
1397 // Double tap to select a word.
1398 application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1399 application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1401 // Render and notify
1402 application.SendNotification();
1403 application.Render();
1405 // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
1406 Actor offscreenRoot = editor.GetChildAt( 0u );
1407 DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1409 CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1410 DALI_TEST_CHECK( camera );
1412 // The offscreen root actor has a container with all the actors which contain the text renderers.
1413 Actor container = offscreenRoot.GetChildAt( 1u );
1414 for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1416 Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1417 DALI_TEST_CHECK( renderer );
1420 Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
1421 DALI_TEST_CHECK( highlight );