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