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