Merge "Add Text input style changed signal." into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextEditor.cpp
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/tap-gesture-event.h>
25 #include <dali-toolkit-test-suite-utils.h>
26 #include <dali-toolkit/dali-toolkit.h>
27
28 using namespace Dali;
29 using namespace Toolkit;
30
31 void dali_texteditor_startup(void)
32 {
33   test_return_value = TET_UNDEF;
34 }
35
36 void dali_texteditor_cleanup(void)
37 {
38   test_return_value = TET_PASS;
39 }
40
41 namespace
42 {
43
44 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
45 const char* const PROPERTY_NAME_TEXT                                 = "text";
46 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
47 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
48 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
49 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
50 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
51 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
52 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
53 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
54 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
55 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
56 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
57 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
58 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
59 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
60 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
61 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
62 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
63 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
64 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
65 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
66 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
67 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
68 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
69 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
70 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
71 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
72 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
73 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
74
75 const char* const PROPERTY_NAME_LINE_SPACING                         = "lineSpacing";
76 const char* const PROPERTY_NAME_INPUT_LINE_SPACING                   = "inputLineSpacing";
77 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
78 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
79 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
80 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
81 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
82 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
83 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
84 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
85
86 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
87
88 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
89
90 const unsigned int CURSOR_BLINK_INTERVAL = 500u; // Cursor blink interval
91 const float TO_MILLISECONDS = 1000.f;
92 const float TO_SECONDS = 1.f / TO_MILLISECONDS;
93
94 const float SCROLL_THRESHOLD = 10.f;
95 const float SCROLL_SPEED = 300.f;
96
97 const unsigned int DEFAULT_FONT_SIZE = 1152u;
98 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
99
100 static bool gTextChangedCallBackCalled;
101 static bool gInputStyleChangedCallbackCalled;
102 static Dali::Toolkit::TextEditor::InputStyle::Mask gInputStyleMask;
103
104 struct CallbackFunctor
105 {
106   CallbackFunctor(bool* callbackFlag)
107   : mCallbackFlag( callbackFlag )
108   {
109   }
110
111   void operator()()
112   {
113     *mCallbackFlag = true;
114   }
115   bool* mCallbackFlag;
116 };
117
118 static void TestTextChangedCallback( TextEditor control )
119 {
120   tet_infoline(" TestTextChangedCallback");
121
122   gTextChangedCallBackCalled = true;
123 }
124
125 static void TestInputStyleChangedCallback( TextEditor control, TextEditor::InputStyle::Mask mask )
126 {
127   tet_infoline(" TestInputStyleChangedCallback");
128
129   gInputStyleChangedCallbackCalled = true;
130   gInputStyleMask = mask;
131 }
132
133 // Generate a TapGestureEvent to send to Core.
134 Integration::TapGestureEvent GenerateTap(
135     Gesture::State state,
136     unsigned int numberOfTaps,
137     unsigned int numberOfTouches,
138     Vector2 point)
139 {
140   Integration::TapGestureEvent tap( state );
141
142   tap.numberOfTaps = numberOfTaps;
143   tap.numberOfTouches = numberOfTouches;
144   tap.point = point;
145
146   return tap;
147 }
148
149 // Generate a KeyEvent to send to Core.
150 Integration::KeyEvent GenerateKey( const std::string& keyName,
151                                    const std::string& keyString,
152                                    int keyCode,
153                                    int keyModifier,
154                                    unsigned long timeStamp,
155                                    const Integration::KeyEvent::State& keyState )
156 {
157   return Integration::KeyEvent( keyName,
158                                 keyString,
159                                 keyCode,
160                                 keyModifier,
161                                 timeStamp,
162                                 keyState );
163 }
164
165 } // namespace
166
167 int UtcDaliToolkitTextEditorConstructorP(void)
168 {
169   ToolkitTestApplication application;
170   tet_infoline(" UtcDaliToolkitTextEditorConstructorP");
171   TextEditor textEditor;
172   DALI_TEST_CHECK( !textEditor );
173   END_TEST;
174 }
175
176 int UtcDaliToolkitTextEditorNewP(void)
177 {
178   ToolkitTestApplication application;
179   tet_infoline(" UtcDaliToolkitTextEditorNewP");
180   TextEditor textEditor = TextEditor::New();
181   DALI_TEST_CHECK( textEditor );
182   END_TEST;
183 }
184
185 int UtcDaliToolkitTextEditorDownCastP(void)
186 {
187   ToolkitTestApplication application;
188   tet_infoline(" UtcDaliToolkitTextEditorDownCastP");
189   TextEditor textEditor1 = TextEditor::New();
190   BaseHandle object( textEditor1 );
191
192   TextEditor textEditor2 = TextEditor::DownCast( object );
193   DALI_TEST_CHECK( textEditor2 );
194
195   TextEditor textEditor3 = DownCast< TextEditor >( object );
196   DALI_TEST_CHECK( textEditor3 );
197   END_TEST;
198 }
199
200 int UtcDaliToolkitTextEditorDownCastN(void)
201 {
202   ToolkitTestApplication application;
203   tet_infoline(" UtcDaliToolkitTextEditorDownCastN");
204   BaseHandle uninitializedObject;
205   TextEditor textEditor1 = TextEditor::DownCast( uninitializedObject );
206   DALI_TEST_CHECK( !textEditor1 );
207
208   TextEditor textEditor2 = DownCast< TextEditor >( uninitializedObject );
209   DALI_TEST_CHECK( !textEditor2 );
210   END_TEST;
211 }
212
213 int UtcDaliToolkitTextEditorCopyConstructorP(void)
214 {
215   ToolkitTestApplication application;
216   tet_infoline(" UtcDaliToolkitTextEditorCopyConstructorP");
217   TextEditor textEditor = TextEditor::New();
218   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
219
220   TextEditor copy( textEditor );
221   DALI_TEST_CHECK( copy );
222   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
223   END_TEST;
224 }
225
226 int UtcDaliToolkitTextEditorAssignmentOperatorP(void)
227 {
228   ToolkitTestApplication application;
229   tet_infoline(" UtcDaliToolkitTextEditorAssignmentOperatorP");
230   TextEditor textEditor = TextEditor::New();
231   textEditor.SetProperty( TextEditor::Property::TEXT, "Test" );
232
233   TextEditor copy = textEditor;
234   DALI_TEST_CHECK( copy );
235   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextEditor::Property::TEXT ) == textEditor.GetProperty<std::string>( TextEditor::Property::TEXT ) );
236   END_TEST;
237 }
238
239 int UtcDaliTextEditorNewP(void)
240 {
241   ToolkitTestApplication application;
242   tet_infoline(" UtcDaliToolkitTextEditorNewP");
243   TextEditor textEditor = TextEditor::New();
244   DALI_TEST_CHECK( textEditor );
245   END_TEST;
246 }
247
248 // Positive test case for a method
249 int UtcDaliTextEditorGetPropertyP(void)
250 {
251   ToolkitTestApplication application;
252   tet_infoline(" UtcDaliToolkitTextEditorGetPropertyP");
253   TextEditor editor = TextEditor::New();
254   DALI_TEST_CHECK( editor );
255
256   // Check Property Indices are correct
257   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextEditor::Property::RENDERING_BACKEND );
258   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextEditor::Property::TEXT );
259   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextEditor::Property::TEXT_COLOR );
260   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextEditor::Property::FONT_FAMILY );
261   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextEditor::Property::FONT_STYLE );
262   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextEditor::Property::POINT_SIZE );
263   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextEditor::Property::HORIZONTAL_ALIGNMENT );
264   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextEditor::Property::SCROLL_THRESHOLD );
265   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextEditor::Property::SCROLL_SPEED );
266   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextEditor::Property::PRIMARY_CURSOR_COLOR );
267   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextEditor::Property::SECONDARY_CURSOR_COLOR );
268   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextEditor::Property::ENABLE_CURSOR_BLINK );
269   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextEditor::Property::CURSOR_BLINK_INTERVAL );
270   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextEditor::Property::CURSOR_BLINK_DURATION );
271   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextEditor::Property::CURSOR_WIDTH );
272   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextEditor::Property::GRAB_HANDLE_IMAGE );
273   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE );
274   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT );
275   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT );
276   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
277   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
278   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
279   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
280   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextEditor::Property::SELECTION_HIGHLIGHT_COLOR );
281   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextEditor::Property::DECORATION_BOUNDING_BOX );
282   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextEditor::Property::ENABLE_MARKUP );
283   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextEditor::Property::INPUT_COLOR );
284   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextEditor::Property::INPUT_FONT_FAMILY );
285   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextEditor::Property::INPUT_FONT_STYLE );
286   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextEditor::Property::INPUT_POINT_SIZE );
287
288   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextEditor::Property::LINE_SPACING );
289   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_LINE_SPACING ) == TextEditor::Property::INPUT_LINE_SPACING );
290   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextEditor::Property::UNDERLINE );
291   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextEditor::Property::INPUT_UNDERLINE );
292   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextEditor::Property::SHADOW );
293   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextEditor::Property::INPUT_SHADOW );
294   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextEditor::Property::EMBOSS );
295   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextEditor::Property::INPUT_EMBOSS );
296   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextEditor::Property::OUTLINE );
297   DALI_TEST_CHECK( editor.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextEditor::Property::INPUT_OUTLINE );
298
299   END_TEST;
300 }
301
302 bool SetPropertyMapRetrieved( TextEditor& editor, const Property::Index property, const std::string mapKey, const std::string mapValue )
303 {
304   bool result = false;
305   Property::Map imageMap;
306   imageMap[mapKey] =mapValue;
307
308   editor.SetProperty( property , imageMap );
309   Property::Value propValue = editor.GetProperty( property );
310   Property::Map* resultMap = propValue.GetMap();
311
312   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
313   {
314     result = true;
315   }
316
317   return result;
318 }
319
320 // Positive test case for a method
321 int UtcDaliTextEditorSetPropertyP(void)
322 {
323   ToolkitTestApplication application;
324   tet_infoline(" UtcDaliToolkitTextEditorSetPropertyP");
325   TextEditor editor = TextEditor::New();
326   DALI_TEST_CHECK( editor );
327   Stage::GetCurrent().Add( editor );
328
329   // Note - we can't check the defaults since the stylesheets are platform-specific
330
331   // Check the render backend property.
332   editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
333   DALI_TEST_EQUALS( (Text::RenderingType)editor.GetProperty<int>( TextEditor::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
334
335   // Check text property.
336   editor.SetProperty( TextEditor::Property::TEXT, "Setting Text" );
337   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
338
339   // Check text's color property
340   editor.SetProperty( TextEditor::Property::TEXT_COLOR, Color::WHITE );
341   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
342
343   // Check font properties.
344   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "Setting font family" );
345   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
346   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
347   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE ), std::string("{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}"), TEST_LOCATION );
348   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
349   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
350
351   // Reset font style.
352   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" );
353   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION );
354   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"slant\":\"roman\"}" );
355   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
356   editor.SetProperty( TextEditor::Property::FONT_STYLE, "" );
357   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::FONT_STYLE ), std::string(""), TEST_LOCATION );
358
359   // Check that the Alignment properties can be correctly set
360   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "END" );
361   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
362
363   // Check scroll properties.
364   editor.SetProperty( TextEditor::Property::SCROLL_THRESHOLD, 1.f );
365   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
366   editor.SetProperty( TextEditor::Property::SCROLL_SPEED, 100.f );
367   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
368
369   // Check cursor properties
370   editor.SetProperty( TextEditor::Property::PRIMARY_CURSOR_COLOR, Color::RED );
371   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
372   editor.SetProperty( TextEditor::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
373   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
374
375   editor.SetProperty( TextEditor::Property::ENABLE_CURSOR_BLINK, false );
376   DALI_TEST_EQUALS( editor.GetProperty<bool>( TextEditor::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
377   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_INTERVAL, 1.f );
378   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
379   editor.SetProperty( TextEditor::Property::CURSOR_BLINK_DURATION, 10.f );
380   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
381   editor.SetProperty( TextEditor::Property::CURSOR_WIDTH, 1 );
382   DALI_TEST_EQUALS( editor.GetProperty<int>( TextEditor::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
383
384   // Check handle images
385   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_IMAGE, "image1" );
386   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
387   editor.SetProperty( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
388   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
389   editor.SetProperty( TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
390
391   // Check handle images
392   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
393   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
394   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
395   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
396   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
397   DALI_TEST_CHECK( SetPropertyMapRetrieved( editor, TextEditor::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
398
399   // Check the highlight color
400   editor.SetProperty( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
401   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
402
403   // Decoration bounding box
404   editor.SetProperty( TextEditor::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
405   DALI_TEST_EQUALS( editor.GetProperty<Rect <int > >( TextEditor::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
406
407   // Check the enable markup property.
408   DALI_TEST_CHECK( !editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
409   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
410   DALI_TEST_CHECK( editor.GetProperty<bool>( TextEditor::Property::ENABLE_MARKUP ) );
411
412   // Check input color property.
413   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
414   DALI_TEST_EQUALS( editor.GetProperty<Vector4>( TextEditor::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
415
416   // Check input font properties.
417   editor.SetProperty( TextEditor::Property::INPUT_FONT_FAMILY, "Setting input font family" );
418   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
419   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
420   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), "{\"weight\":\"bold\",\"width\":\"condensed\",\"slant\":\"italic\"}", TEST_LOCATION );
421   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 12.f );
422   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
423
424   // Reset input font style.
425   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"weight\":\"normal\",\"slant\":\"oblique\"}" );
426   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), std::string("{\"weight\":\"normal\",\"slant\":\"oblique\"}"), TEST_LOCATION );
427   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"slant\":\"roman\"}" );
428   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), std::string("{\"slant\":\"normal\"}"), TEST_LOCATION );
429   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "" );
430   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_FONT_STYLE ), std::string(""), TEST_LOCATION );
431
432   // Check the line spacing property
433   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
434   editor.SetProperty( TextEditor::Property::LINE_SPACING, 10.f );
435   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
436
437   // Check the input line spacing property
438   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
439   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 20.f );
440   DALI_TEST_EQUALS( editor.GetProperty<float>( TextEditor::Property::INPUT_LINE_SPACING ), 20.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
441
442   // Check the underline property
443   editor.SetProperty( TextEditor::Property::UNDERLINE, "Underline properties" );
444   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::UNDERLINE ), std::string("Underline properties"), TEST_LOCATION );
445
446   // Check the input underline property
447   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "Underline input properties" );
448   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
449
450   // Check the shadow property
451   editor.SetProperty( TextEditor::Property::SHADOW, "Shadow properties" );
452   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::SHADOW ), std::string("Shadow properties"), TEST_LOCATION );
453
454   // Check the input shadow property
455   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "Shadow input properties" );
456   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
457
458   // Check the emboss property
459   editor.SetProperty( TextEditor::Property::EMBOSS, "Emboss properties" );
460   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
461
462   // Check the input emboss property
463   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "Emboss input properties" );
464   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
465
466   // Check the outline property
467   editor.SetProperty( TextEditor::Property::OUTLINE, "Outline properties" );
468   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
469
470   // Check the input outline property
471   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "Outline input properties" );
472   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
473
474   END_TEST;
475 }
476
477 // Positive Atlas Text Renderer test
478 int utcDaliTextEditorAtlasRenderP(void)
479 {
480   ToolkitTestApplication application;
481   tet_infoline(" UtcDaliToolkitTextEditorAtlasRenderP");
482   StyleManager styleManager = StyleManager::Get();
483   styleManager.ApplyDefaultTheme();
484   TextEditor editor = TextEditor::New();
485   DALI_TEST_CHECK( editor );
486
487   editor.SetProperty( TextEditor::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
488
489   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
490
491   Stage::GetCurrent().Add( editor );
492
493   try
494   {
495     // Render some text with the shared atlas backend
496     editor.SetProperty( TextEditor::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
497     application.SendNotification();
498     application.Render();
499   }
500   catch( ... )
501   {
502     tet_result(TET_FAIL);
503   }
504   END_TEST;
505 }
506
507 // Positive test for the textChanged signal.
508 int utcDaliTextEditorTextChangedP(void)
509 {
510   ToolkitTestApplication application;
511   tet_infoline(" utcDaliTextEditorTextChangedP");
512   TextEditor editor = TextEditor::New();
513   DALI_TEST_CHECK( editor );
514
515   Stage::GetCurrent().Add( editor );
516
517   // connect to the text changed signal.
518   ConnectionTracker* testTracker = new ConnectionTracker();
519   editor.TextChangedSignal().Connect( &TestTextChangedCallback );
520   bool textChangedSignal = false;
521   editor.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
522
523   gTextChangedCallBackCalled = false;
524   editor.SetProperty( TextEditor::Property::TEXT, "ABC" );
525   DALI_TEST_CHECK( gTextChangedCallBackCalled );
526   DALI_TEST_CHECK( textChangedSignal );
527
528   application.SendNotification();
529
530   editor.SetKeyInputFocus();
531
532   gTextChangedCallBackCalled = false;
533   application.ProcessEvent( GenerateKey( "D", "D", 0, 0, 0, Integration::KeyEvent::Down ) );
534   DALI_TEST_CHECK( gTextChangedCallBackCalled );
535
536   END_TEST;
537 }
538
539 int utcDaliTextEditorInputStyleChanged01(void)
540 {
541   ToolkitTestApplication application;
542   tet_infoline(" utcDaliTextEditorInputStyleChanged01");
543
544   // The text-editor emits signals when the input style changes. These changes of style are
545   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
546   // can't be emitted during the size negotiation as the callbacks may update the UI.
547   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
548   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
549   application.CreateAdaptor();
550
551   // Load some fonts.
552
553   char* pathNamePtr = get_current_dir_name();
554   const std::string pathName( pathNamePtr );
555   free( pathNamePtr );
556
557   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
558   fontClient.SetDpi( 93u, 93u );
559
560   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
561   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
562
563   TextEditor editor = TextEditor::New();
564   DALI_TEST_CHECK( editor );
565
566
567   editor.SetSize( 300.f, 50.f );
568   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
569   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
570
571   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
572   editor.SetProperty( TextEditor::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
573
574   // connect to the text changed signal.
575   ConnectionTracker* testTracker = new ConnectionTracker();
576   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
577   bool inputStyleChangedSignal = false;
578   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
579
580   Stage::GetCurrent().Add( editor );
581
582   // Render and notify
583   application.SendNotification();
584   application.Render();
585
586   // Executes the idle callbacks added by the text control on the change of input style.
587   application.RunIdles();
588
589   gInputStyleChangedCallbackCalled = false;
590   gInputStyleMask = TextEditor::InputStyle::NONE;
591   inputStyleChangedSignal = false;
592
593   // Create a tap event to touch the text editor.
594   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 18.f, 25.f ) ) );
595   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 18.f, 25.f ) ) );
596
597   // Render and notify
598   application.SendNotification();
599   application.Render();
600
601   // Executes the idle callbacks added by the text control on the change of input style.
602   application.RunIdles();
603
604   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
605   if( gInputStyleChangedCallbackCalled )
606   {
607     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY | TextEditor::InputStyle::POINT_SIZE ), TEST_LOCATION );
608
609     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
610     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
611
612     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
613     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
614   }
615   DALI_TEST_CHECK( inputStyleChangedSignal );
616
617   gInputStyleChangedCallbackCalled = false;
618   gInputStyleMask = TextEditor::InputStyle::NONE;
619   inputStyleChangedSignal = false;
620
621   // Create a tap event to touch the text editor.
622   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
623   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
624
625   // Render and notify
626   application.SendNotification();
627   application.Render();
628
629   // Executes the idle callbacks added by the text control on the change of input style.
630   application.RunIdles();
631
632   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
633   DALI_TEST_CHECK( !inputStyleChangedSignal );
634
635   gInputStyleChangedCallbackCalled = false;
636   gInputStyleMask = TextEditor::InputStyle::NONE;
637   inputStyleChangedSignal = false;
638
639   // Create a tap event to touch the text editor.
640   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 43.f, 25.f ) ) );
641   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 43.f, 25.f ) ) );
642
643   // Render and notify
644   application.SendNotification();
645   application.Render();
646
647   // Executes the idle callbacks added by the text control on the change of input style.
648   application.RunIdles();
649
650   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
651   if( gInputStyleChangedCallbackCalled )
652   {
653     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR ), TEST_LOCATION );
654
655     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
656     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
657   }
658   DALI_TEST_CHECK( inputStyleChangedSignal );
659
660   gInputStyleChangedCallbackCalled = false;
661   gInputStyleMask = TextEditor::InputStyle::NONE;
662   inputStyleChangedSignal = false;
663
664   // Create a tap event to touch the text editor.
665   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 88.f, 25.f ) ) );
666   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 88.f, 25.f ) ) );
667
668   // Render and notify
669   application.SendNotification();
670   application.Render();
671
672   // Executes the idle callbacks added by the text control on the change of input style.
673   application.RunIdles();
674
675   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
676   if( gInputStyleChangedCallbackCalled )
677   {
678     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::COLOR | TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
679
680     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
681     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
682
683     const std::string style = editor.GetProperty( TextEditor::Property::INPUT_FONT_STYLE ).Get<std::string>();
684     DALI_TEST_EQUALS( style, "{\"weight\":\"bold\"}", TEST_LOCATION );
685   }
686   DALI_TEST_CHECK( inputStyleChangedSignal );
687
688   gInputStyleChangedCallbackCalled = false;
689   gInputStyleMask = TextEditor::InputStyle::NONE;
690   inputStyleChangedSignal = false;
691
692   // Create a tap event to touch the text editor.
693   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 115.f, 25.f ) ) );
694   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 115.f, 25.f ) ) );
695
696   // Render and notify
697   application.SendNotification();
698   application.Render();
699
700   // Executes the idle callbacks added by the text control on the change of input style.
701   application.RunIdles();
702
703   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
704   DALI_TEST_CHECK( !inputStyleChangedSignal );
705
706   gInputStyleChangedCallbackCalled = false;
707   gInputStyleMask = TextEditor::InputStyle::NONE;
708   inputStyleChangedSignal = false;
709
710   // Create a tap event to touch the text editor.
711   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 164.f, 25.f ) ) );
712   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 164.f, 25.f ) ) );
713
714   // Render and notify
715   application.SendNotification();
716   application.Render();
717
718   // Executes the idle callbacks added by the text control on the change of input style.
719   application.RunIdles();
720
721   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
722   if( gInputStyleChangedCallbackCalled )
723   {
724     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextEditor::InputStyle::FONT_STYLE ), TEST_LOCATION );
725
726     const std::string style = editor.GetProperty( TextEditor::Property::INPUT_FONT_STYLE ).Get<std::string>();
727     DALI_TEST_CHECK( style.empty() );
728   }
729   DALI_TEST_CHECK( inputStyleChangedSignal );
730
731   gInputStyleChangedCallbackCalled = false;
732   gInputStyleMask = TextEditor::InputStyle::NONE;
733   inputStyleChangedSignal = false;
734
735   // Create a tap event to touch the text editor.
736   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 191.f, 25.f ) ) );
737   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 191.f, 25.f ) ) );
738
739   // Render and notify
740   application.SendNotification();
741   application.Render();
742
743   // Executes the idle callbacks added by the text control on the change of input style.
744   application.RunIdles();
745
746   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
747   DALI_TEST_CHECK( !inputStyleChangedSignal );
748
749   END_TEST;
750 }
751
752 int utcDaliTextEditorInputStyleChanged02(void)
753 {
754   ToolkitTestApplication application;
755   tet_infoline(" utcDaliTextEditorInputStyleChanged02");
756
757   // The text-editor emits signals when the input style changes. These changes of style are
758   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
759   // can't be emitted during the size negotiation as the callbacks may update the UI.
760   // The text-editor adds an idle callback to the adaptor to emit the signals after the size negotiation.
761   // This creates an implementation of the adaptor stub and a queue of idle callbacks.
762   application.CreateAdaptor();
763
764   // Load some fonts.
765
766   char* pathNamePtr = get_current_dir_name();
767   const std::string pathName( pathNamePtr );
768   free( pathNamePtr );
769
770   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
771   fontClient.SetDpi( 93u, 93u );
772
773   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
774   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
775
776   TextEditor editor = TextEditor::New();
777   DALI_TEST_CHECK( editor );
778
779
780   editor.SetSize( 300.f, 50.f );
781   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
782   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
783
784   editor.SetProperty( TextEditor::Property::ENABLE_MARKUP, true );
785   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>" );
786
787   // connect to the text changed signal.
788   ConnectionTracker* testTracker = new ConnectionTracker();
789   editor.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
790   bool inputStyleChangedSignal = false;
791   editor.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
792
793   Stage::GetCurrent().Add( editor );
794
795   // Render and notify
796   application.SendNotification();
797   application.Render();
798
799   // Executes the idle callbacks added by the text control on the change of input style.
800   application.RunIdles();
801
802   gInputStyleChangedCallbackCalled = false;
803   gInputStyleMask = TextEditor::InputStyle::NONE;
804   inputStyleChangedSignal = false;
805
806   // Create a tap event to touch the text editor.
807   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 53.f, 25.f ) ) );
808   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 53.f, 25.f ) ) );
809   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 53.f, 25.f ) ) );
810   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 53.f, 25.f ) ) );
811
812   // Render and notify
813   application.SendNotification();
814   application.Render();
815
816   // Executes the idle callbacks added by the text control on the change of input style.
817   application.RunIdles();
818
819   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
820   if( gInputStyleChangedCallbackCalled )
821   {
822     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
823                       static_cast<unsigned int>( TextEditor::InputStyle::FONT_FAMILY |
824                                                  TextEditor::InputStyle::POINT_SIZE  |
825                                                  TextEditor::InputStyle::COLOR ),
826                       TEST_LOCATION );
827
828     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
829     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
830
831     const std::string fontFamily = editor.GetProperty( TextEditor::Property::INPUT_FONT_FAMILY ).Get<std::string>();
832     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
833
834     const float pointSize = editor.GetProperty( TextEditor::Property::INPUT_POINT_SIZE ).Get<float>();
835     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
836   }
837   DALI_TEST_CHECK( inputStyleChangedSignal );
838
839   gInputStyleChangedCallbackCalled = false;
840   gInputStyleMask = TextEditor::InputStyle::NONE;
841   inputStyleChangedSignal = false;
842
843   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
844
845   // Render and notify
846   application.SendNotification();
847   application.Render();
848
849   // Executes the idle callbacks added by the text control on the change of input style.
850   application.RunIdles();
851
852   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
853   if( gInputStyleChangedCallbackCalled )
854   {
855     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
856                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
857                       TEST_LOCATION );
858
859     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
860     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
861   }
862   DALI_TEST_CHECK( inputStyleChangedSignal );
863
864   gInputStyleChangedCallbackCalled = false;
865   gInputStyleMask = TextEditor::InputStyle::NONE;
866   inputStyleChangedSignal = false;
867
868   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
869
870   // Render and notify
871   application.SendNotification();
872   application.Render();
873
874   // Executes the idle callbacks added by the text control on the change of input style.
875   application.RunIdles();
876
877   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
878   DALI_TEST_CHECK( !inputStyleChangedSignal );
879
880   gInputStyleChangedCallbackCalled = false;
881   gInputStyleMask = TextEditor::InputStyle::NONE;
882   inputStyleChangedSignal = false;
883
884   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
885
886   // Render and notify
887   application.SendNotification();
888   application.Render();
889
890   // Executes the idle callbacks added by the text control on the change of input style.
891   application.RunIdles();
892
893   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
894   if( gInputStyleChangedCallbackCalled )
895   {
896     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
897                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR ),
898                       TEST_LOCATION );
899
900     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
901     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
902   }
903   DALI_TEST_CHECK( inputStyleChangedSignal );
904
905   gInputStyleChangedCallbackCalled = false;
906   gInputStyleMask = TextEditor::InputStyle::NONE;
907   inputStyleChangedSignal = false;
908
909   editor.SetProperty( TextEditor::Property::INPUT_COLOR, Color::YELLOW );
910
911   editor.SetProperty( TextEditor::Property::INPUT_FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"condensed\",\"slant\":\"italic\"}" );
912   editor.SetProperty( TextEditor::Property::INPUT_POINT_SIZE, 20.f );
913   editor.SetProperty( TextEditor::Property::INPUT_LINE_SPACING, 5.f );
914
915   editor.SetProperty( TextEditor::Property::INPUT_UNDERLINE, "underline" );
916   editor.SetProperty( TextEditor::Property::INPUT_SHADOW, "shadow" );
917   editor.SetProperty( TextEditor::Property::INPUT_EMBOSS, "emboss" );
918   editor.SetProperty( TextEditor::Property::INPUT_OUTLINE, "outline" );
919
920   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
921
922   // Render and notify
923   application.SendNotification();
924   application.Render();
925
926   // Executes the idle callbacks added by the text control on the change of input style.
927   application.RunIdles();
928
929   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
930   DALI_TEST_CHECK( !inputStyleChangedSignal );
931
932   // Create a tap event to touch the text editor.
933   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 63.f, 25.f ) ) );
934   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 63.f, 25.f ) ) );
935
936   // Render and notify
937   application.SendNotification();
938   application.Render();
939
940   // Executes the idle callbacks added by the text control on the change of input style.
941   application.RunIdles();
942
943   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
944   if( gInputStyleChangedCallbackCalled )
945   {
946     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
947                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
948                                                  TextEditor::InputStyle::POINT_SIZE |
949                                                  TextEditor::InputStyle::FONT_STYLE |
950                                                  TextEditor::InputStyle::LINE_SPACING |
951                                                  TextEditor::InputStyle::UNDERLINE |
952                                                  TextEditor::InputStyle::SHADOW |
953                                                  TextEditor::InputStyle::EMBOSS |
954                                                  TextEditor::InputStyle::OUTLINE ),
955                       TEST_LOCATION );
956
957     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
958     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
959   }
960   DALI_TEST_CHECK( inputStyleChangedSignal );
961
962   gInputStyleChangedCallbackCalled = false;
963   gInputStyleMask = TextEditor::InputStyle::NONE;
964   inputStyleChangedSignal = false;
965
966   editor.SetProperty( TextEditor::Property::FONT_FAMILY, "DejaVuSerif" );
967   editor.SetProperty( TextEditor::Property::FONT_STYLE, "{\"weight\":\"black\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
968
969   // Create a tap event to touch the text editor.
970   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 30.f, 25.f ) ) );
971   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 30.f, 25.f ) ) );
972
973   // Render and notify
974   application.SendNotification();
975   application.Render();
976
977   // Executes the idle callbacks added by the text control on the change of input style.
978   application.RunIdles();
979
980   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
981   if( gInputStyleChangedCallbackCalled )
982   {
983     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
984                       static_cast<unsigned int>( TextEditor::InputStyle::COLOR |
985                                                  TextEditor::InputStyle::POINT_SIZE |
986                                                  TextEditor::InputStyle::FONT_STYLE ),
987                       TEST_LOCATION );
988
989     const Vector4 color = editor.GetProperty( TextEditor::Property::INPUT_COLOR ).Get<Vector4>();
990     DALI_TEST_EQUALS( color, Color::YELLOW, TEST_LOCATION );
991   }
992   DALI_TEST_CHECK( inputStyleChangedSignal );
993
994   END_TEST;
995 }
996
997 int utcDaliTextEditorEvent01(void)
998 {
999   ToolkitTestApplication application;
1000   tet_infoline(" utcDaliTextEditorEvent01");
1001
1002   // Creates a tap event. After creating a tap event the text editor should
1003   // have the focus and add text with key events should be possible.
1004
1005   TextEditor editor = TextEditor::New();
1006   DALI_TEST_CHECK( editor );
1007
1008   Stage::GetCurrent().Add( editor );
1009
1010   editor.SetSize( 300.f, 50.f );
1011   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1012   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1013
1014   // Avoid a crash when core load gl resources.
1015   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1016
1017   // Render and notify
1018   application.SendNotification();
1019   application.Render();
1020
1021   // Add a key event but as the text editor has not the focus it should do nothing.
1022   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1023
1024   // Render and notify
1025   application.SendNotification();
1026   application.Render();
1027
1028   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string(""), TEST_LOCATION );
1029
1030   // Create a tap event to touch the text editor.
1031   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1032   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1033
1034   // Render and notify
1035   application.SendNotification();
1036   application.Render();
1037
1038   // Now the text editor has the focus, so it can handle the key events.
1039   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1040   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1041
1042   // Render and notify
1043   application.SendNotification();
1044   application.Render();
1045
1046   DALI_TEST_EQUALS( editor.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1047
1048   // Create a second text editor and send key events to it.
1049   TextEditor editor2 = TextEditor::New();
1050
1051   editor2.SetParentOrigin( ParentOrigin::TOP_LEFT );
1052   editor2.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1053   editor2.SetSize( 100.f, 100.f );
1054   editor2.SetPosition( 100.f, 100.f );
1055
1056   Stage::GetCurrent().Add( editor2 );
1057
1058   // Render and notify
1059   application.SendNotification();
1060   application.Render();
1061
1062   // Create a tap event on the second text editor.
1063   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1064   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 125.0f ) ) );
1065
1066   // Render and notify
1067   application.SendNotification();
1068   application.Render();
1069
1070   // The second text editor has the focus. It should handle the key events.
1071   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1072   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1073
1074   // Render and notify
1075   application.SendNotification();
1076   application.Render();
1077
1078   // Check the text has been added to the second text editor.
1079   DALI_TEST_EQUALS( editor2.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("aa"), TEST_LOCATION );
1080
1081   END_TEST;
1082 }
1083
1084 int utcDaliTextEditorEvent02(void)
1085 {
1086   ToolkitTestApplication application;
1087   tet_infoline(" utcDaliTextEditorEvent02");
1088
1089   // Checks if the right number of actors are created.
1090
1091   TextEditor editor = TextEditor::New();
1092   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1093   DALI_TEST_CHECK( editor );
1094
1095   Stage::GetCurrent().Add( editor );
1096
1097   editor.SetSize( 300.f, 50.f );
1098   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1099   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1100
1101   // Avoid a crash when core load gl resources.
1102   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1103
1104   // Render and notify
1105   application.SendNotification();
1106   application.Render();
1107
1108   // Check there are the expected number of children ( offscreen root actor, and the offscreen image view
1109   DALI_TEST_EQUALS( editor.GetChildCount(), 2u, TEST_LOCATION );
1110
1111   Actor offscreenRoot = editor.GetChildAt( 0u );
1112   DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1113   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1114
1115   Actor offscreenImage = editor.GetChildAt( 1u );
1116   DALI_TEST_CHECK( offscreenImage );
1117
1118   // Create a tap event to touch the text editor.
1119   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1120   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 150.0f, 25.0f ) ) );
1121
1122   // Render and notify
1123   application.SendNotification();
1124   application.Render();
1125
1126   Actor layer = editor.GetChildAt( 2u );
1127   DALI_TEST_CHECK( layer.IsLayer() );
1128
1129   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1130   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor.
1131
1132   // Now the text editor has the focus, so it can handle the key events.
1133   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1134   application.ProcessEvent( GenerateKey( "a", "a", 0, 0, 0, Integration::KeyEvent::Down ) );
1135
1136   // Render and notify
1137   application.SendNotification();
1138   application.Render();
1139
1140   // Checks the cursor and the renderer have been created.
1141   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
1142   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 2u, TEST_LOCATION ); // The camera actor and the renderer
1143
1144   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
1145   DALI_TEST_CHECK( cursor );
1146
1147   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1148   DALI_TEST_CHECK( camera );
1149
1150   // The offscreen root actor has a container with all the actors which contain the text renderers.
1151   Actor container = offscreenRoot.GetChildAt( 1u );
1152   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1153   {
1154     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1155     DALI_TEST_CHECK( renderer );
1156   }
1157
1158   // Move the cursor and check the position changes.
1159   Vector3 position1 = cursor.GetCurrentPosition();
1160
1161   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1162   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::Down ) );
1163
1164   // Render and notify
1165   application.SendNotification();
1166   application.Render();
1167
1168   Vector3 position2 = cursor.GetCurrentPosition();
1169
1170   DALI_TEST_CHECK( position2.x < position1.x );
1171
1172   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1173   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::Down ) );
1174
1175   // Render and notify
1176   application.SendNotification();
1177   application.Render();
1178
1179   Vector3 position3 = cursor.GetCurrentPosition();
1180
1181   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
1182
1183   // Send some taps and check the cursor positions.
1184
1185   // Try to tap at the beginning.
1186   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1187   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 1.f, 25.0f ) ) );
1188
1189   // Render and notify
1190   application.SendNotification();
1191   application.Render();
1192
1193   // Cursor position should be the same than position1.
1194   Vector3 position4 = cursor.GetCurrentPosition();
1195
1196   DALI_TEST_EQUALS( position2, position4, TEST_LOCATION ); // Should be in the same position2.
1197
1198   // Tap away from the start position.
1199   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 16.f, 25.0f ) ) );
1200   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 16.0f, 25.0f ) ) );
1201
1202   // Render and notify
1203   application.SendNotification();
1204   application.Render();
1205
1206   Vector3 position5 = cursor.GetCurrentPosition();
1207
1208   DALI_TEST_CHECK( position5.x > position4.x );
1209
1210   // Remove all the text.
1211   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1212   application.ProcessEvent( GenerateKey( "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::Down ) );
1213   editor.SetProperty( TextEditor::Property::TEXT, "" );
1214
1215   // Render and notify
1216   application.SendNotification();
1217   application.Render();
1218
1219   // Cursor position should be the same than position2.
1220   Vector3 position6 = cursor.GetCurrentPosition();
1221
1222   DALI_TEST_EQUALS( position2, position6, TEST_LOCATION );// Should be in the same position2.
1223
1224   // Should not be a renderer.
1225   DALI_TEST_EQUALS( offscreenRoot.GetChildCount(), 1u, TEST_LOCATION ); // The camera actor only.
1226
1227   END_TEST;
1228 }
1229
1230 int utcDaliTextEditorEvent03(void)
1231 {
1232   ToolkitTestApplication application;
1233   tet_infoline(" utcDaliTextEditorEvent03");
1234
1235   // Checks if the highlight actor is created.
1236
1237   TextEditor editor = TextEditor::New();
1238   DALI_TEST_CHECK( editor );
1239
1240   Stage::GetCurrent().Add( editor );
1241
1242   editor.SetProperty( TextEditor::Property::TEXT, "This is a long text for the size of the text-editor." );
1243   editor.SetProperty( TextEditor::Property::POINT_SIZE, 10.f );
1244   editor.SetSize( 30.f, 50.f );
1245   editor.SetParentOrigin( ParentOrigin::TOP_LEFT );
1246   editor.SetAnchorPoint( AnchorPoint::TOP_LEFT );
1247
1248   // Avoid a crash when core load gl resources.
1249   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1250
1251   // Render and notify
1252   application.SendNotification();
1253   application.Render();
1254
1255   // Tap first to get the focus.
1256   application.ProcessEvent( GenerateTap( Gesture::Possible, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1257   application.ProcessEvent( GenerateTap( Gesture::Started, 1u, 1u, Vector2( 3.f, 25.0f ) ) );
1258
1259   // Render and notify
1260   application.SendNotification();
1261   application.Render();
1262
1263   // Double tap to select a word.
1264   application.ProcessEvent( GenerateTap( Gesture::Possible, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1265   application.ProcessEvent( GenerateTap( Gesture::Started, 2u, 1u, Vector2( 3.f, 25.0f ) ) );
1266
1267   // Render and notify
1268   application.SendNotification();
1269   application.Render();
1270
1271   // The offscreen root actor should have three actors: the camera, a renderer and the highlight actor.
1272   Actor offscreenRoot = editor.GetChildAt( 0u );
1273   DALI_TEST_CHECK( offscreenRoot.IsLayer() );
1274
1275   CameraActor camera = CameraActor::DownCast( offscreenRoot.GetChildAt( 0u ) );
1276   DALI_TEST_CHECK( camera );
1277
1278   // The offscreen root actor has a container with all the actors which contain the text renderers.
1279   Actor container = offscreenRoot.GetChildAt( 1u );
1280   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
1281   {
1282     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
1283     DALI_TEST_CHECK( renderer );
1284   }
1285
1286   Renderer highlight = offscreenRoot.GetChildAt( 2u ).GetRendererAt( 0u );
1287   DALI_TEST_CHECK( highlight );
1288
1289   END_TEST;
1290 }