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