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