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