Merge "Add KEYBOARD_FOCUSABLE_CHILDREN property. Whether the children of this actor...
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextField.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <iostream>
19 #include <stdlib.h>
20 #include <unistd.h>
21
22 #include <dali/public-api/rendering/renderer.h>
23 #include <dali/integration-api/events/key-event-integ.h>
24 #include <dali/integration-api/events/touch-event-integ.h>
25
26 #include <dali/devel-api/adaptor-framework/key-devel.h>
27 #include <dali/devel-api/text-abstraction/font-client.h>
28 #include <dali-toolkit-test-suite-utils.h>
29 #include <dali-toolkit/dali-toolkit.h>
30 #include <dali-toolkit/devel-api/controls/text-controls/text-field-devel.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include "toolkit-clipboard.h"
33 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
34
35 using namespace Dali;
36 using namespace Toolkit;
37
38 void dali_textfield_startup(void)
39 {
40   test_return_value = TET_UNDEF;
41 }
42
43 void dali_textfield_cleanup(void)
44 {
45   test_return_value = TET_PASS;
46 }
47
48 namespace
49 {
50
51 const char* const PROPERTY_NAME_RENDERING_BACKEND                    = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT                                 = "text";
53 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT                     = "placeholderText";
54 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED             = "placeholderTextFocused";
55 const char* const PROPERTY_NAME_FONT_FAMILY                          = "fontFamily";
56 const char* const PROPERTY_NAME_FONT_STYLE                           = "fontStyle";
57 const char* const PROPERTY_NAME_POINT_SIZE                           = "pointSize";
58 const char* const PROPERTY_NAME_MAX_LENGTH                           = "maxLength";
59 const char* const PROPERTY_NAME_EXCEED_POLICY                        = "exceedPolicy";
60 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT                 = "horizontalAlignment";
61 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT                   = "verticalAlignment";
62 const char* const PROPERTY_NAME_TEXT_COLOR                           = "textColor";
63 const char* const PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR               = "placeholderTextColor";
64 const char* const PROPERTY_NAME_PRIMARY_CURSOR_COLOR                 = "primaryCursorColor";
65 const char* const PROPERTY_NAME_SECONDARY_CURSOR_COLOR               = "secondaryCursorColor";
66 const char* const PROPERTY_NAME_ENABLE_CURSOR_BLINK                  = "enableCursorBlink";
67 const char* const PROPERTY_NAME_CURSOR_BLINK_INTERVAL                = "cursorBlinkInterval";
68 const char* const PROPERTY_NAME_CURSOR_BLINK_DURATION                = "cursorBlinkDuration";
69 const char* const PROPERTY_NAME_CURSOR_WIDTH                         = "cursorWidth";
70 const char* const PROPERTY_NAME_GRAB_HANDLE_IMAGE                    = "grabHandleImage";
71 const char* const PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE            = "grabHandlePressedImage";
72 const char* const PROPERTY_NAME_SCROLL_THRESHOLD                     = "scrollThreshold";
73 const char* const PROPERTY_NAME_SCROLL_SPEED                         = "scrollSpeed";
74 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT          = "selectionHandleImageLeft";
75 const char* const PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT         = "selectionHandleImageRight";
76 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT  = "selectionHandlePressedImageLeft";
77 const char* const PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT = "selectionHandlePressedImageRight";
78 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT   = "selectionHandleMarkerImageLeft";
79 const char* const PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT  = "selectionHandleMarkerImageRight";
80 const char* const PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR            = "selectionHighlightColor";
81 const char* const PROPERTY_NAME_DECORATION_BOUNDING_BOX              = "decorationBoundingBox";
82 const char* const PROPERTY_NAME_INPUT_METHOD_SETTINGS                = "inputMethodSettings";
83 const char* const PROPERTY_NAME_INPUT_COLOR                          = "inputColor";
84 const char* const PROPERTY_NAME_ENABLE_MARKUP                        = "enableMarkup";
85 const char* const PROPERTY_NAME_INPUT_FONT_FAMILY                    = "inputFontFamily";
86 const char* const PROPERTY_NAME_INPUT_FONT_STYLE                     = "inputFontStyle";
87 const char* const PROPERTY_NAME_INPUT_POINT_SIZE                     = "inputPointSize";
88
89 const char* const PROPERTY_NAME_UNDERLINE                            = "underline";
90 const char* const PROPERTY_NAME_INPUT_UNDERLINE                      = "inputUnderline";
91 const char* const PROPERTY_NAME_SHADOW                               = "shadow";
92 const char* const PROPERTY_NAME_INPUT_SHADOW                         = "inputShadow";
93 const char* const PROPERTY_NAME_EMBOSS                               = "emboss";
94 const char* const PROPERTY_NAME_INPUT_EMBOSS                         = "inputEmboss";
95 const char* const PROPERTY_NAME_OUTLINE                              = "outline";
96 const char* const PROPERTY_NAME_INPUT_OUTLINE                        = "inputOutline";
97
98 const char* const PROPERTY_NAME_HIDDEN_INPUT_SETTINGS                = "hiddenInputSettings";
99 const char* const PROPERTY_NAME_PIXEL_SIZE                           = "pixelSize";
100 const char* const PROPERTY_NAME_ENABLE_SELECTION                     = "enableSelection";
101 const char* const PROPERTY_NAME_PLACEHOLDER                          = "placeholder";
102 const char* const PROPERTY_NAME_ELLIPSIS                             = "ellipsis";
103 const char* const PROPERTY_NAME_ENABLE_SHIFT_SELECTION               = "enableShiftSelection";
104 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE                   = "enableGrabHandle";
105 const char* const PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION      = "matchSystemLanguageDirection";
106 const char* const PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP             = "enableGrabHandlePopup";
107 const char* const PROPERTY_NAME_BACKGROUND                           = "textBackground";
108 const char* const PROPERTY_NAME_FONT_SIZE_SCALE                      = "fontSizeScale";
109 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR                    = "grabHandleColor";
110 const char* const PROPERTY_NAME_INPUT_FILTER                         = "inputFilter";
111
112 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
113 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
114
115 const float RENDER_FRAME_INTERVAL = 16.66f;
116
117 const unsigned int DEFAULT_FONT_SIZE = 1152u;
118 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
119
120 const int KEY_RETURN_CODE = 36;
121 const int KEY_A_CODE = 38;
122 const int KEY_D_CODE = 40;
123 const int KEY_SHIFT_MODIFIER = 257;
124
125 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
126
127 static bool gSelectionChangedCallbackCalled;
128 static uint32_t oldSelectionStart;
129 static uint32_t oldSelectionEnd;
130 static bool gSelectionClearedCallbackCalled;
131 static bool gAnchorClickedCallBackCalled;
132 static bool gAnchorClickedCallBackNotCalled;
133 static bool gTextChangedCallBackCalled;
134 static bool gMaxCharactersCallBackCalled;
135 static bool gInputFilteredAcceptedCallbackCalled;
136 static bool gInputFilteredRejectedCallbackCalled;
137 static bool gInputStyleChangedCallbackCalled;
138 static bool gCursorPositionChangedCallbackCalled;
139 static uint32_t oldCursorPos;
140 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
141
142 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
143 {
144   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
145   Integration::ResourcePointer resource(bitmap);
146   bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
147 }
148
149 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
150 {
151   int width(40);
152   int height(40);
153   LoadBitmapResource( app.GetPlatform(), width, height );
154
155   Property::Map propertyMap;
156   propertyMap["filename"] = "image.png";
157   propertyMap["width"] = width;
158   propertyMap["height"] = height;
159   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
160   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
161   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
162   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
163   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
164   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
165   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
166   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
167 }
168
169 /*
170  * Simulate time passed by.
171  *
172  * @note this will always process at least 1 frame (1/60 sec)
173  *
174  * @param application Test application instance
175  * @param duration Time to pass in milliseconds.
176  * @return The actual time passed in milliseconds
177  */
178 static int Wait(ToolkitTestApplication& application, int duration = 0)
179 {
180   int time = 0;
181
182   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
183   {
184     application.SendNotification();
185     application.Render(RENDER_FRAME_INTERVAL);
186     time += RENDER_FRAME_INTERVAL;
187   }
188
189   return time;
190 }
191
192 Dali::Integration::Point GetPointDownInside( Vector2& pos )
193 {
194   Dali::Integration::Point point;
195   point.SetState( PointState::DOWN );
196   point.SetScreenPosition( pos );
197   return point;
198 }
199
200 Dali::Integration::Point GetPointUpInside( Vector2& pos )
201 {
202   Dali::Integration::Point point;
203   point.SetState( PointState::UP );
204   point.SetScreenPosition( pos );
205   return point;
206 }
207
208 struct CallbackFunctor
209 {
210   CallbackFunctor(bool* callbackFlag)
211   : mCallbackFlag( callbackFlag )
212   {
213   }
214
215   void operator()()
216   {
217     *mCallbackFlag = true;
218   }
219   bool* mCallbackFlag;
220 };
221
222 static void TestSelectionClearedCallback(TextField control)
223 {
224   tet_infoline(" TestSelectionClearedCallback");
225
226   gSelectionClearedCallbackCalled = true;
227 }
228
229 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
230 {
231   tet_infoline(" TestSelectionChangedCallback");
232
233   gSelectionChangedCallbackCalled = true;
234   oldSelectionStart = oldStart;
235   oldSelectionEnd   = oldEnd;
236 }
237
238 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
239 {
240   tet_infoline(" TestAnchorClickedCallback");
241
242   gAnchorClickedCallBackNotCalled = false;
243
244   if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
245   {
246     gAnchorClickedCallBackCalled = true;
247   }
248 }
249
250 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
251 {
252   tet_infoline(" TestCursorPositionChangedCallback");
253
254   gCursorPositionChangedCallbackCalled = true;
255   oldCursorPos = oldPos;
256 }
257
258 static void TestTextChangedCallback( TextField control )
259 {
260   tet_infoline(" TestTextChangedCallback");
261
262   gTextChangedCallBackCalled = true;
263 }
264
265 static void TestMaxLengthReachedCallback( TextField control )
266 {
267   tet_infoline(" TestMaxLengthReachedCallback");
268
269   gMaxCharactersCallBackCalled = true;
270 }
271
272 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
273 {
274   tet_infoline(" TestInputFilteredCallback");
275
276   if(type == Toolkit::InputFilter::Property::ACCEPTED)
277   {
278     gInputFilteredAcceptedCallbackCalled = true;
279   }
280   else if(type == Toolkit::InputFilter::Property::REJECTED)
281   {
282     gInputFilteredRejectedCallbackCalled = true;
283   }
284 }
285
286 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
287 {
288   tet_infoline(" TestInputStyleChangedCallback");
289
290   gInputStyleChangedCallbackCalled = true;
291   gInputStyleMask = mask;
292 }
293
294 // Generate a KeyEvent to send to Core.
295 Integration::KeyEvent GenerateKey( const std::string& keyName,
296                                    const std::string& logicalKey,
297                                    const std::string& keyString,
298                                    int keyCode,
299                                    int keyModifier,
300                                    unsigned long timeStamp,
301                                    const Integration::KeyEvent::State& keyState,
302                                    const std::string& compose = "",
303                                    const std::string& deviceName = DEFAULT_DEVICE_NAME,
304                                    const Device::Class::Type& deviceClass = Device::Class::NONE,
305                                    const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
306 {
307   return Integration::KeyEvent( keyName,
308                                 logicalKey,
309                                 keyString,
310                                 keyCode,
311                                 keyModifier,
312                                 timeStamp,
313                                 keyState,
314                                 compose,
315                                 deviceName,
316                                 deviceClass,
317                                 deviceSubclass );
318 }
319
320 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
321 {
322   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
323   {
324     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
325     {
326       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
327
328       Property::Value* valueSet = NULL;
329       if ( valueGet.first.type == Property::Key::INDEX )
330       {
331         valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
332       }
333       else
334       {
335         // Get Key is a string so searching Set Map for a string key
336         valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
337       }
338
339       if( NULL != valueSet )
340       {
341         if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
342         {
343           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
344           return false;
345         }
346         else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
347         {
348           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
349           return false;
350         }
351         else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
352         {
353           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
354           return false;
355         }
356         else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
357         {
358           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
359           return false;
360         }
361         else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
362         {
363           Vector2 vector2Get = valueGet.second.Get<Vector2>();
364           Vector2 vector2Set = valueSet->Get<Vector2>();
365           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
366           return false;
367         }
368         else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
369         {
370           Vector4 vector4Get = valueGet.second.Get<Vector4>();
371           Vector4 vector4Set = valueSet->Get<Vector4>();
372           tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
373           return false;
374         }
375       }
376       else
377       {
378         if ( valueGet.first.type == Property::Key::INDEX )
379         {
380           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
381         }
382         else
383         {
384           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
385         }
386         return false;
387       }
388     }
389   }
390
391   return true;
392 }
393
394 } // namespace
395
396 int UtcDaliToolkitTextFieldConstructorP(void)
397 {
398   ToolkitTestApplication application;
399   tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
400   TextField textField;
401   DALI_TEST_CHECK( !textField );
402   END_TEST;
403 }
404
405 int UtcDaliToolkitTextFieldNewP(void)
406 {
407   ToolkitTestApplication application;
408   tet_infoline(" UtcDaliToolkitTextFieldNewP");
409   TextField textField = TextField::New();
410   DALI_TEST_CHECK( textField );
411   END_TEST;
412 }
413
414 int UtcDaliToolkitTextFieldDownCastP(void)
415 {
416   ToolkitTestApplication application;
417   tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
418   TextField textField1 = TextField::New();
419   BaseHandle object( textField1 );
420
421   TextField textField2 = TextField::DownCast( object );
422   DALI_TEST_CHECK( textField2 );
423
424   TextField textField3 = DownCast< TextField >( object );
425   DALI_TEST_CHECK( textField3 );
426   END_TEST;
427 }
428
429 int UtcDaliToolkitTextFieldDownCastN(void)
430 {
431   ToolkitTestApplication application;
432   tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
433   BaseHandle uninitializedObject;
434   TextField textField1 = TextField::DownCast( uninitializedObject );
435   DALI_TEST_CHECK( !textField1 );
436
437   TextField textField2 = DownCast< TextField >( uninitializedObject );
438   DALI_TEST_CHECK( !textField2 );
439   END_TEST;
440 }
441
442 int UtcDaliToolkitTextFieldCopyConstructorP(void)
443 {
444   ToolkitTestApplication application;
445   tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
446   TextField textField = TextField::New();
447   textField.SetProperty( TextField::Property::TEXT, "Test" );
448
449   TextField copy( textField );
450   DALI_TEST_CHECK( copy );
451   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
452   END_TEST;
453 }
454
455 int UtcDaliTextFieldMoveConstructor(void)
456 {
457   ToolkitTestApplication application;
458
459   TextField textField = TextField::New();
460   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
461   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
462
463   TextField moved = std::move( textField );
464   DALI_TEST_CHECK( moved );
465   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
466   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
467   DALI_TEST_CHECK( !textField );
468
469   END_TEST;
470 }
471
472 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
473 {
474   ToolkitTestApplication application;
475   tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
476   TextField textField = TextField::New();
477   textField.SetProperty( TextField::Property::TEXT, "Test" );
478
479   TextField copy = textField;
480   DALI_TEST_CHECK( copy );
481   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
482   END_TEST;
483 }
484
485 int UtcDaliTextFieldMoveAssignment(void)
486 {
487   ToolkitTestApplication application;
488
489   TextField textField = TextField::New();
490   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
491   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
492
493   TextField moved;
494   moved = std::move( textField );
495   DALI_TEST_CHECK( moved );
496   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
497   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
498   DALI_TEST_CHECK( !textField );
499
500   END_TEST;
501 }
502
503 int UtcDaliTextFieldNewP(void)
504 {
505   ToolkitTestApplication application;
506   tet_infoline(" UtcDaliToolkitTextFieldNewP");
507   TextField textField = TextField::New();
508   DALI_TEST_CHECK( textField );
509   END_TEST;
510 }
511
512 // Positive test case for a method
513 int UtcDaliTextFieldGetPropertyP(void)
514 {
515   ToolkitTestApplication application;
516   tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
517   TextField field = TextField::New();
518   DALI_TEST_CHECK( field );
519
520   // Check Property Indices are correct
521   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
522   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
523   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
524   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
525   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
526   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
527   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
528   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
529   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
530   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
531   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
532   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
533   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
534   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
535   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
536   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
537   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
538   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
539   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
540   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
541   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
542   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
543   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
544   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
545   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
546   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
547   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
548   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
549   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
550   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
551   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
552   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
553   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
554   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
555   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
556   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
557   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
558   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
559   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
560   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
561   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
562   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
563   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
564   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
565   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
566   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
567   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
568   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
569   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
570   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
571   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
572   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
573   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
574   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
575   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
576   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
577   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
578   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
579
580   END_TEST;
581 }
582
583 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
584 {
585   bool result = false;
586   Property::Map imageMap;
587   imageMap[mapKey] =mapValue;
588
589   field.SetProperty( property , imageMap );
590   Property::Value propValue = field.GetProperty( property );
591   Property::Map* resultMap = propValue.GetMap();
592
593   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
594   {
595     result = true;
596   }
597
598   return result;
599 }
600
601 // Positive test case for a method
602 int UtcDaliTextFieldSetPropertyP(void)
603 {
604   ToolkitTestApplication application;
605   tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
606   TextField field = TextField::New();
607   DALI_TEST_CHECK( field );
608   application.GetScene().Add( field );
609
610   // Note - we can't check the defaults since the stylesheets are platform-specific
611
612   // Check the render backend property.
613   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
614   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
615
616   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
617   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
618
619   // Check text property.
620   field.SetProperty( TextField::Property::TEXT, "Setting Text" );
621   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
622
623   // Check placeholder text properties.
624   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
625   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
626
627   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
628   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
629
630   // Check font properties.
631   field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
632   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
633
634   Property::Map fontStyleMapSet;
635   Property::Map fontStyleMapGet;
636   Property::Value* slantValue = NULL;
637
638   fontStyleMapSet.Insert( "weight", "bold" );
639   fontStyleMapSet.Insert( "width", "condensed" );
640   fontStyleMapSet.Insert( "slant", "italic" );
641   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
642
643   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
644   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
645   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
646
647   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
648   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
649
650   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
651   DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
652   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
653
654   // Reset font style.
655   fontStyleMapSet.Clear();
656   fontStyleMapSet.Insert( "weight", "normal" );
657   fontStyleMapSet.Insert( "slant", "oblique" );
658   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
659
660   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
661   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
662   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
663
664   fontStyleMapSet.Clear();
665   fontStyleMapSet.Insert( "slant", "roman" );
666   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
667   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
668
669   // Replace 'roman' for 'normal'.
670   slantValue = fontStyleMapGet.Find( "slant" );
671   if( NULL != slantValue )
672   {
673     if( "normal" == slantValue->Get<std::string>() )
674     {
675       fontStyleMapGet["slant"] = "roman";
676     }
677   }
678   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
679   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
680
681   fontStyleMapSet.Clear();
682
683   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
684   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
685   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
686   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
687
688   // Check that the MAX_LENGTH property can be correctly set
689   const int maxNumberOfCharacters = 20;
690   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
691   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
692
693   // Check exceed policy
694   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
695   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
696   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
697   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
698
699   // Check that the Alignment properties can be correctly set
700   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
701   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
702   field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
703   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
704
705   // Check text's color property
706   field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
707   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
708
709   // Check placeholder text's color property.
710   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
711   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
712
713   // Check cursor properties
714   field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
715   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
716   field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
717   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
718
719   field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
720   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
721   field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
722   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
723   field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
724   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
725   field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
726   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
727
728   // Check scroll properties.
729   field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
730   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
731   field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
732   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
733
734   // Check handle images
735   field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
736   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
737   field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
738   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
739   field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
740
741   // Check handle images
742   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
743   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
744   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
745   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
746   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
747   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
748
749   // Check the highlight color
750   field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
751   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
752
753   // Decoration bounding box
754   field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
755   DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
756
757   // Check the input method setting
758   Property::Map propertyMap;
759   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
760   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
761   InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
762   int inputVariation = 1;
763   propertyMap["PANEL_LAYOUT"] = panelLayout;
764   propertyMap["AUTO_CAPITALIZE"] = autoCapital;
765   propertyMap["BUTTON_ACTION"] = buttonAction;
766   propertyMap["VARIATION"] = inputVariation;
767   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
768
769   Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
770   Property::Map map;
771   DALI_TEST_CHECK( value.Get( map ) );
772
773   int layout = 0;
774   DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
775   DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
776
777   int capital = 0;
778   DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
779   DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
780
781   int action = 0;
782   DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
783   DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
784
785   int variation = 0;
786   DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
787   DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
788
789   // Check input color property.
790   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
791   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
792
793   // Check the enable markup property.
794   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
795   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
796   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
797
798   // Check input font properties.
799   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
800   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
801
802   fontStyleMapSet.Clear();
803   fontStyleMapSet.Insert( "weight", "bold" );
804   fontStyleMapSet.Insert( "width", "condensed" );
805   fontStyleMapSet.Insert( "slant", "italic" );
806
807   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
808   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
809   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
810   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
811
812   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
813   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
814
815   // Reset input font style.
816   fontStyleMapSet.Clear();
817   fontStyleMapSet.Insert( "weight", "normal" );
818   fontStyleMapSet.Insert( "slant", "oblique" );
819
820   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
821   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
822   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
823   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
824
825   fontStyleMapSet.Clear();
826   fontStyleMapSet.Insert( "slant", "roman" );
827
828   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
829   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
830
831   // Replace 'roman' for 'normal'.
832   slantValue = fontStyleMapGet.Find( "slant" );
833   if( NULL != slantValue )
834   {
835     if( "normal" == slantValue->Get<std::string>() )
836     {
837       fontStyleMapGet["slant"] = "roman";
838     }
839   }
840   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
841   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
842
843   fontStyleMapSet.Clear();
844
845   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
846   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
847   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
848   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
849
850   Property::Map underlineMapSet;
851   Property::Map underlineMapGet;
852
853   underlineMapSet.Insert( "enable", true );
854   underlineMapSet.Insert( "color", Color::RED );
855   underlineMapSet.Insert( "height", 1 );
856
857   // Check the underline property
858   field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
859
860   underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
861   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
862   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
863
864   // Check the input underline property
865   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
866   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
867
868   // Check the shadow property
869   Property::Map shadowMapSet;
870   Property::Map shadowMapGet;
871
872   shadowMapSet.Insert( "color", Color::GREEN );
873   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
874   shadowMapSet.Insert( "blurRadius", 3.0f );
875
876   field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
877
878   shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
879   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
880   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
881
882   // Check the input shadow property
883   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
884   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
885
886   // Check the emboss property
887   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
888   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
889
890   // Check the input emboss property
891   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
892   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
893
894   // Check the outline property
895
896   // Test string type first
897   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
898   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
899   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
900
901   // Then test the property map type
902   Property::Map outlineMapSet;
903   Property::Map outlineMapGet;
904
905   outlineMapSet["color"] = Color::RED;
906   outlineMapSet["width"] = 2.0f;
907
908   field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
909
910   outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
911   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
912   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
913
914   // Check the input outline property
915   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
916   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
917
918   // Check the hidden input settings property
919   Property::Map hiddenMapSet;
920   Property::Map hiddenMapGet;
921   hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
922   hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
923   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
924   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
925   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
926
927   hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
928   DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
929   DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
930
931   // Check the pixel size of font
932   field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
933   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
934
935   // Check the enable selection property
936   field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
937   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
938
939   // Check the placeholder property with pixel size
940   Property::Map placeholderPixelSizeMapSet;
941   Property::Map placeholderPixelSizeMapGet;
942   Property::Map placeholderFontstyleMap;
943   placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
944   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
945   placeholderPixelSizeMapSet["color"] = Color::BLUE;
946   placeholderPixelSizeMapSet["fontFamily"] = "Arial";
947   placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
948   placeholderPixelSizeMapSet["ellipsis"] = true;
949
950   placeholderFontstyleMap.Insert( "weight", "bold" );
951   placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
952   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
953
954   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
955   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
956
957   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
958   Property::Map placeholderConversionMap;
959   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
960   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
961   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
962   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
963   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
964   placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
965
966   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
967
968   // Check the placeholder property with point size
969   Property::Map placeholderMapSet;
970   Property::Map placeholderMapGet;
971   placeholderMapSet["text"] = "Setting Placeholder Text";
972   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
973   placeholderMapSet["color"] = Color::RED;
974   placeholderMapSet["fontFamily"] = "Arial";
975   placeholderMapSet["pointSize"] = 12.0f;
976   placeholderMapSet["ellipsis"] = false;
977
978   // Check the placeholder font style property
979   placeholderFontstyleMap.Clear();
980
981   placeholderFontstyleMap.Insert( "weight", "bold" );
982   placeholderFontstyleMap.Insert( "width", "condensed" );
983   placeholderFontstyleMap.Insert( "slant", "italic" );
984   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
985   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
986
987   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
988   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
989
990   placeholderConversionMap.Clear();
991   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
992   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
993   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
994   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
995   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
996   placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
997
998   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
999
1000   // Reset font style.
1001   placeholderFontstyleMap.Clear();
1002   placeholderFontstyleMap.Insert( "weight", "normal" );
1003   placeholderFontstyleMap.Insert( "slant", "oblique" );
1004   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1005   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1006
1007   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1008   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1009
1010   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1011   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1012
1013   placeholderFontstyleMap.Clear();
1014   placeholderFontstyleMap.Insert( "slant", "roman" );
1015   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1016   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1017
1018   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1019
1020   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1021
1022   placeholderFontstyleMap.Clear();
1023   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1024   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1025
1026   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1027   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1028   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1029
1030   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1031
1032   // Check the ellipsis property
1033   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1034   field.SetProperty( TextField::Property::ELLIPSIS, true );
1035   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1036
1037   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1038   DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1039
1040   // Test the ENABLE_GRAB_HANDLE_POPUP property
1041   DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1042   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1043   DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1044
1045   // Check the background property
1046   field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1047   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1048
1049   //Check handle color
1050   field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1051   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1052
1053   // Check the input filter property
1054   Property::Map inputFilterMapSet;
1055   Property::Map inputFilterMapGet;
1056   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1057   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1058
1059   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1060
1061   inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1062   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1063
1064   // Clear
1065   inputFilterMapSet.Clear();
1066   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1067
1068   application.SendNotification();
1069   application.Render();
1070
1071   END_TEST;
1072 }
1073
1074 // Positive Atlas Text Renderer test
1075 int utcDaliTextFieldAtlasRenderP(void)
1076 {
1077   ToolkitTestApplication application;
1078   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1079   StyleManager styleManager = StyleManager::Get();
1080   styleManager.ApplyDefaultTheme();
1081   TextField field = TextField::New();
1082   DALI_TEST_CHECK( field );
1083
1084   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1085
1086   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1087
1088   application.GetScene().Add( field );
1089
1090   try
1091   {
1092     // Render some text with the shared atlas backend
1093     field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1094     application.SendNotification();
1095     application.Render();
1096   }
1097   catch( ... )
1098   {
1099     tet_result(TET_FAIL);
1100   }
1101   END_TEST;
1102 }
1103
1104 // Positive test for the anchorClicked signal.
1105 int utcDaliTextFieldAnchorClicked01(void)
1106 {
1107   ToolkitTestApplication application;
1108   tet_infoline(" utcDaliTextFieldAnchorClicked01");
1109   TextField field = TextField::New();
1110   DALI_TEST_CHECK(field);
1111
1112   application.GetScene().Add(field);
1113
1114   // connect to the anchor clicked signal.
1115   ConnectionTracker* testTracker = new ConnectionTracker();
1116   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1117   bool anchorClickedSignal = false;
1118   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1119
1120   gAnchorClickedCallBackCalled = false;
1121   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1122   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1123   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1124   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1125   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1126
1127   application.SendNotification();
1128   application.Render();
1129   field.SetKeyInputFocus();
1130
1131   // Create a tap event to touch the text field.
1132   TestGenerateTap(application, 5.0f, 25.0f);
1133   application.SendNotification();
1134   application.Render();
1135
1136   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1137   DALI_TEST_CHECK(anchorClickedSignal);
1138
1139   gAnchorClickedCallBackNotCalled = true;
1140   // Tap the outside of anchor, callback should not be called.
1141   TestGenerateTap(application, 150.f, 100.f);
1142   application.SendNotification();
1143   application.Render();
1144
1145   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1146
1147   END_TEST;
1148 }
1149
1150 // Positive test for the anchorClicked signal.
1151 int utcDaliTextFieldAnchorClicked02(void)
1152 {
1153   ToolkitTestApplication application;
1154   tet_infoline(" utcDaliTextFieldAnchorClicked02");
1155   TextField field = TextField::New();
1156   DALI_TEST_CHECK(field);
1157
1158   application.GetScene().Add(field);
1159
1160   // connect to the anchor clicked signal.
1161   ConnectionTracker* testTracker = new ConnectionTracker();
1162   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1163   bool anchorClickedSignal = false;
1164   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1165
1166   gAnchorClickedCallBackCalled = false;
1167   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1168   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1169   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1170   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1171   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1172
1173   application.SendNotification();
1174   application.Render();
1175   field.SetKeyInputFocus();
1176
1177   // Avoid a crash when core load gl resources.
1178   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1179
1180   // Create a tap event to touch the text field.
1181   TestGenerateTap(application, 30.0f, 25.0f, 100);
1182   application.SendNotification();
1183   application.Render();
1184
1185   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1186   DALI_TEST_CHECK(anchorClickedSignal);
1187
1188
1189   // For coverage InsertTextAnchor, RemoveTextAnchor
1190   // first index insert
1191   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1192   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1193   application.SendNotification();
1194   application.Render();
1195
1196   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1197   application.SendNotification();
1198   application.Render();
1199
1200   gAnchorClickedCallBackCalled = false;
1201   // Create a tap event to touch the text field.
1202   TestGenerateTap(application, 30.0f, 25.0f, 700);
1203   application.SendNotification();
1204   field.SetKeyInputFocus();
1205
1206   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1207
1208   // last index insert
1209   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1210   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1211   application.SendNotification();
1212   application.Render();
1213
1214   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1215   application.SendNotification();
1216   application.Render();
1217
1218   gAnchorClickedCallBackCalled = false;
1219   // Create a tap event to touch the text field.
1220   TestGenerateTap(application, 30.0f, 25.0f, 1300);
1221   application.SendNotification();
1222   field.SetKeyInputFocus();
1223
1224   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1225
1226   // mid index insert
1227   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1228   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1229   application.SendNotification();
1230   application.Render();
1231
1232   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1233   application.SendNotification();
1234   application.Render();
1235
1236   gAnchorClickedCallBackCalled = false;
1237   // Create a tap event to touch the text field.
1238   TestGenerateTap(application, 30.0f, 25.0f, 1900);
1239   application.SendNotification();
1240   field.SetKeyInputFocus();
1241
1242   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1243
1244   // first index remove
1245   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1246   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1247   application.SendNotification();
1248   application.Render();
1249
1250   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1251   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1252   application.SendNotification();
1253   application.Render();
1254
1255   gAnchorClickedCallBackCalled = false;
1256   // Create a tap event to touch the text field.
1257   TestGenerateTap(application, 30.0f, 25.0f, 2500);
1258   application.SendNotification();
1259   field.SetKeyInputFocus();
1260
1261   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1262
1263   // last index remove
1264   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1265   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1266   application.SendNotification();
1267   application.Render();
1268
1269   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1270   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1271   application.SendNotification();
1272   application.Render();
1273
1274   gAnchorClickedCallBackCalled = false;
1275   // Create a tap event to touch the text field.
1276   TestGenerateTap(application, 30.0f, 25.0f, 3100);
1277   application.SendNotification();
1278   application.Render();
1279
1280   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1281
1282   // middle index
1283   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1284   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1285   application.SendNotification();
1286   application.Render();
1287
1288   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1289   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1290   application.SendNotification();
1291   application.Render();
1292
1293   gAnchorClickedCallBackCalled = false;
1294   // Create a tap event to touch the text field.
1295   TestGenerateTap(application, 30.0f, 25.0f, 3700);
1296   application.SendNotification();
1297   application.Render();
1298
1299   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1300
1301   // 0 ~ 1 index remove
1302   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1303   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1304   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1305   application.SendNotification();
1306   application.Render();
1307
1308   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1309   application.SendNotification();
1310   application.Render();
1311
1312   gAnchorClickedCallBackCalled = false;
1313   // Create a tap event to touch the text field.
1314   TestGenerateTap(application, 30.0f, 25.0f, 4300);
1315   application.SendNotification();
1316   application.Render();
1317
1318   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1319
1320   // 1 ~ 3 index remove
1321   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1322   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1323   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1324   application.SendNotification();
1325   application.Render();
1326
1327   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1328   application.SendNotification();
1329   application.Render();
1330
1331   gAnchorClickedCallBackCalled = false;
1332   // Create a tap event to touch the text field.
1333   TestGenerateTap(application, 30.0f, 25.0f, 4900);
1334   application.SendNotification();
1335   application.Render();
1336
1337   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1338
1339   // 3 ~ 4 index remove
1340   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1341   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1342   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1343   application.SendNotification();
1344   application.Render();
1345
1346   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1347   application.SendNotification();
1348   application.Render();
1349
1350   gAnchorClickedCallBackCalled = false;
1351   // Create a tap event to touch the text field.
1352   TestGenerateTap(application, 30.0f, 25.0f, 5500);
1353   application.SendNotification();
1354   application.Render();
1355
1356   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1357
1358   // Remove front of anchor
1359   field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1360   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1361   application.SendNotification();
1362   application.Render();
1363
1364   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1365   application.SendNotification();
1366   application.Render();
1367
1368   // Remove whole text
1369   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1370   DevelTextField::SelectWholeText(field);
1371   application.SendNotification();
1372   application.Render();
1373
1374   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1375   application.SendNotification();
1376   application.Render();
1377
1378   // Remove all with backspace
1379   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1380   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1381   application.SendNotification();
1382   application.Render();
1383
1384   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1385   application.SendNotification();
1386   application.Render();
1387
1388   // Remove all with delete
1389   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1390   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1391   application.SendNotification();
1392   application.Render();
1393
1394   application.ProcessEvent(GenerateKey("Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1395   application.SendNotification();
1396   application.Render();
1397
1398   END_TEST;
1399 }
1400
1401 // Positive test for the textChanged signal.
1402 int utcDaliTextFieldTextChangedP(void)
1403 {
1404   ToolkitTestApplication application;
1405   tet_infoline(" utcDaliTextFieldTextChangedP");
1406   TextField field = TextField::New();
1407   DALI_TEST_CHECK( field );
1408
1409   application.GetScene().Add( field );
1410
1411   // connect to the text changed signal.
1412   ConnectionTracker* testTracker = new ConnectionTracker();
1413   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1414   bool textChangedSignal = false;
1415   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1416
1417   gTextChangedCallBackCalled = false;
1418   field.SetProperty( TextField::Property::TEXT, "ABC" );
1419   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1420   DALI_TEST_CHECK( textChangedSignal );
1421
1422   application.SendNotification();
1423   field.SetKeyInputFocus();
1424
1425   gTextChangedCallBackCalled = false;
1426   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1427   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1428
1429   // Remove all text
1430   field.SetProperty( TextField::Property::TEXT, "" );
1431
1432   // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1433   gTextChangedCallBackCalled = false;
1434   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1435   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1436
1437   // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1438   gTextChangedCallBackCalled = false;
1439   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1440   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1441
1442   END_TEST;
1443 }
1444
1445 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1446 {
1447   ToolkitTestApplication application;
1448   tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1449   TextField field = TextField::New();
1450   DALI_TEST_CHECK( field );
1451
1452
1453   application.GetScene().Add( field );
1454
1455   // connect to the text changed signal.
1456   ConnectionTracker* testTracker = new ConnectionTracker();
1457   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1458   bool textChangedSignal = false;
1459   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1460
1461
1462   // get InputMethodContext
1463   std::string text;
1464   InputMethodContext::EventData imfEvent;
1465   InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1466
1467   field.SetKeyInputFocus();
1468   field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1469
1470   // input text
1471   gTextChangedCallBackCalled = false;
1472   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1473   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1474   application.SendNotification();
1475   application.Render();
1476   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1477   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1478
1479   gTextChangedCallBackCalled = false;
1480   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1481   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1482   application.SendNotification();
1483   application.Render();
1484   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1485   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1486
1487   gTextChangedCallBackCalled = false;
1488   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1489   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1490   application.SendNotification();
1491   application.Render();
1492   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1493   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1494
1495   gTextChangedCallBackCalled = false;
1496   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1497   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1498   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1499
1500   imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1501   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1502   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1503
1504   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1505   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1506   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1507
1508   application.SendNotification();
1509   application.Render();
1510   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1511   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1512
1513   END_TEST;
1514 }
1515
1516
1517 // Negative test for the textChanged signal.
1518 int utcDaliTextFieldTextChangedN(void)
1519 {
1520   ToolkitTestApplication application;
1521   tet_infoline(" utcDaliTextFieldTextChangedN");
1522   TextField field = TextField::New();
1523   DALI_TEST_CHECK( field );
1524
1525   application.GetScene().Add( field );
1526
1527   // connect to the text changed signal.
1528   ConnectionTracker* testTracker = new ConnectionTracker();
1529   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1530   bool textChangedSignal = false;
1531   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1532
1533   gTextChangedCallBackCalled = false;
1534   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1535   application.SendNotification();
1536   application.Render();
1537   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1538   DALI_TEST_CHECK( !textChangedSignal );
1539
1540   END_TEST;
1541 }
1542
1543 // Positive test for Max Characters reached signal.
1544 int utcDaliTextFieldMaxCharactersReachedP(void)
1545 {
1546   ToolkitTestApplication application;
1547   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1548   TextField field = TextField::New();
1549   DALI_TEST_CHECK( field );
1550
1551   application.GetScene().Add( field );
1552
1553   const int maxNumberOfCharacters = 1;
1554   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1555
1556   field.SetKeyInputFocus();
1557
1558   // connect to the text changed signal.
1559   ConnectionTracker* testTracker = new ConnectionTracker();
1560   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1561   bool maxLengthReachedSignal = false;
1562   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1563
1564   gMaxCharactersCallBackCalled = false;
1565
1566   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1567   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1568
1569   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1570   DALI_TEST_CHECK( maxLengthReachedSignal );
1571
1572   END_TEST;
1573 }
1574
1575 // Negative test for Max Characters reached signal.
1576 int utcDaliTextFieldMaxCharactersReachedN(void)
1577 {
1578   ToolkitTestApplication application;
1579   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1580   TextField field = TextField::New();
1581   DALI_TEST_CHECK( field );
1582
1583   application.GetScene().Add( field );
1584
1585   const int maxNumberOfCharacters = 3;
1586   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1587
1588   field.SetKeyInputFocus();
1589
1590   // connect to the text changed signal.
1591   ConnectionTracker* testTracker = new ConnectionTracker();
1592   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1593   bool maxLengthReachedSignal = false;
1594   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1595
1596   gMaxCharactersCallBackCalled = false;
1597
1598   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1599   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1600
1601   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1602   DALI_TEST_CHECK( !maxLengthReachedSignal );
1603
1604   application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1605
1606   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1607   DALI_TEST_CHECK( !maxLengthReachedSignal );
1608
1609   END_TEST;
1610 }
1611
1612 // Positive test for Input Filtered signal.
1613 int utcDaliTextFieldInputFilteredP(void)
1614 {
1615   ToolkitTestApplication application;
1616   tet_infoline(" utcDaliTextFieldInputFilteredP");
1617   TextField field = TextField::New();
1618   DALI_TEST_CHECK(field);
1619
1620   application.GetScene().Add(field);
1621
1622   Property::Map inputFilter;
1623
1624   // Only digit is accepted.
1625   inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1626
1627   // Set input filter to TextField.
1628   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1629
1630   field.SetKeyInputFocus();
1631
1632   // connect to the input filtered signal.
1633   ConnectionTracker* testTracker = new ConnectionTracker();
1634   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1635   bool inputFilteredSignal = false;
1636   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1637
1638   gInputFilteredAcceptedCallbackCalled = false;
1639
1640   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1641
1642   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1643   DALI_TEST_CHECK(inputFilteredSignal);
1644
1645   // Word is rejected.
1646   inputFilter[InputFilter::Property::ACCEPTED] = "";
1647   inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1648
1649   // Set input filter to TextField.
1650   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1651
1652   field.SetKeyInputFocus();
1653
1654   inputFilteredSignal = false;
1655   gInputFilteredRejectedCallbackCalled = false;
1656
1657   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1658
1659   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1660   DALI_TEST_CHECK(inputFilteredSignal);
1661
1662   END_TEST;
1663 }
1664
1665 // Negative test for Input Filtered signal.
1666 int utcDaliTextFieldInputFilteredN(void)
1667 {
1668   ToolkitTestApplication application;
1669   tet_infoline(" utcDaliTextFieldInputFilteredP");
1670   TextField field = TextField::New();
1671   DALI_TEST_CHECK(field);
1672
1673   application.GetScene().Add(field);
1674
1675   Property::Map inputFilter;
1676
1677   // Only word is accepted.
1678   inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1679
1680   // Set input filter to TextField.
1681   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1682
1683   field.SetKeyInputFocus();
1684
1685   // connect to the input filtered signal.
1686   ConnectionTracker* testTracker = new ConnectionTracker();
1687   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1688   bool inputFilteredSignal = false;
1689   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1690
1691   gInputFilteredAcceptedCallbackCalled = false;
1692
1693   // Key a, d should not be filtered.
1694   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1695   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1696   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1697   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1698
1699   // Backspace, Delete should not be filtered.
1700   application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1701   application.ProcessEvent(GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1702
1703   // Render and notify
1704   application.SendNotification();
1705   application.Render();
1706
1707   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1708   DALI_TEST_CHECK(!inputFilteredSignal);
1709
1710   // Digit is rejected.
1711   inputFilter[InputFilter::Property::ACCEPTED] = "";
1712   inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1713
1714   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1715
1716   field.SetKeyInputFocus();
1717
1718   inputFilteredSignal = false;
1719   gInputFilteredRejectedCallbackCalled = false;
1720
1721   // Key a, d should not be filtered.
1722   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1723   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1724   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1725   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1726
1727   // Backspace, Delete should not be filtered.
1728   application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1729   application.ProcessEvent(GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1730
1731   // Render and notify
1732   application.SendNotification();
1733   application.Render();
1734
1735   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1736   DALI_TEST_CHECK(!inputFilteredSignal);
1737
1738   END_TEST;
1739 }
1740
1741 int utcDaliTextFieldInputStyleChanged01(void)
1742 {
1743   // The text-field emits signals when the input style changes. These changes of style are
1744   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1745   // can't be emitted during the size negotiation as the callbacks may update the UI.
1746   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1747   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1748   ToolkitTestApplication application;
1749   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1750
1751   // Load some fonts.
1752
1753   char* pathNamePtr = get_current_dir_name();
1754   const std::string pathName( pathNamePtr );
1755   free( pathNamePtr );
1756
1757   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1758   fontClient.SetDpi( 93u, 93u );
1759
1760   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1761   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1762
1763   TextField field = TextField::New();
1764   DALI_TEST_CHECK( field );
1765
1766
1767   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1768   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1769   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1770
1771   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1772   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1773
1774   // connect to the text changed signal.
1775   ConnectionTracker* testTracker = new ConnectionTracker();
1776   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1777   bool inputStyleChangedSignal = false;
1778   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1779
1780   application.GetScene().Add( field );
1781
1782   // Render and notify
1783   application.SendNotification();
1784   application.Render();
1785
1786   // Executes the idle callbacks added by the text control on the change of input style.
1787   application.RunIdles();
1788
1789   gInputStyleChangedCallbackCalled = false;
1790   gInputStyleMask = TextField::InputStyle::NONE;
1791   inputStyleChangedSignal = false;
1792
1793   // Create a tap event to touch the text field.
1794   TestGenerateTap( application, 18.0f, 25.0f );
1795
1796   // Render and notify
1797   application.SendNotification();
1798   application.Render();
1799
1800   // Executes the idle callbacks added by the text control on the change of input style.
1801   application.RunIdles();
1802
1803   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1804   if( gInputStyleChangedCallbackCalled )
1805   {
1806     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1807
1808     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1809     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1810
1811     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1812     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1813   }
1814   DALI_TEST_CHECK( inputStyleChangedSignal );
1815
1816   gInputStyleChangedCallbackCalled = false;
1817   gInputStyleMask = TextField::InputStyle::NONE;
1818   inputStyleChangedSignal = false;
1819
1820   // Create a tap event to touch the text field.
1821   TestGenerateTap( application, 30.0f, 25.0f );
1822
1823   // Render and notify
1824   application.SendNotification();
1825   application.Render();
1826
1827   // Executes the idle callbacks added by the text control on the change of input style.
1828   application.RunIdles();
1829
1830   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1831   DALI_TEST_CHECK( !inputStyleChangedSignal );
1832
1833   gInputStyleChangedCallbackCalled = false;
1834   gInputStyleMask = TextField::InputStyle::NONE;
1835   inputStyleChangedSignal = false;
1836
1837   // Create a tap event to touch the text field.
1838   TestGenerateTap( application, 43.0f, 25.0f );
1839
1840   // Render and notify
1841   application.SendNotification();
1842   application.Render();
1843
1844   // Executes the idle callbacks added by the text control on the change of input style.
1845   application.RunIdles();
1846
1847   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1848   if( gInputStyleChangedCallbackCalled )
1849   {
1850     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1851
1852     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1853     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1854   }
1855   DALI_TEST_CHECK( inputStyleChangedSignal );
1856
1857   gInputStyleChangedCallbackCalled = false;
1858   gInputStyleMask = TextField::InputStyle::NONE;
1859   inputStyleChangedSignal = false;
1860
1861   // Create a tap event to touch the text field.
1862   TestGenerateTap( application, 88.0f, 25.0f );
1863
1864   // Render and notify
1865   application.SendNotification();
1866   application.Render();
1867
1868   // Executes the idle callbacks added by the text control on the change of input style.
1869   application.RunIdles();
1870
1871   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1872   if( gInputStyleChangedCallbackCalled )
1873   {
1874     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1875
1876     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1877     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1878
1879     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1880
1881     Property::Map fontStyleMapSet;
1882     fontStyleMapSet.Insert( "weight", "bold" );
1883
1884     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1885     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1886   }
1887   DALI_TEST_CHECK( inputStyleChangedSignal );
1888
1889   gInputStyleChangedCallbackCalled = false;
1890   gInputStyleMask = TextField::InputStyle::NONE;
1891   inputStyleChangedSignal = false;
1892
1893   // Create a tap event to touch the text field.
1894   TestGenerateTap( application, 115.0f, 25.0f );
1895
1896   // Render and notify
1897   application.SendNotification();
1898   application.Render();
1899
1900   // Executes the idle callbacks added by the text control on the change of input style.
1901   application.RunIdles();
1902
1903   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1904   DALI_TEST_CHECK( !inputStyleChangedSignal );
1905
1906   gInputStyleChangedCallbackCalled = false;
1907   gInputStyleMask = TextField::InputStyle::NONE;
1908   inputStyleChangedSignal = false;
1909
1910   // Create a tap event to touch the text field.
1911   TestGenerateTap( application, 164.0f, 25.0f );
1912
1913   // Render and notify
1914   application.SendNotification();
1915   application.Render();
1916
1917   // Executes the idle callbacks added by the text control on the change of input style.
1918   application.RunIdles();
1919
1920   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1921   if( gInputStyleChangedCallbackCalled )
1922   {
1923     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1924
1925     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1926     DALI_TEST_CHECK( style.empty() );
1927   }
1928   DALI_TEST_CHECK( inputStyleChangedSignal );
1929
1930   gInputStyleChangedCallbackCalled = false;
1931   gInputStyleMask = TextField::InputStyle::NONE;
1932   inputStyleChangedSignal = false;
1933
1934   // Create a tap event to touch the text field.
1935   TestGenerateTap( application, 191.0f, 25.0f );
1936
1937   // Render and notify
1938   application.SendNotification();
1939   application.Render();
1940
1941   // Executes the idle callbacks added by the text control on the change of input style.
1942   application.RunIdles();
1943
1944   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1945   DALI_TEST_CHECK( !inputStyleChangedSignal );
1946
1947   END_TEST;
1948 }
1949
1950 int utcDaliTextFieldInputStyleChanged02(void)
1951 {
1952   // The text-field emits signals when the input style changes. These changes of style are
1953   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1954   // can't be emitted during the size negotiation as the callbacks may update the UI.
1955   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1956   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1957   ToolkitTestApplication application;
1958   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1959
1960   // Load some fonts.
1961
1962   char* pathNamePtr = get_current_dir_name();
1963   const std::string pathName( pathNamePtr );
1964   free( pathNamePtr );
1965
1966   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1967   fontClient.SetDpi( 93u, 93u );
1968
1969   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1970   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1971
1972   TextField field = TextField::New();
1973   DALI_TEST_CHECK( field );
1974
1975   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1976   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1977   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1978
1979   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1980   field.SetProperty( TextField::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>" );
1981
1982   // connect to the text changed signal.
1983   ConnectionTracker* testTracker = new ConnectionTracker();
1984   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1985   bool inputStyleChangedSignal = false;
1986   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1987
1988   application.GetScene().Add( field );
1989
1990   // Render and notify
1991   application.SendNotification();
1992   application.Render();
1993
1994   // Executes the idle callbacks added by the text control on the change of input style.
1995   application.RunIdles();
1996
1997   gInputStyleChangedCallbackCalled = false;
1998   gInputStyleMask = TextField::InputStyle::NONE;
1999   inputStyleChangedSignal = false;
2000
2001   // Create a tap event to touch the text field.
2002   TestGenerateTap( application, 53.0f, 25.0f, 100 );
2003   TestGenerateTap( application, 53.0f, 25.0f, 200 );
2004
2005   // Render and notify
2006   application.SendNotification();
2007   application.Render();
2008
2009   // Executes the idle callbacks added by the text control on the change of input style.
2010   application.RunIdles();
2011
2012   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2013   if( gInputStyleChangedCallbackCalled )
2014   {
2015     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2016                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2017                                                  TextField::InputStyle::POINT_SIZE  |
2018                                                  TextField::InputStyle::COLOR ),
2019                       TEST_LOCATION );
2020
2021     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2022     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2023
2024     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2025     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2026
2027     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2028     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2029   }
2030   DALI_TEST_CHECK( inputStyleChangedSignal );
2031
2032   gInputStyleChangedCallbackCalled = false;
2033   gInputStyleMask = TextField::InputStyle::NONE;
2034   inputStyleChangedSignal = false;
2035
2036   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2037
2038   // Render and notify
2039   application.SendNotification();
2040   application.Render();
2041
2042   // Executes the idle callbacks added by the text control on the change of input style.
2043   application.RunIdles();
2044
2045   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2046   if( gInputStyleChangedCallbackCalled )
2047   {
2048     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2049                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2050                       TEST_LOCATION );
2051
2052     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2053     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2054   }
2055   DALI_TEST_CHECK( inputStyleChangedSignal );
2056
2057   gInputStyleChangedCallbackCalled = false;
2058   gInputStyleMask = TextField::InputStyle::NONE;
2059   inputStyleChangedSignal = false;
2060
2061   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2062
2063   // Render and notify
2064   application.SendNotification();
2065   application.Render();
2066
2067   // Executes the idle callbacks added by the text control on the change of input style.
2068   application.RunIdles();
2069
2070   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2071   DALI_TEST_CHECK( !inputStyleChangedSignal );
2072
2073   gInputStyleChangedCallbackCalled = false;
2074   gInputStyleMask = TextField::InputStyle::NONE;
2075   inputStyleChangedSignal = false;
2076
2077   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2078
2079   // Render and notify
2080   application.SendNotification();
2081   application.Render();
2082
2083   // Executes the idle callbacks added by the text control on the change of input style.
2084   application.RunIdles();
2085
2086   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2087   if( gInputStyleChangedCallbackCalled )
2088   {
2089     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2090                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2091                       TEST_LOCATION );
2092
2093     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2094     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2095   }
2096   DALI_TEST_CHECK( inputStyleChangedSignal );
2097
2098   gInputStyleChangedCallbackCalled = false;
2099   gInputStyleMask = TextField::InputStyle::NONE;
2100   inputStyleChangedSignal = false;
2101
2102   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2103
2104   Property::Map fontStyleMapSet;
2105   fontStyleMapSet.Insert( "weight", "thin" );
2106   fontStyleMapSet.Insert( "width", "condensed" );
2107   fontStyleMapSet.Insert( "slant", "italic" );
2108
2109   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2110   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2111
2112   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2113   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2114   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2115   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2116
2117   // Render and notify
2118   application.SendNotification();
2119   application.Render();
2120
2121   // Executes the idle callbacks added by the text control on the change of input style.
2122   application.RunIdles();
2123
2124   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2125   DALI_TEST_CHECK( !inputStyleChangedSignal );
2126
2127   // Create a tap event to touch the text field.
2128   TestGenerateTap( application, 63.0f, 25.0f, 700 );
2129
2130   // Render and notify
2131   application.SendNotification();
2132   application.Render();
2133
2134   // Executes the idle callbacks added by the text control on the change of input style.
2135   application.RunIdles();
2136
2137   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2138   if( gInputStyleChangedCallbackCalled )
2139   {
2140     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2141                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
2142                                                  TextField::InputStyle::POINT_SIZE |
2143                                                  TextField::InputStyle::FONT_STYLE |
2144                                                  TextField::InputStyle::UNDERLINE |
2145                                                  TextField::InputStyle::SHADOW |
2146                                                  TextField::InputStyle::EMBOSS |
2147                                                  TextField::InputStyle::OUTLINE ),
2148                       TEST_LOCATION );
2149
2150     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2151     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2152   }
2153   DALI_TEST_CHECK( inputStyleChangedSignal );
2154
2155   END_TEST;
2156 }
2157
2158 int utcDaliTextFieldEvent01(void)
2159 {
2160   ToolkitTestApplication application;
2161   tet_infoline(" utcDaliTextFieldEvent01");
2162
2163   // Creates a tap event. After creating a tap event the text field should
2164   // have the focus and add text with key events should be possible.
2165
2166   TextField field = TextField::New();
2167   DALI_TEST_CHECK( field );
2168
2169   application.GetScene().Add( field );
2170
2171   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2172   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2173   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2174
2175   // Render and notify
2176   application.SendNotification();
2177   application.Render();
2178
2179   // Avoid a crash when core load gl resources.
2180   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2181
2182   // Render and notify
2183   application.SendNotification();
2184   application.Render();
2185
2186   // Add a key event but as the text field has not the focus it should do nothing.
2187   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2188
2189   // Render and notify
2190   application.SendNotification();
2191   application.Render();
2192
2193   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2194
2195   // Create a tap event to touch the text field.
2196   TestGenerateTap( application, 150.0f, 25.0f );
2197
2198   // Render and notify
2199   application.SendNotification();
2200   application.Render();
2201
2202   // Pressing delete key should be fine even if there is no text in TextField.
2203   application.ProcessEvent( GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2204   // Render and notify
2205   application.SendNotification();
2206   application.Render();
2207
2208   // Now the text field has the focus, so it can handle the key events.
2209   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2210   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2211
2212   // Render and notify
2213   application.SendNotification();
2214   application.Render();
2215
2216   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2217
2218   // Create a second text field and send key events to it.
2219   TextField field2 = TextField::New();
2220
2221   field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2222   field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2223   field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2224   field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2225
2226   application.GetScene().Add( field2 );
2227
2228   // Render and notify
2229   application.SendNotification();
2230   application.Render();
2231
2232   // Create a tap event on the second text field.
2233   TestGenerateTap( application, 150.0f, 125.0f );
2234
2235   // Render and notify
2236   application.SendNotification();
2237   application.Render();
2238
2239   // The second text field has the focus. It should handle the key events.
2240   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2242
2243   // Render and notify
2244   application.SendNotification();
2245   application.Render();
2246
2247   // Check the text has been added to the second text field.
2248   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2249
2250   END_TEST;
2251 }
2252
2253 int utcDaliTextFieldEvent02(void)
2254 {
2255   ToolkitTestApplication application;
2256   tet_infoline(" utcDaliTextFieldEvent02");
2257
2258   // Checks if the right number of actors are created.
2259
2260   TextField field = TextField::New();
2261   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2262   DALI_TEST_CHECK( field );
2263   LoadMarkerImages(application, field);
2264
2265   application.GetScene().Add( field );
2266
2267   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2268   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2269   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2270
2271   // Avoid a crash when core load gl resources.
2272   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2273
2274   // Render and notify
2275   application.SendNotification();
2276   application.Render();
2277
2278   // Check there are the expected number of children ( stencil ).
2279   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2280
2281   Actor stencil = field.GetChildAt( 0u );
2282   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2283
2284   // Create a tap event to touch the text field.
2285   TestGenerateTap( application, 150.0f, 25.0f, 300 );
2286
2287   // Render and notify
2288   application.SendNotification();
2289   application.Render();
2290
2291   Actor layer = field.GetChildAt( 1u );
2292   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2293   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2294
2295   // Now the text field has the focus, so it can handle the key events.
2296   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2297   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2298
2299   // Render and notify
2300   application.SendNotification();
2301   application.Render();
2302
2303   // Checks the cursor and the renderer have been created.
2304   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2305   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2306
2307   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2308   DALI_TEST_CHECK( cursor );
2309
2310   // The offscreen root actor has a container with all the actors which contain the text renderers.
2311   Actor container = stencil.GetChildAt( 0u );
2312   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2313   {
2314     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2315     DALI_TEST_CHECK( renderer );
2316   }
2317
2318   // Move the cursor and check the position changes.
2319   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2320   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2321
2322   // Render and notify
2323   application.SendNotification();
2324   application.Render();
2325
2326   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2327   DALI_TEST_CHECK( position2.x < position1.x );
2328
2329   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2330
2331   // Render and notify
2332   application.SendNotification();
2333   application.Render();
2334
2335   Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2336   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2337
2338
2339   // Move the cursor to the first position.
2340   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2341   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2342
2343   // Render and notify
2344   application.SendNotification();
2345   application.Render();
2346
2347   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2348
2349   // Send some taps and check the cursor positions.
2350
2351   // Try to tap at the beginning.
2352   TestGenerateTap( application, 1.0f, 25.0f, 900 );
2353
2354   // Render and notify
2355   application.SendNotification();
2356   application.Render();
2357
2358   // Cursor position should be the same than position1.
2359   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2360
2361   DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2362
2363   // Tap away from the start position.
2364   TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2365
2366   // Render and notify
2367   application.SendNotification();
2368   application.Render();
2369
2370   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2371
2372   DALI_TEST_CHECK( position6.x > position5.x );
2373
2374   // Remove all the text.
2375   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2376   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2377   field.SetProperty( TextField::Property::TEXT, "" );
2378
2379   // Render and notify
2380   application.SendNotification();
2381   application.Render();
2382
2383   // Cursor position should be the same than position2.
2384   Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2385
2386   DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2387
2388   // Should not be a renderer.
2389   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2390
2391   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2392   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2393   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2394
2395   application.SendNotification();
2396   application.Render();
2397
2398   // There are renderer and decorator layer
2399   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2400
2401   END_TEST;
2402 }
2403
2404 int utcDaliTextFieldEvent03(void)
2405 {
2406   ToolkitTestApplication application;
2407   tet_infoline(" utcDaliTextFieldEvent03");
2408
2409   // Checks if the highlight actor is created.
2410
2411   TextField field = TextField::New();
2412   DALI_TEST_CHECK( field );
2413
2414   application.GetScene().Add( field );
2415
2416   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2417   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2418   field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2419   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2420   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2421
2422   // Avoid a crash when core load gl resources.
2423   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2424   LoadMarkerImages(application, field);
2425
2426   // Render and notify
2427   application.SendNotification();
2428   application.Render();
2429
2430   // Tap first to get the focus.
2431   TestGenerateTap( application, 3.0f, 25.0f );
2432
2433   // Render and notify
2434   application.SendNotification();
2435   application.Render();
2436
2437   // Double tap to select a word.
2438   TestGenerateTap( application, 3.0f, 25.0f );
2439
2440   // Render and notify
2441   application.SendNotification();
2442   application.Render();
2443
2444   // The offscreen root actor should have two actors: the renderer and the highlight actor.
2445   Actor stencil = field.GetChildAt( 0u );
2446
2447   // The highlight actor is drawn first, so is the first actor in the list
2448   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2449   DALI_TEST_CHECK( highlight );
2450
2451   // The offscreen root actor has a container with all the actors which contain the text renderers.
2452   Actor container = stencil.GetChildAt( 1u );
2453   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2454   {
2455     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2456     DALI_TEST_CHECK( renderer );
2457   }
2458
2459   END_TEST;
2460 }
2461
2462 int utcDaliTextFieldEvent04(void)
2463 {
2464   ToolkitTestApplication application;
2465   tet_infoline(" utcDaliTextFieldEvent04");
2466
2467   // Checks if the highlight actor is created.
2468
2469   TextField field = TextField::New();
2470   DALI_TEST_CHECK( field );
2471   application.GetScene().Add( field );
2472   LoadMarkerImages(application, field);
2473   // Render and notify
2474   application.SendNotification();
2475   application.Render();
2476
2477   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2478   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2479   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2480   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2481   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2482
2483   // Avoid a crash when core load gl resources.
2484   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2485   // Render and notify
2486   application.SendNotification();
2487   application.Render();
2488
2489   // Create a tap event to touch the text field.
2490   TestGenerateTap( application, 150.0f, 25.0f );
2491   // Render and notify
2492   application.SendNotification();
2493   application.Render();
2494
2495
2496   // Tap first to get the focus.
2497   TestGenerateTap( application, 1.0f, 25.0f );
2498
2499   // Render and notify
2500   application.SendNotification();
2501   application.Render();
2502
2503   // Double tap to select a word.
2504   TestGenerateTap( application, 1.0f, 25.0f );
2505
2506   // Render and notify
2507   application.SendNotification();
2508   application.Render();
2509
2510   // Tap grab handle
2511   TestGenerateTap( application, 0.0f, 40.0f );
2512   END_TEST;
2513 }
2514
2515 int utcDaliTextFieldEvent05(void)
2516 {
2517   ToolkitTestApplication application;
2518   tet_infoline(" utcDaliTextFieldEvent05");
2519
2520   // Checks dragging of cursor/grab handle
2521
2522   TextField field = TextField::New();
2523   DALI_TEST_CHECK( field );
2524   application.GetScene().Add( field );
2525   LoadMarkerImages(application, field);
2526   // Render and notify
2527   application.SendNotification();
2528   application.Render();
2529
2530   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2531   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2532   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2533   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2534   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2535
2536   // Avoid a crash when core load gl resources.
2537   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2538   // Render and notify
2539   application.SendNotification();
2540   application.Render();
2541
2542   // Create a tap event to touch the text field.
2543   TestGenerateTap( application, 150.0f, 25.0f );
2544   // Render and notify
2545   application.SendNotification();
2546   application.Render();
2547
2548   // Tap first to get the focus.
2549   TestGenerateTap( application, 1.0f, 25.0f );
2550
2551   // Render and notify
2552   application.SendNotification();
2553   application.Render();
2554
2555   // Double tap to select a word.
2556   TestGenerateTap( application, 1.0f, 25.0f );
2557
2558   // Render and notify
2559   application.SendNotification();
2560   application.Render();
2561
2562   Actor stencil = field.GetChildAt( 1u );
2563   END_TEST;
2564 }
2565
2566 int utcDaliTextFieldEvent06(void)
2567 {
2568   ToolkitTestApplication application;
2569   tet_infoline(" utcDaliTextFieldEvent06");
2570
2571   // Checks Longpress when in edit mode
2572
2573   TextField field = TextField::New();
2574   DALI_TEST_CHECK( field );
2575   application.GetScene().Add( field );
2576   LoadMarkerImages(application, field);
2577   // Render and notify
2578   application.SendNotification();
2579   application.Render();
2580
2581   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2582   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2583   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2584   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2585   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2586
2587   // Avoid a crash when core load gl resources.
2588   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2589   // Render and notify
2590   application.SendNotification();
2591   application.Render();
2592
2593   // Create a tap event to touch the text field.
2594   TestGenerateTap( application, 150.0f, 25.0f );
2595   // Render and notify
2596   application.SendNotification();
2597   application.Render();
2598
2599
2600   // Tap first to get the focus.
2601   TestGenerateTap( application, 1.0f, 25.0f );
2602
2603   // Render and notify
2604   application.SendNotification();
2605   application.Render();
2606
2607   // Long Press
2608   TestGenerateLongPress(application, 1.0f, 25.0f);
2609
2610   // Render and notify
2611   application.SendNotification();
2612   application.Render();
2613
2614   END_TEST;
2615 }
2616
2617 int utcDaliTextFieldEvent07(void)
2618 {
2619   ToolkitTestApplication application;
2620   tet_infoline(" utcDaliTextFieldEvent07");
2621
2622   // Checks Longpress to start edit mode
2623
2624   TextField field = TextField::New();
2625   DALI_TEST_CHECK( field );
2626   application.GetScene().Add( field );
2627   LoadMarkerImages(application, field);
2628   // Render and notify
2629   application.SendNotification();
2630   application.Render();
2631
2632   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2633   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2634   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2635   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2636   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2637   Property::Map propertyMap;
2638   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2639   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2640
2641   // Avoid a crash when core load gl resources.
2642   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2643   // Render and notify
2644   application.SendNotification();
2645   application.Render();
2646
2647   // Long Press
2648   TestGenerateLongPress(application, 1.0f, 25.0f);
2649
2650   // Render and notify
2651   application.SendNotification();
2652   application.Render();
2653
2654   END_TEST;
2655 }
2656
2657 int utcDaliTextFieldEvent08(void)
2658 {
2659   ToolkitTestApplication application;
2660   tet_infoline(" utcDaliTextFieldEvent08");
2661
2662   Dali::Clipboard clipboard = Clipboard::Get();
2663   clipboard.SetItem("testTextFieldEvent");
2664
2665   // Checks Longpress when only place holder text
2666
2667   TextField field = TextField::New();
2668   DALI_TEST_CHECK( field );
2669   application.GetScene().Add( field );
2670   LoadMarkerImages(application, field);
2671   // Render and notify
2672   application.SendNotification();
2673   application.Render();
2674
2675   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2676   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2677   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2678   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2679   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2680
2681   // Avoid a crash when core load gl resources.
2682   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2683   // Render and notify
2684   application.SendNotification();
2685   application.Render();
2686
2687   // Long Press
2688   TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2689
2690   // Render and notify
2691   application.SendNotification();
2692   application.Render();
2693
2694   Wait(application, 500);
2695
2696   TestEndLongPress( application, 1.0f, 25.0f, 520 );
2697
2698   // Long Press
2699   TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2700
2701   // Render and notify
2702   application.Render();
2703
2704   Wait(application, 500);
2705
2706   Integration::Scene stage = application.GetScene();
2707   Layer layer = stage.GetRootLayer();
2708   Actor actor = layer.FindChildByName("optionPaste");
2709
2710   if (actor)
2711   {
2712     Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2713     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2714     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2715
2716     Dali::Integration::TouchEvent event;
2717     event = Dali::Integration::TouchEvent();
2718     event.AddPoint( GetPointDownInside( position ) );
2719     application.ProcessEvent( event );
2720
2721     event = Dali::Integration::TouchEvent();
2722     event.AddPoint( GetPointUpInside( position ) );
2723     application.ProcessEvent( event );
2724   }
2725   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2726
2727   END_TEST;
2728 }
2729
2730 int utcDaliTextFieldEvent09(void)
2731 {
2732   ToolkitTestApplication application;
2733   tet_infoline(" utcDaliTextFieldEvent09");
2734
2735   TextField field = TextField::New();
2736   DALI_TEST_CHECK( field );
2737   application.GetScene().Add( field );
2738   LoadMarkerImages(application, field);
2739   // Render and notify
2740   application.SendNotification();
2741   application.Render();
2742
2743   field.SetProperty( TextField::Property::TEXT, "Hello" );
2744   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2745   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2746   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2747   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2748
2749   // Avoid a crash when core load gl resources.
2750   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2751
2752   // Create a tap event to touch the text field.
2753   TestGenerateTap( application, 150.0f, 25.0f );
2754   application.SendNotification();
2755   application.Render();
2756
2757   Property::Map map;
2758   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2759   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2760   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2761   application.SendNotification();
2762   application.Render();
2763
2764   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2765   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2766   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2767   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2768   application.SendNotification();
2769   application.Render();
2770
2771   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2772   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2773   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2774   for( unsigned int index = 0u; index < 5u; ++index )
2775   {
2776     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2777     application.SendNotification();
2778     application.Render();
2779   }
2780
2781   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2782   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2783   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2784   for( unsigned int index = 0u; index < 5u; ++index )
2785   {
2786     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2787     application.SendNotification();
2788     application.Render();
2789   }
2790
2791   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2792   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2793   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2794   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2795   application.SendNotification();
2796   application.Render();
2797   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2798   application.SendNotification();
2799   application.Render();
2800
2801   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2802   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2803   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2804   application.SendNotification();
2805   application.Render();
2806
2807   Property::Map mapGet;
2808   mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2809   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2810   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2811   END_TEST;
2812 }
2813
2814
2815 int utcDaliTextFieldStyleWhilstSelected(void)
2816 {
2817   ToolkitTestApplication application;
2818   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2819
2820   // Change font and styles whilst text is selected whilst word selected
2821
2822   TextField field = TextField::New();
2823   DALI_TEST_CHECK( field );
2824   application.GetScene().Add( field );
2825   LoadMarkerImages(application, field);
2826   // Render and notify
2827   application.SendNotification();
2828   application.Render();
2829
2830   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2831   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2832   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2833   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2834   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2835
2836   // Avoid a crash when core load gl resources.
2837   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2838   // Render and notify
2839   application.SendNotification();
2840   application.Render();
2841
2842   // Create a tap event to touch the text field.
2843   TestGenerateTap( application, 150.0f, 25.0f );
2844   // Render and notify
2845   application.SendNotification();
2846   application.Render();
2847
2848
2849   // Tap first to get the focus.
2850   TestGenerateTap( application, 1.0f, 25.0f );
2851
2852   // Render and notify
2853   application.SendNotification();
2854   application.Render();
2855
2856   // Double tap to select a word.
2857   TestGenerateTap( application, 1.0f, 25.0f );
2858
2859   // Render and notify
2860   application.SendNotification();
2861   application.Render();
2862
2863   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2864   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2865
2866   Property::Map fontStyleMapSet;
2867   Property::Map fontStyleMapGet;
2868
2869   fontStyleMapSet.Insert( "weight", "bold" );
2870   fontStyleMapSet.Insert( "slant", "italic" );
2871   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2872
2873   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2874   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2875   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2876
2877   fontStyleMapSet.Clear();
2878   fontStyleMapSet.Insert( "width", "expanded" );
2879   fontStyleMapSet.Insert( "slant", "italic" );
2880   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2881
2882   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2883   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2884   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2885
2886   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2887   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2888
2889   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2890   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2891
2892   fontStyleMapSet.Clear();
2893   fontStyleMapSet.Insert( "weight", "bold" );
2894   fontStyleMapSet.Insert( "slant", "italic" );
2895
2896   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2897
2898   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2899   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2900   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2901
2902   fontStyleMapSet.Clear();
2903   fontStyleMapSet.Insert( "width", "expanded" );
2904
2905   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2906
2907   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2908   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2909   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2910
2911   // Press Escape to increase coverage
2912   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2913   application.SendNotification();
2914   application.Render();
2915
2916   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2917
2918   END_TEST;
2919 }
2920
2921 int utcDaliTextFieldEscKeyLoseFocus(void)
2922 {
2923   ToolkitTestApplication application;
2924   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2925
2926   // Creates a tap event. After creating a tap event the text field should
2927   // have the focus and add text with key events should be possible.
2928
2929   TextField field = TextField::New();
2930   DALI_TEST_CHECK( field );
2931
2932   application.GetScene().Add( field );
2933
2934   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2935   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2936   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2937
2938   // Avoid a crash when core load gl resources.
2939   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2940
2941   // Render and notify
2942   application.SendNotification();
2943   application.Render();
2944
2945   // Add a key event but as the text field has not the focus it should do nothing.
2946   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2947   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2948
2949   // Render and notify
2950   application.SendNotification();
2951   application.Render();
2952
2953   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2954
2955   // Create a tap event to touch the text field.
2956   TestGenerateTap( application, 150.0f, 25.0f );
2957
2958   // Render and notify
2959   application.SendNotification();
2960   application.Render();
2961
2962   // Now the text field has the focus, so it can handle the key events.
2963   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2964   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2965   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2966   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2967
2968   // Render and notify
2969   application.SendNotification();
2970   application.Render();
2971
2972   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2973
2974   // Generate a Esc key event. The text field should lose the focus.
2975   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2976   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2977
2978   // Render and notify
2979   application.SendNotification();
2980   application.Render();
2981
2982   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
2983
2984   // No more text should be introduced
2985   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2986   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2987
2988   // Render and notify
2989   application.SendNotification();
2990   application.Render();
2991
2992   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
2993
2994   END_TEST;
2995 }
2996
2997 int utcDaliTextFieldSomeSpecialKeys(void)
2998 {
2999   ToolkitTestApplication application;
3000   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3001
3002   // Checks some special keys when the text is selected.
3003
3004   TextField field = TextField::New();
3005   DALI_TEST_CHECK( field );
3006   application.GetScene().Add( field );
3007   LoadMarkerImages(application, field);
3008   // Render and notify
3009   application.SendNotification();
3010   application.Render();
3011
3012   const std::string longText( "This is a long text for the size of the text-field." );
3013
3014   field.SetProperty( TextField::Property::TEXT, longText );
3015   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3016   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3017   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3018   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3019
3020   // Avoid a crash when core load gl resources.
3021   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3022   // Render and notify
3023   application.SendNotification();
3024   application.Render();
3025
3026   // Create a tap event to touch the text field.
3027   TestGenerateTap( application, 150.0f, 25.0f );
3028
3029   // Render and notify
3030   application.SendNotification();
3031   application.Render();
3032
3033   // Tap first to get the focus.
3034   TestGenerateTap( application, 1.0f, 25.0f );
3035
3036   // Render and notify
3037   application.SendNotification();
3038   application.Render();
3039
3040   // Double tap to select a word.
3041   TestGenerateTap( application, 1.0f, 25.0f );
3042
3043   // Render and notify
3044   application.SendNotification();
3045   application.Render();
3046
3047   // Generate a Esc key event. The text field should lose the focus.
3048   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::DOWN, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3049   application.ProcessEvent( GenerateKey( "XF86PowerOff", "", "XF86PowerOff", DALI_KEY_POWER, 0, 0, Integration::KeyEvent::UP, "XF86PowerOff", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3050
3051   // Render and notify
3052   application.SendNotification();
3053   application.Render();
3054
3055   // Generate a Esc key event. The text field should lose the focus.
3056   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::DOWN, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3057   application.ProcessEvent( GenerateKey( "XF86Menu", "", "XF86Menu", DALI_KEY_MENU, 0, 0, Integration::KeyEvent::UP, "XF86Menu", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3058
3059   // Render and notify
3060   application.SendNotification();
3061   application.Render();
3062
3063   // Generate a Esc key event. The text field should lose the focus.
3064   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::DOWN, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3065   application.ProcessEvent( GenerateKey( "XF86Home", "", "XF86Home", DALI_KEY_HOME, 0, 0, Integration::KeyEvent::UP, "XF86Home", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3066
3067   // Render and notify
3068   application.SendNotification();
3069   application.Render();
3070
3071   // The text shouldn't be deleted.
3072   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), longText, TEST_LOCATION );
3073
3074   END_TEST;
3075 }
3076
3077 int utcDaliTextFieldSizeUpdate(void)
3078 {
3079   ToolkitTestApplication application;
3080   tet_infoline("utcDaliTextFieldSizeUpdate");
3081
3082   // Checks some special keys when the text is selected.
3083   TextField field = TextField::New();
3084   DALI_TEST_CHECK( field );
3085   application.GetScene().Add( field );
3086
3087   float previousHeight = 0.0f;
3088   float currentHeight = 0.0f;
3089   const float fieldWidth = 1920.0f;
3090
3091
3092   // "ㅁ" is bigger then "ኢ"
3093   field.SetProperty( Actor::Property::SIZE, Vector2( fieldWidth ,10.0f ) );
3094   field.SetResizePolicy( ResizePolicy::FIXED , Dimension::WIDTH );
3095   field.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY , Dimension::HEIGHT );
3096
3097   field.SetProperty( TextField::Property::TEXT, "ኢ");
3098   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3099   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3100
3101   field.SetProperty( Actor::Property::KEYBOARD_FOCUSABLE,true);
3102   KeyboardFocusManager::Get().SetCurrentFocusActor( field );
3103
3104   application.SendNotification();
3105   application.Render();
3106
3107   previousHeight = field.GetHeightForWidth( fieldWidth );
3108   DALI_TEST_EQUALS( previousHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ) , TEST_LOCATION );
3109
3110   // Add  another script characters ( glyph height is defferent )
3111   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3112   application.ProcessEvent( GenerateKey( "ㅁ", "", "ㅁ", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "ㅁ", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3113
3114   application.SendNotification();
3115   application.Render();
3116
3117   currentHeight = field.GetHeightForWidth( fieldWidth );
3118   DALI_TEST_EQUALS( currentHeight, field.GetProperty<float>( Actor::Property::SIZE_HEIGHT ), TEST_LOCATION );
3119   DALI_TEST_EQUALS( (previousHeight < currentHeight), true , TEST_LOCATION );
3120
3121   END_TEST;
3122 }
3123
3124 int utcDaliTextFieldExtremlyLargePointSize(void)
3125 {
3126   ToolkitTestApplication application;
3127   tet_infoline(" utcDaliTextFieldExtremlyLargePointSize");
3128
3129   TextField field = TextField::New();
3130
3131   field.SetProperty( TextField::Property::TEXT, "Text" );
3132   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3133   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3134   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3135   application.GetScene().Add( field );
3136
3137   try
3138   {
3139     field.SetProperty( TextField::Property::POINT_SIZE, 160.0f );
3140     application.SendNotification();
3141     DALI_TEST_CHECK( field );
3142   }
3143   catch (...)
3144   {
3145     tet_result(TET_FAIL);
3146   }
3147   END_TEST;
3148 }
3149
3150 int UtcDaliTextFieldDefaultFontStylePropertyCoverage(void)
3151 {
3152   ToolkitTestApplication application;
3153   tet_infoline("UtcDaliTextFieldFontStylePorpertyCoverage");
3154   TextField field = TextField::New();
3155   DALI_TEST_CHECK( field );
3156   application.GetScene().Add( field );
3157
3158   Property::Map fontStyleMapGet;
3159
3160   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
3161
3162   Property::Value* weightValue = NULL;
3163   Property::Value* widthValue = NULL;
3164   Property::Value* slantValue = NULL;
3165   weightValue = fontStyleMapGet.Find( "weight" );
3166   widthValue = fontStyleMapGet.Find( "width" );
3167   slantValue = fontStyleMapGet.Find( "slant" );
3168   DALI_TEST_CHECK( !weightValue );
3169   DALI_TEST_CHECK( !widthValue );
3170   DALI_TEST_CHECK( !slantValue );
3171
3172   END_TEST;
3173 }
3174
3175 int UtcDaliTextFieldSettingPlaceholder(void)
3176 {
3177   ToolkitTestApplication application;
3178   tet_infoline("UtcDaliTextFieldSettingPlaceholder");
3179
3180   TextField field = TextField::New();
3181   DALI_TEST_CHECK( field );
3182   application.GetScene().Add( field );
3183
3184   // Check the placeholder property with pixel size
3185   Property::Map placeholderPixelSizeMapSet;
3186   Property::Map placeholderPixelSizeMapGet;
3187   Property::Map placeholderFontstyleMap;
3188   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3189   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3190   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::BLUE;
3191   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3192   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::PIXEL_SIZE ] = 15.0f;
3193   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = true;
3194
3195   placeholderFontstyleMap.Insert( "weight", "bold" );
3196   placeholderPixelSizeMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3197   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
3198
3199   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3200   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
3201   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderPixelSizeMapSet ), true, TEST_LOCATION );
3202
3203   // Check the placeholder property with point size
3204   Property::Map placeholderMapSet;
3205   Property::Map placeholderMapGet;
3206   placeholderMapSet[ Text::PlaceHolder::Property::TEXT ] = "Setting Placeholder Text";
3207   placeholderMapSet[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = "Setting Placeholder Text Focused";
3208   placeholderMapSet[ Text::PlaceHolder::Property::COLOR ] = Color::RED;
3209   placeholderMapSet[ Text::PlaceHolder::Property::FONT_FAMILY ] = "Arial";
3210   placeholderMapSet[ Text::PlaceHolder::Property::POINT_SIZE ] = 12.0f;
3211   placeholderMapSet[ Text::PlaceHolder::Property::ELLIPSIS ] = false;
3212
3213   // Check the placeholder font style property
3214   placeholderFontstyleMap.Clear();
3215
3216   placeholderFontstyleMap.Insert( "weight", "bold" );
3217   placeholderFontstyleMap.Insert( "width", "condensed" );
3218   placeholderFontstyleMap.Insert( "slant", "italic" );
3219   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3220   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3221
3222   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3223   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3224   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3225
3226   // Reset font style.
3227   placeholderFontstyleMap.Clear();
3228   placeholderFontstyleMap.Insert( "weight", "normal" );
3229   placeholderFontstyleMap.Insert( "slant", "oblique" );
3230   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3231   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3232
3233   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3234   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3235   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3236
3237   placeholderFontstyleMap.Clear();
3238   placeholderFontstyleMap.Insert( "slant", "roman" );
3239   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3240   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3241
3242   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3243
3244   placeholderFontstyleMap.Clear();
3245   placeholderMapSet[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderFontstyleMap;
3246
3247   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
3248   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
3249   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
3250   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderMapSet ), true, TEST_LOCATION );
3251
3252   END_TEST;
3253 }
3254
3255 int UtcDaliTextFieldPlaceholderCoverage(void)
3256 {
3257   ToolkitTestApplication application;
3258   tet_infoline("UtcDaliTextFieldPlaceholderCoverage");
3259
3260   // mPlaceholderFont is created only once, so create a new control for coverage.
3261   TextField fieldForCoverage = TextField::New();
3262   DALI_TEST_CHECK(fieldForCoverage);
3263   application.GetScene().Add(fieldForCoverage);
3264
3265   // for SetPlaceholderFontFamily() coverage.
3266   Property::Map fontFamilyMap;
3267   fontFamilyMap[Text::PlaceHolder::Property::FONT_FAMILY] = "Arial";
3268   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontFamilyMap);
3269
3270   // mPlaceholderFont is created only once, so create a new control for coverage.
3271   fieldForCoverage = TextField::New();
3272   DALI_TEST_CHECK(fieldForCoverage);
3273   application.GetScene().Add(fieldForCoverage);
3274
3275   // for SetPlaceholderTextFontSize coverage.
3276   Property::Map fontSizeMap;
3277   fontSizeMap[Text::PlaceHolder::Property::PIXEL_SIZE] = 15.0f;
3278   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontSizeMap);
3279
3280   // mPlaceholderFont is created only once, so create a new control for coverage.
3281   fieldForCoverage = TextField::New();
3282   DALI_TEST_CHECK(fieldForCoverage);
3283   application.GetScene().Add(fieldForCoverage);
3284
3285   // for SetPlaceholderTextFontWeight coverage.
3286   Property::Map fontStyleWeightMap;
3287   Property::Map fontStyleWeightPropertyMap;
3288   fontStyleWeightPropertyMap.Insert("weight", "bold");
3289   fontStyleWeightMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWeightPropertyMap;
3290   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWeightMap);
3291
3292   // mPlaceholderFont is created only once, so create a new control for coverage.
3293   fieldForCoverage = TextField::New();
3294   DALI_TEST_CHECK(fieldForCoverage);
3295   application.GetScene().Add(fieldForCoverage);
3296
3297   // for SetPlaceholderTextFontWidth coverage.
3298   Property::Map fontStyleWidthMap;
3299   Property::Map fontStyleWidthPropertyMap;
3300   fontStyleWidthPropertyMap.Insert("width", "expanded");
3301   fontStyleWidthMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleWidthPropertyMap;
3302   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleWidthMap);
3303
3304   // mPlaceholderFont is created only once, so create a new control for coverage.
3305   fieldForCoverage = TextField::New();
3306   DALI_TEST_CHECK(fieldForCoverage);
3307   application.GetScene().Add(fieldForCoverage);
3308
3309   // for SetPlaceholderTextFontSlant coverage.
3310   Property::Map fontStyleSlantMap;
3311   Property::Map fontStyleSlantPropertyMap;
3312   fontStyleSlantPropertyMap.Insert("slant", "italic");
3313   fontStyleSlantMap[Text::PlaceHolder::Property::FONT_STYLE] = fontStyleSlantPropertyMap;
3314   fieldForCoverage.SetProperty(TextField::Property::PLACEHOLDER, fontStyleSlantMap);
3315
3316   END_TEST;
3317 }
3318
3319 int UtcDaliTextFieldSetPaddingProperty(void)
3320 {
3321   ToolkitTestApplication application;
3322   tet_infoline("UtcDaliTextFieldSetPaddingProperty\n");
3323
3324   TextField field = TextField::New();
3325   DALI_TEST_CHECK( field );
3326   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3327   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3328   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3329   application.GetScene().Add( field );
3330
3331   application.SendNotification();
3332   application.Render();
3333
3334   Vector3 originalSize = field.GetNaturalSize();
3335
3336   field.SetProperty( Toolkit::Control::Property::PADDING, Extents( 10, 10, 10, 10 ) );
3337
3338   application.SendNotification();
3339   application.Render();
3340
3341   DALI_TEST_EQUALS( field.GetProperty<Extents>( Toolkit::Control::Property::PADDING ), Extents( 10, 10, 10, 10 ), TEST_LOCATION );
3342
3343   Vector3 paddingAddedSize = field.GetNaturalSize();
3344
3345   DALI_TEST_EQUALS( originalSize.width + 10 + 10 , paddingAddedSize.width, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3346
3347   DALI_TEST_EQUALS( originalSize.height + 10 + 10 , paddingAddedSize.height, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
3348
3349   END_TEST;
3350 }
3351
3352 int UtcDaliTextFieldEnableShiftSelectionProperty(void)
3353 {
3354   ToolkitTestApplication application;
3355   tet_infoline("UtcDaliTextFieldEnableShiftSelectionProperty");
3356
3357   TextField field = TextField::New();
3358   DALI_TEST_CHECK( field );
3359   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3360   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3361   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3362   application.GetScene().Add( field );
3363
3364   application.SendNotification();
3365   application.Render();
3366
3367   // The default value of ENABLE_SHIFT_SELECTION is 'true'.
3368   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), true, TEST_LOCATION );
3369
3370   // Check the enable shift selection property
3371   field.SetProperty( DevelTextField::Property::ENABLE_SHIFT_SELECTION, false );
3372   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_SHIFT_SELECTION ), false, TEST_LOCATION );
3373
3374   application.SendNotification();
3375   application.Render();
3376
3377   END_TEST;
3378 }
3379
3380 int UtcDaliTextFieldEnableGrabHandleProperty(void)
3381 {
3382   ToolkitTestApplication application;
3383   tet_infoline("UtcDaliTextFieldEnableGrabHandleProperty");
3384
3385   TextField field = TextField::New();
3386   DALI_TEST_CHECK( field );
3387   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3388   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3389   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3390   application.GetScene().Add( field );
3391
3392   application.SendNotification();
3393   application.Render();
3394
3395   // The default value of ENABLE_GRAB_HANDLE is 'true'.
3396   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), true, TEST_LOCATION );
3397
3398   // Check the enable grab handle property
3399   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE, false );
3400   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE ), false, TEST_LOCATION );
3401
3402   application.SendNotification();
3403   application.Render();
3404
3405   END_TEST;
3406 }
3407
3408 int UtcDaliTextFieldMatchSystemLanguageDirectionProperty(void)
3409 {
3410   ToolkitTestApplication application;
3411   tet_infoline("UtcDaliTextFieldMatchSystemLanguageDirectionProperty");
3412
3413   TextField field = TextField::New();
3414   DALI_TEST_CHECK( field );
3415   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3416   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3417   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3418   application.GetScene().Add( field );
3419
3420   application.SendNotification();
3421   application.Render();
3422
3423   // The default value of MATCH_SYSTEM_LANGUAGE_DIRECTION is 'true'.
3424   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), true, TEST_LOCATION );
3425
3426   // Check the match system language direction property
3427   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
3428   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION ), false, TEST_LOCATION );
3429
3430   application.SendNotification();
3431   application.Render();
3432
3433   END_TEST;
3434 }
3435
3436 int utcDaliTextFieldLayoutDirectionCoverage(void)
3437 {
3438   ToolkitTestApplication application;
3439   tet_infoline(" utcDaliTextFieldLayoutDirectionCoverage");
3440
3441   // Creates a tap event. After creating a tap event the text field should
3442   // have the focus and add text with key events should be possible.
3443   TextField field = TextField::New();
3444   DALI_TEST_CHECK( field );
3445
3446   application.GetScene().Add( field );
3447
3448   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3449   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3450   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3451
3452   // Avoid a crash when core load gl resources.
3453   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3454
3455   // Render and notify
3456   application.SendNotification();
3457   application.Render();
3458
3459   // init direction for coverage
3460   // Set horizontal alignment END
3461   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3462
3463   // Create a tap event to touch the text field.
3464   TestGenerateTap( application, 150.0f, 25.0f );
3465
3466   // Render and notify
3467   application.SendNotification();
3468   application.Render();
3469
3470   // Set MATCH_SYSTEM_LANGUAGE_DIRECTION to true to use the layout direction.
3471   field.SetProperty( DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
3472   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
3473
3474   // Set horizontal alignment BEGIN
3475   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "BEGIN");
3476
3477   // Create a tap event to touch the text field.
3478   TestGenerateTap( application, 150.0f, 25.0f );
3479
3480   // Render and notify
3481   application.SendNotification();
3482   application.Render();
3483
3484   // Set horizontal alignment CENTER
3485   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER");
3486
3487   // Create a tap event to touch the text field.
3488   TestGenerateTap( application, 150.0f, 25.0f );
3489
3490   // Render and notify
3491   application.SendNotification();
3492   application.Render();
3493
3494   // Set horizontal alignment END
3495   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END");
3496
3497   // Create a tap event to touch the text field.
3498   TestGenerateTap( application, 150.0f, 25.0f );
3499
3500   // Render and notify
3501   application.SendNotification();
3502   application.Render();
3503
3504   // Generate a Esc key event. The text field should lose the focus.
3505   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3506   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3507
3508   // Render and notify
3509   application.SendNotification();
3510   application.Render();
3511
3512   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3513
3514   END_TEST;
3515 }
3516
3517 int UtcDaliTextFieldGetInputMethodContext(void)
3518 {
3519   ToolkitTestApplication application;
3520   tet_infoline("UtcDaliTextFieldGetInputMethodContext");
3521
3522   TextField field = TextField::New();
3523   DALI_TEST_CHECK( DevelTextField::GetInputMethodContext( field ) );
3524
3525   END_TEST;
3526 }
3527
3528 int UtcDaliTextFieldSelectWholeText(void)
3529 {
3530   ToolkitTestApplication application;
3531   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3532
3533   TextField textField = TextField::New();
3534
3535   application.GetScene().Add( textField );
3536
3537   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3538   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3539   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3540
3541   // Avoid a crash when core load gl resources.
3542   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3543
3544   application.SendNotification();
3545   application.Render();
3546
3547   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3548
3549   DevelTextField::SelectWholeText( textField );
3550
3551   application.SendNotification();
3552   application.Render();
3553
3554   // Nothing should have been selected. The number of children is still 1
3555   DALI_TEST_EQUALS( 1u, textField.GetChildCount(), TEST_LOCATION );
3556
3557   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3558
3559   application.SendNotification();
3560   application.Render();
3561
3562   DevelTextField::SelectWholeText( textField );
3563
3564   application.SendNotification();
3565   application.Render();
3566
3567   // Should be 2 children, the stencil and the layer
3568   DALI_TEST_EQUALS( 2u, textField.GetChildCount(), TEST_LOCATION );
3569
3570   // The offscreen root actor should have two actors: the renderer and the highlight actor.
3571   Actor stencil = textField.GetChildAt( 0u );
3572
3573   // The highlight actor is drawn first, so is the first actor in the list
3574   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
3575   DALI_TEST_CHECK( highlight );
3576
3577   END_TEST;
3578 }
3579
3580 int UtcDaliTextFieldSelectText(void)
3581 {
3582   ToolkitTestApplication application;
3583   tet_infoline(" UtcDaliTextFieldSelectText ");
3584
3585   TextField textField = TextField::New();
3586
3587   application.GetScene().Add( textField );
3588
3589   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3590   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3591   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3592
3593   // Avoid a crash when core load gl resources.
3594   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3595
3596   application.SendNotification();
3597   application.Render();
3598
3599   DevelTextField::SelectText( textField, 0, 5 );
3600
3601   application.SendNotification();
3602   application.Render();
3603
3604   // Nothing is selected
3605   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3606   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3607
3608   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3609
3610   application.SendNotification();
3611   application.Render();
3612
3613   // Hello is selected
3614   DevelTextField::SelectText( textField, 0, 5 );
3615
3616   application.SendNotification();
3617   application.Render();
3618
3619   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3620   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3621
3622   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3623   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3624
3625   // world is selected
3626   DevelTextField::SelectText( textField, 6, 11 );
3627
3628   application.SendNotification();
3629   application.Render();
3630
3631   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3632   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3633
3634   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3635   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3636
3637   END_TEST;
3638 }
3639
3640 int UtcDaliTextFieldSelectNone(void)
3641 {
3642   ToolkitTestApplication application;
3643   tet_infoline(" UtcDaliTextFieldSelectWholeText ");
3644
3645   TextField textField = TextField::New();
3646
3647   application.GetScene().Add( textField );
3648
3649   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3650   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3651   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3652
3653   // Avoid a crash when core load gl resources.
3654   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3655
3656   application.SendNotification();
3657   application.Render();
3658
3659   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3660
3661   application.SendNotification();
3662   application.Render();
3663
3664   // Nothing is selected
3665   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3666   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3667
3668   DevelTextField::SelectWholeText( textField );
3669
3670   application.SendNotification();
3671   application.Render();
3672
3673   // whole text is selected
3674   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3675   DALI_TEST_EQUALS( "Hello world", selectedText, TEST_LOCATION );
3676
3677   DevelTextField::SelectNone( textField );
3678
3679   application.SendNotification();
3680   application.Render();
3681
3682   // Nothing is selected
3683   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3684   DALI_TEST_EQUALS( "", selectedText, TEST_LOCATION );
3685
3686   END_TEST;
3687 }
3688
3689 int UtcDaliTextFieldSelectRange(void)
3690 {
3691   ToolkitTestApplication application;
3692   tet_infoline(" UtcDaliTextFieldSelectRange ");
3693
3694   TextField textField = TextField::New();
3695
3696   application.GetScene().Add( textField );
3697
3698   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3699   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3700   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3701
3702   // Avoid a crash when core load gl resources.
3703   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3704
3705   application.SendNotification();
3706   application.Render();
3707
3708   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
3709
3710   application.SendNotification();
3711   application.Render();
3712
3713   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 0);
3714   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 5);
3715
3716   // Hello is selected
3717   std::string selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3718   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
3719
3720   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
3721   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
3722
3723   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_START , 6);
3724   textField.SetProperty( DevelTextField::Property::SELECTED_TEXT_END , 11);
3725
3726   // world is selected
3727   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
3728   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
3729
3730   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
3731   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
3732
3733   END_TEST;
3734 }
3735
3736 int UtcDaliTextFieldEnableEditing(void)
3737 {
3738   ToolkitTestApplication application;
3739   tet_infoline(" UtcDaliTextFieldEnableEditing ");
3740
3741   TextField textField = TextField::New();
3742
3743   application.GetScene().Add( textField );
3744
3745   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3746   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3747   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3748
3749   // Avoid a crash when core load gl resources.
3750   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3751
3752   application.SendNotification();
3753   application.Render();
3754
3755   textField.SetKeyInputFocus();
3756   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, false );
3757   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3758
3759   // Render and notify
3760   application.SendNotification();
3761   application.Render();
3762
3763   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "", TEST_LOCATION );
3764   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), false, TEST_LOCATION );
3765
3766
3767   textField.SetKeyInputFocus();
3768   textField.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
3769   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3770
3771   // Render and notify
3772   application.SendNotification();
3773   application.Render();
3774
3775   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "D", TEST_LOCATION );
3776   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::ENABLE_EDITING ).Get<bool>(), true, TEST_LOCATION );
3777
3778   END_TEST;
3779 }
3780
3781 int UtcDaliToolkitTextFieldFontSizeScale(void)
3782 {
3783   ToolkitTestApplication application;
3784   tet_infoline(" UtcDaliToolkitTextFieldFontSizeScale");
3785
3786   TextField textField = TextField::New();
3787   textField.SetProperty( TextField::Property::POINT_SIZE, 30.f );
3788   textField.SetProperty( TextField::Property::TEXT, "Test" );
3789   Vector3 nonScaledSize = textField.GetNaturalSize();
3790
3791   TextField textFieldScaled = TextField::New();
3792   textFieldScaled.SetProperty( TextField::Property::POINT_SIZE, 15.f );
3793   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3794   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3795   Vector3 scaledSize = textFieldScaled.GetNaturalSize();
3796
3797   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3798
3799   textField.SetProperty( TextField::Property::PIXEL_SIZE, 30.f );
3800   textField.SetProperty( TextField::Property::TEXT, "Test" );
3801   nonScaledSize = textField.GetNaturalSize();
3802
3803   textFieldScaled.SetProperty( TextField::Property::PIXEL_SIZE, 15.f );
3804   textFieldScaled.SetProperty( Toolkit::DevelTextField::Property::FONT_SIZE_SCALE, 2.f );
3805   textFieldScaled.SetProperty( TextField::Property::TEXT, "Test" );
3806   scaledSize = textFieldScaled.GetNaturalSize();
3807
3808   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
3809
3810   END_TEST;
3811 }
3812
3813 int UtcDaliTextFieldPrimaryCursorPosition(void)
3814 {
3815   ToolkitTestApplication application;
3816   tet_infoline(" UtcDaliTextFieldPrimaryCursorPosition ");
3817
3818   TextField textField = TextField::New();
3819
3820   application.GetScene().Add( textField );
3821
3822   textField.SetProperty( TextField::Property::TEXT, "ABCEF");
3823   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3824   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3825   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3826
3827   // Avoid a crash when core load gl resources.
3828   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3829
3830   textField.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
3831   application.SendNotification();
3832   application.Render();
3833   textField.SetKeyInputFocus();
3834
3835   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3836
3837   // Render and notify
3838   application.SendNotification();
3839   application.Render();
3840
3841   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "ABCDEF", TEST_LOCATION );
3842   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION ).Get<int>(), 4, TEST_LOCATION );
3843
3844   END_TEST;
3845 }
3846
3847 // test max length when set after setting long text
3848 int utcDaliTextFieldMaxCharactersReachedAfterSetText(void)
3849 {
3850   ToolkitTestApplication application;
3851   tet_infoline(" utcDaliTextFieldMaxCharactersReachedAfterSetText");
3852   TextField field = TextField::New();
3853   DALI_TEST_CHECK( field );
3854
3855   application.GetScene().Add( field );
3856
3857   field.SetProperty(TextField::Property::TEXT, "123456789");
3858
3859   const int maxNumberOfCharacters = 3;
3860   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
3861
3862   field.SetKeyInputFocus();
3863
3864   // connect to the text max lengh reached signal.
3865   ConnectionTracker* testTracker = new ConnectionTracker();
3866   bool maxLengthReachedSignal = false;
3867   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
3868
3869   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3870   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3871
3872   DALI_TEST_CHECK( maxLengthReachedSignal );
3873
3874   DALI_TEST_EQUALS( field.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "123456789", TEST_LOCATION );
3875
3876   END_TEST;
3877 }
3878
3879
3880
3881 int UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize(void)
3882 {
3883   ToolkitTestApplication application;
3884   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledForLargeFontPointSize ");
3885
3886   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3887   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3888   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3889
3890   // Create a text field
3891   TextField textField = TextField::New();
3892
3893   //Set size to avoid automatic eliding
3894   textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3895   //Set very large font-size using point-size
3896   textField.SetProperty( TextField::Property::POINT_SIZE, 1000) ;
3897   //Specify font-family
3898   textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3899   //Set text to check if appear or not
3900   textField.SetProperty( TextField::Property::TEXT, "A");
3901
3902   application.GetScene().Add( textField );
3903
3904   application.SendNotification();
3905   application.Render();
3906   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3907   Vector3 naturalSize = textField.GetNaturalSize();
3908
3909   DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3910   DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3911
3912   END_TEST;
3913 }
3914
3915 int UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases(void)
3916 {
3917   ToolkitTestApplication application;
3918   tet_infoline(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases ");
3919
3920   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
3921   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3922   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
3923
3924   Vector3 naturalSize; //Use GetNaturalSize to verify that size of block does not exceed Atlas size
3925   // Create a text editor
3926   TextField textField = TextField::New();
3927
3928   //Set size to avoid automatic eliding
3929   textField.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
3930   textField.SetProperty( TextField::Property::FONT_FAMILY, "DejaVu Sans");
3931   textField.SetProperty( TextField::Property::TEXT, "A");
3932
3933   const int numberOfCases = 6;
3934   int arrayCases[numberOfCases] = {323, 326, 330, 600, 1630, 2500};
3935
3936   for (int index=0; index < numberOfCases; index++)
3937   {
3938     tet_printf(" UtcDaliTextFieldAtlasLimitationIsEnabledPerformanceCases point-size= %d \n", arrayCases[index]);
3939     textField.SetProperty( TextField::Property::POINT_SIZE, arrayCases[index]) ;
3940     application.GetScene().Add( textField );
3941     application.SendNotification();
3942     application.Render();
3943     naturalSize = textField.GetNaturalSize();
3944     DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
3945     DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
3946
3947   }
3948
3949   END_TEST;
3950 }
3951
3952 int UtcDaliToolkitTextFieldEllipsisPositionProperty(void)
3953 {
3954   ToolkitTestApplication application;
3955   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty ");
3956   TextField textField = TextField::New();
3957
3958   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Default is END");
3959   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3960
3961   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START");
3962   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3963   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3964
3965   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE");
3966   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3967   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3968
3969   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END");
3970   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3971   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3972
3973   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to START using integer");
3974   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 1);
3975   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3976
3977   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to MIDDLE using integer");
3978   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 2);
3979   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3980
3981   tet_infoline(" UtcDaliToolkitTextFieldEllipsisPositionProperty - Change to END using integer");
3982   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, 0);
3983   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3984
3985   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3986   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "START");
3987   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
3988
3989   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3990   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "MIDDLE");
3991   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
3992
3993   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3994   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "END");
3995   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
3996
3997   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3998   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "start");
3999   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
4000
4001   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
4002   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "middle");
4003   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
4004
4005   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
4006   textField.SetProperty(DevelTextField::Property::ELLIPSIS_POSITION, "end");
4007   DALI_TEST_EQUALS( textField.GetProperty< int >( DevelTextField::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
4008
4009   END_TEST;
4010 }
4011
4012 int UtcDaliTextFieldCopyText(void)
4013 {
4014   ToolkitTestApplication application;
4015   tet_infoline(" UtcDaliTextFieldCopyText ");
4016
4017   TextField textField = TextField::New();
4018
4019   std::string selectedText = "";
4020   std::string copiedText = "";
4021
4022   application.GetScene().Add( textField );
4023
4024   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4025   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4026   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4027
4028   // Avoid a crash when core load gl resources.
4029   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4030
4031   application.SendNotification();
4032   application.Render();
4033
4034   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4035
4036   application.SendNotification();
4037   application.Render();
4038
4039   // Hello is selected
4040   DevelTextField::SelectText( textField, 0, 5 );
4041
4042   application.SendNotification();
4043   application.Render();
4044
4045   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4046   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4047
4048   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4049   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4050
4051   // Hello is copied
4052   copiedText = DevelTextField::CopyText( textField );
4053   DALI_TEST_EQUALS( "Hello", copiedText, TEST_LOCATION );
4054
4055   // world is selected
4056   DevelTextField::SelectText( textField, 6, 11 );
4057
4058   application.SendNotification();
4059   application.Render();
4060
4061   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4062   DALI_TEST_EQUALS( "world", selectedText, TEST_LOCATION );
4063
4064   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 6, TEST_LOCATION );
4065   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 11, TEST_LOCATION );
4066
4067   // world is copied
4068   copiedText = DevelTextField::CopyText( textField );
4069   DALI_TEST_EQUALS( "world", copiedText, TEST_LOCATION );
4070
4071   // "lo wo" is selected
4072   DevelTextField::SelectText( textField, 3, 8 );
4073
4074   application.SendNotification();
4075   application.Render();
4076
4077   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4078   DALI_TEST_EQUALS( "lo wo", selectedText, TEST_LOCATION );
4079
4080   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 3, TEST_LOCATION );
4081   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 8, TEST_LOCATION );
4082
4083   // "lo wo" is copied
4084   copiedText = DevelTextField::CopyText( textField );
4085   DALI_TEST_EQUALS( "lo wo", copiedText, TEST_LOCATION );
4086
4087   END_TEST;
4088 }
4089
4090 int UtcDaliTextFieldCutText(void)
4091 {
4092   ToolkitTestApplication application;
4093   tet_infoline(" UtcDaliTextFieldCutText ");
4094
4095   TextField textField = TextField::New();
4096
4097   std::string selectedText = "";
4098
4099   application.GetScene().Add( textField );
4100
4101   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4102   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4103   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4104
4105   // Avoid a crash when core load gl resources.
4106   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4107
4108   application.SendNotification();
4109   application.Render();
4110
4111   textField.SetProperty( TextField::Property::TEXT, "Hello world" );
4112
4113   application.SendNotification();
4114   application.Render();
4115
4116   // Hello is selected
4117   DevelTextField::SelectText( textField, 0, 5 );
4118
4119   application.SendNotification();
4120   application.Render();
4121
4122   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4123   DALI_TEST_EQUALS( "Hello", selectedText, TEST_LOCATION );
4124
4125   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4126   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 5, TEST_LOCATION );
4127
4128   // Hello is cut
4129   DALI_TEST_EQUALS( "Hello", DevelTextField::CutText( textField ), TEST_LOCATION );
4130
4131   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), " world", TEST_LOCATION );
4132
4133   // " w" is selected
4134   DevelTextField::SelectText( textField, 0, 2 );
4135
4136   application.SendNotification();
4137   application.Render();
4138
4139   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4140   DALI_TEST_EQUALS( " w", selectedText, TEST_LOCATION );
4141
4142   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 0, TEST_LOCATION );
4143   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4144
4145   // " w" is cut
4146   DALI_TEST_EQUALS( " w", DevelTextField::CutText( textField ), TEST_LOCATION );
4147
4148   application.SendNotification();
4149   application.Render();
4150
4151   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "orld", TEST_LOCATION );
4152
4153   // Test Cut from the middle
4154
4155   // "rl" is selected
4156   DevelTextField::SelectText( textField, 1, 3 );
4157
4158   application.SendNotification();
4159   application.Render();
4160
4161   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4162   DALI_TEST_EQUALS( "rl", selectedText, TEST_LOCATION );
4163
4164   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4165   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 3, TEST_LOCATION );
4166
4167   // "rl" is cut
4168   DALI_TEST_EQUALS( "rl", DevelTextField::CutText( textField ), TEST_LOCATION );
4169
4170   application.SendNotification();
4171   application.Render();
4172
4173   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "od", TEST_LOCATION );
4174
4175   // Test Cut from the end
4176
4177   // "d" is selected
4178   DevelTextField::SelectText( textField, 1, 2 );
4179
4180   application.SendNotification();
4181   application.Render();
4182
4183   selectedText = textField.GetProperty( DevelTextField::Property::SELECTED_TEXT ).Get<std::string>();
4184   DALI_TEST_EQUALS( "d", selectedText, TEST_LOCATION );
4185
4186   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_START ).Get<int>(), 1, TEST_LOCATION );
4187   DALI_TEST_EQUALS( textField.GetProperty( DevelTextField::Property::SELECTED_TEXT_END ).Get<int>(), 2, TEST_LOCATION );
4188
4189   // "d" is cut
4190   DALI_TEST_EQUALS( "d", DevelTextField::CutText( textField ), TEST_LOCATION );
4191
4192   application.SendNotification();
4193   application.Render();
4194
4195   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "o", TEST_LOCATION );
4196
4197   END_TEST;
4198 }
4199
4200 int UtcDaliTextFieldPasteText(void)
4201 {
4202   ToolkitTestApplication application;
4203   tet_infoline(" UtcDaliTextFieldPasteText ");
4204
4205   TextField textField = TextField::New();
4206
4207   application.GetScene().Add( textField );
4208
4209   std::string cutText = "";
4210   std::string copiedText = "";
4211
4212   textField.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
4213   textField.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4214   textField.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4215
4216   // Avoid a crash when core load gl resources.
4217   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4218
4219   application.SendNotification();
4220   application.Render();
4221
4222   textField.SetProperty( TextField::Property::TEXT, "Hello World" );
4223
4224   application.SendNotification();
4225   application.Render();
4226
4227   // Tap on the text editor
4228   TestGenerateTap( application, 3.0f, 25.0f );
4229
4230   // Render and notify
4231   application.SendNotification();
4232   application.Render();
4233
4234   // Select some text in the right of the current cursor position
4235   DevelTextField::SelectText( textField, 0, 3 );
4236
4237   // Render and notify
4238   application.SendNotification();
4239   application.Render();
4240
4241   // Cut the selected text
4242   cutText = DevelTextField::CutText(textField);
4243
4244   // Render and notify
4245   application.SendNotification();
4246   application.Render();
4247
4248   DALI_TEST_EQUALS( "Hel", cutText, TEST_LOCATION );
4249   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo World", TEST_LOCATION );
4250
4251   DevelTextField::SelectText( textField, 0, 3 );
4252
4253   // Render and notify
4254   application.SendNotification();
4255   application.Render();
4256
4257   // Copy the selected text
4258   copiedText = DevelTextField::CopyText(textField);
4259
4260   // Render and notify
4261   application.SendNotification();
4262   application.Render();
4263
4264   DALI_TEST_EQUALS( "lo ", copiedText, TEST_LOCATION );
4265   DALI_TEST_EQUALS( "lo World", textField.GetProperty<std::string>( TextField::Property::TEXT ), TEST_LOCATION );
4266
4267   // Move the cursor to the end of the line
4268   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4269   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4270   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4271   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4272   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4273   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4274   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4275   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4276
4277   // Render and notify
4278   application.SendNotification();
4279   application.Render();
4280
4281   // Paste the selected text at the current cursor position
4282   DevelTextField::PasteText(textField);
4283
4284   // Render and notify
4285   application.SendNotification();
4286   application.Render();
4287
4288   DALI_TEST_EQUALS( textField.GetProperty( TextField::Property::TEXT ).Get<std::string>(), "lo Worldlo ", TEST_LOCATION );
4289
4290   END_TEST;
4291 }
4292 int utcDaliTextFieldCursorPositionChangedSignal(void)
4293 {
4294   ToolkitTestApplication application;
4295   tet_infoline(" utcDaliTextFieldCursorPositionChangedSignal");
4296
4297   TextField field = TextField::New();
4298   DALI_TEST_CHECK( field );
4299
4300   application.GetScene().Add( field );
4301
4302   // connect to the selection changed signal.
4303   ConnectionTracker* testTracker = new ConnectionTracker();
4304   DevelTextField::CursorPositionChangedSignal(field).Connect(&TestCursorPositionChangedCallback);
4305   bool cursorPositionChangedSignal = false;
4306   field.ConnectSignal( testTracker, "cursorPositionChanged",   CallbackFunctor(&cursorPositionChangedSignal) );
4307
4308   field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4309   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4310   field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4311   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4312   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4313
4314   // Avoid a crash when core load gl resources.
4315   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4316
4317   // Render and notify
4318   application.SendNotification();
4319   application.Render();
4320
4321   field.SetKeyInputFocus();
4322
4323   // Tap on the text field
4324   TestGenerateTap( application, 3.0f, 25.0f );
4325
4326   // Render and notify
4327   application.SendNotification();
4328   application.Render();
4329
4330   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4331   DALI_TEST_EQUALS(oldCursorPos, 23, TEST_LOCATION);
4332
4333   gCursorPositionChangedCallbackCalled = false;
4334
4335   // Move to left.
4336   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4337
4338   // Render and notify
4339   application.SendNotification();
4340   application.Render();
4341
4342   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4343   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4344
4345   gCursorPositionChangedCallbackCalled = false;
4346
4347   // Insert D
4348   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4349
4350   // Render and notify
4351   application.SendNotification();
4352   application.Render();
4353
4354   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4355   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4356
4357   gCursorPositionChangedCallbackCalled = false;
4358
4359   //delete one character
4360   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4361
4362   // Render and notify
4363   application.SendNotification();
4364   application.Render();
4365
4366   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4367   DALI_TEST_EQUALS(oldCursorPos, 17, TEST_LOCATION);
4368
4369   gCursorPositionChangedCallbackCalled = false;
4370
4371   field.SetProperty( TextField::Property::TEXT, "Hello" );
4372
4373   // Render and notify
4374   application.SendNotification();
4375   application.Render();
4376
4377   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4378   DALI_TEST_EQUALS(oldCursorPos, 16, TEST_LOCATION);
4379
4380   gCursorPositionChangedCallbackCalled = false;
4381
4382   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4383
4384   // Render and notify
4385   application.SendNotification();
4386   application.Render();
4387
4388   DALI_TEST_CHECK(gCursorPositionChangedCallbackCalled);
4389   DALI_TEST_EQUALS(oldCursorPos, 5, TEST_LOCATION);
4390
4391   END_TEST;
4392 }
4393
4394 int utcDaliTextFieldSelectionClearedSignal(void)
4395 {
4396   ToolkitTestApplication application;
4397   tet_infoline(" utcDaliTextFieldSelectionClearedSignal");
4398
4399   TextField field = TextField::New();
4400   DALI_TEST_CHECK( field );
4401
4402   application.GetScene().Add( field );
4403
4404   // connect to the selection changed signal.
4405   ConnectionTracker* testTracker = new ConnectionTracker();
4406   DevelTextField::SelectionClearedSignal(field).Connect(&TestSelectionClearedCallback);
4407   bool selectionClearedSignal = false;
4408   field.ConnectSignal( testTracker, "selectionCleared",   CallbackFunctor(&selectionClearedSignal) );
4409
4410   field.SetProperty( TextField::Property::TEXT, "Hello\nworld\nHello world" );
4411   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4412   field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4413   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4414   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4415
4416   // Avoid a crash when core load gl resources.
4417   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4418
4419   // Render and notify
4420   application.SendNotification();
4421   application.Render();
4422
4423   // Tap on the text editor
4424   TestGenerateTap( application, 3.0f, 25.0f );
4425
4426   // Render and notify
4427   application.SendNotification();
4428   application.Render();
4429
4430   // Move to second line of the text & Select some text in the right of the current cursor position
4431   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) ); 
4432   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4433
4434   // remove selection
4435   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4436
4437   // Render and notify
4438   application.SendNotification();
4439   application.Render();
4440
4441   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4442
4443   // Render and notify
4444   application.SendNotification();
4445   application.Render();
4446
4447   // Tap on the text editor
4448   TestGenerateTap( application, 3.0f, 25.0f );
4449
4450   // Render and notify
4451   application.SendNotification();
4452   application.Render();
4453
4454   gSelectionClearedCallbackCalled = false;
4455
4456   // Move to second line of the text & select.
4457   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4458   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4459
4460   //remove selection
4461   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4462
4463   // Render and notify
4464   application.SendNotification();
4465   application.Render();
4466
4467   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4468
4469   gSelectionClearedCallbackCalled = false;
4470
4471   // Render and notify
4472   application.SendNotification();
4473   application.Render();
4474
4475   // Move to second line of the text & select.
4476   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_DOWN, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4477   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4478
4479   // replace D with selected text
4480   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4481
4482   // Render and notify
4483   application.SendNotification();
4484   application.Render();
4485
4486   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4487
4488   gSelectionClearedCallbackCalled = false;
4489
4490   // Render and notify
4491   application.SendNotification();
4492   application.Render();
4493
4494   DevelTextField::SelectText( field ,1, 3 );
4495
4496   // Render and notify
4497   application.SendNotification();
4498   application.Render();
4499
4500   field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4501
4502   // Render and notify
4503   application.SendNotification();
4504   application.Render();
4505
4506   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4507
4508   gSelectionClearedCallbackCalled = false;
4509
4510   DevelTextField::SelectText( field ,1, 3 );
4511
4512   // Render and notify
4513   application.SendNotification();
4514   application.Render();
4515
4516   // select none
4517   DevelTextField::SelectNone(field);
4518
4519   // Render and notify
4520   application.SendNotification();
4521   application.Render();
4522
4523   DALI_TEST_CHECK(gSelectionClearedCallbackCalled);
4524
4525   END_TEST;
4526 }
4527
4528 int utcDaliTextFieldSelectionChangedSignal(void)
4529 {
4530   ToolkitTestApplication application;
4531   tet_infoline(" utcDaliTextFieldSelectionChangedSignal");
4532
4533   TextField field = TextField::New();
4534   DALI_TEST_CHECK( field );
4535
4536   application.GetScene().Add( field );
4537
4538   // connect to the selection changed signal.
4539   ConnectionTracker* testTracker = new ConnectionTracker();
4540   DevelTextField::SelectionChangedSignal(field).Connect(&TestSelectionChangedCallback);
4541   bool selectionChangedSignal = false;
4542   field.ConnectSignal( testTracker, "selectionChanged",   CallbackFunctor(&selectionChangedSignal) );
4543
4544   field.SetProperty( TextField::Property::TEXT, "Hello world Hello world" );
4545   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
4546   field.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 50.f ) );
4547   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
4548   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
4549
4550   // Avoid a crash when core load gl resources.
4551   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
4552
4553   // Render and notify
4554   application.SendNotification();
4555   application.Render();
4556
4557   // Tap on the text field
4558   TestGenerateTap( application, 3.0f, 25.0f );
4559
4560   // Render and notify
4561   application.SendNotification();
4562   application.Render();
4563
4564   // Select some text in the right of the current cursor position
4565   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_SHIFT_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4566   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4567
4568   // Render and notify
4569   application.SendNotification();
4570   application.Render();
4571
4572   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4573   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4574
4575   gSelectionChangedCallbackCalled = false;
4576
4577   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, KEY_SHIFT_MODIFIER, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4578
4579   // Render and notify
4580   application.SendNotification();
4581   application.Render();
4582
4583   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4584   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4585   DALI_TEST_EQUALS(oldSelectionEnd, 1, TEST_LOCATION);
4586
4587   gSelectionChangedCallbackCalled = false;
4588
4589   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
4590
4591   // Render and notify
4592   application.SendNotification();
4593   application.Render();
4594
4595   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4596   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4597   DALI_TEST_EQUALS(oldSelectionEnd, 2, TEST_LOCATION);
4598
4599   gSelectionChangedCallbackCalled = false;
4600   field.SetKeyInputFocus();
4601
4602   // Render and notify
4603   application.SendNotification();
4604   application.Render();
4605
4606   DevelTextField::SelectText( field ,0, 5 );
4607
4608   application.SendNotification();
4609   application.Render();
4610
4611   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4612   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4613
4614   gSelectionChangedCallbackCalled = false;
4615
4616   field.SetProperty( DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
4617
4618   // Render and notify
4619   application.SendNotification();
4620   application.Render();
4621
4622   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4623   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4624   DALI_TEST_EQUALS(oldSelectionEnd, 5, TEST_LOCATION);
4625
4626   gSelectionChangedCallbackCalled = false;
4627
4628   // select all text
4629   DevelTextField::SelectWholeText(field);
4630
4631   // Render and notify
4632   application.SendNotification();
4633   application.Render();
4634
4635   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4636   DALI_TEST_EQUALS(oldSelectionStart, oldSelectionEnd, TEST_LOCATION);
4637
4638   gSelectionChangedCallbackCalled = false;
4639
4640   // select none
4641   DevelTextField::SelectNone(field);
4642
4643   // Render and notify
4644   application.SendNotification();
4645   application.Render();
4646
4647   DALI_TEST_CHECK(gSelectionChangedCallbackCalled);
4648   DALI_TEST_EQUALS(oldSelectionStart, 0, TEST_LOCATION);
4649   DALI_TEST_EQUALS(oldSelectionEnd, 23, TEST_LOCATION);
4650
4651   END_TEST;
4652 }