Unregister visual directly when IMAGE have invalid value
[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_ENABLE_FONT_SIZE_SCALE               = "enableFontSizeScale";
113 const char* const PROPERTY_NAME_GRAB_HANDLE_COLOR                    = "grabHandleColor";
114 const char* const PROPERTY_NAME_INPUT_FILTER                         = "inputFilter";
115
116 const Vector4 PLACEHOLDER_TEXT_COLOR( 0.8f, 0.8f, 0.8f, 0.8f );
117 const Dali::Vector4 LIGHT_BLUE( 0.75f, 0.96f, 1.f, 1.f ); // The text highlight color.
118
119 const float RENDER_FRAME_INTERVAL = 16.66f;
120
121 const unsigned int DEFAULT_FONT_SIZE = 1152u;
122 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
123
124 const int KEY_RETURN_CODE = 36;
125 const int KEY_A_CODE = 38;
126 const int KEY_D_CODE = 40;
127 const int KEY_SHIFT_MODIFIER = 257;
128
129 const std::string DEFAULT_DEVICE_NAME("hwKeyboard");
130
131 static bool gSelectionChangedCallbackCalled;
132 static uint32_t oldSelectionStart;
133 static uint32_t oldSelectionEnd;
134 static bool gSelectionClearedCallbackCalled;
135 static bool gAnchorClickedCallBackCalled;
136 static bool gAnchorClickedCallBackNotCalled;
137 static bool gTextChangedCallBackCalled;
138 static bool gMaxCharactersCallBackCalled;
139 static bool gInputFilteredAcceptedCallbackCalled;
140 static bool gInputFilteredRejectedCallbackCalled;
141 static bool gInputStyleChangedCallbackCalled;
142 static bool gCursorPositionChangedCallbackCalled;
143 static uint32_t oldCursorPos;
144 static Dali::Toolkit::TextField::InputStyle::Mask gInputStyleMask;
145
146 static void LoadBitmapResource(TestPlatformAbstraction& platform, int width, int height)
147 {
148   Integration::Bitmap* bitmap = Integration::Bitmap::New( Integration::Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::OWNED_DISCARD );
149   Integration::ResourcePointer resource(bitmap);
150   bitmap->GetPackedPixelsProfile()->ReserveBuffer(Pixel::RGBA8888, width, height, width, height);
151 }
152
153 static void LoadMarkerImages(ToolkitTestApplication& app, TextField textField)
154 {
155   int width(40);
156   int height(40);
157   LoadBitmapResource( app.GetPlatform(), width, height );
158
159   Property::Map propertyMap;
160   propertyMap["filename"] = "image.png";
161   propertyMap["width"] = width;
162   propertyMap["height"] = height;
163   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, propertyMap );
164   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, propertyMap );
165   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, propertyMap );
166   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, propertyMap );
167   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, propertyMap );
168   textField.SetProperty( Toolkit::TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, propertyMap );
169   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_IMAGE, propertyMap );
170   textField.SetProperty( Toolkit::TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, propertyMap );
171 }
172
173 /*
174  * Simulate time passed by.
175  *
176  * @note this will always process at least 1 frame (1/60 sec)
177  *
178  * @param application Test application instance
179  * @param duration Time to pass in milliseconds.
180  * @return The actual time passed in milliseconds
181  */
182 static int Wait(ToolkitTestApplication& application, int duration = 0)
183 {
184   int time = 0;
185
186   for(int i = 0; i <= ( duration / RENDER_FRAME_INTERVAL); i++)
187   {
188     application.SendNotification();
189     application.Render(RENDER_FRAME_INTERVAL);
190     time += RENDER_FRAME_INTERVAL;
191   }
192
193   return time;
194 }
195
196 Dali::Integration::Point GetPointDownInside( Vector2& pos )
197 {
198   Dali::Integration::Point point;
199   point.SetState( PointState::DOWN );
200   point.SetScreenPosition( pos );
201   return point;
202 }
203
204 Dali::Integration::Point GetPointUpInside( Vector2& pos )
205 {
206   Dali::Integration::Point point;
207   point.SetState( PointState::UP );
208   point.SetScreenPosition( pos );
209   return point;
210 }
211
212 struct CallbackFunctor
213 {
214   CallbackFunctor(bool* callbackFlag)
215   : mCallbackFlag( callbackFlag )
216   {
217   }
218
219   void operator()()
220   {
221     *mCallbackFlag = true;
222   }
223   bool* mCallbackFlag;
224 };
225
226 static void TestSelectionClearedCallback(TextField control)
227 {
228   tet_infoline(" TestSelectionClearedCallback");
229
230   gSelectionClearedCallbackCalled = true;
231 }
232
233 static void TestSelectionChangedCallback(TextField control, uint32_t oldStart, uint32_t oldEnd)
234 {
235   tet_infoline(" TestSelectionChangedCallback");
236
237   gSelectionChangedCallbackCalled = true;
238   oldSelectionStart = oldStart;
239   oldSelectionEnd   = oldEnd;
240 }
241
242 static void TestAnchorClickedCallback(TextField control, const char* href, unsigned int hrefLength)
243 {
244   tet_infoline(" TestAnchorClickedCallback");
245
246   gAnchorClickedCallBackNotCalled = false;
247
248   if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
249   {
250     gAnchorClickedCallBackCalled = true;
251   }
252 }
253
254 static void TestCursorPositionChangedCallback( TextField control, unsigned int oldPos )
255 {
256   tet_infoline(" TestCursorPositionChangedCallback");
257
258   gCursorPositionChangedCallbackCalled = true;
259   oldCursorPos = oldPos;
260 }
261
262 static void TestTextChangedCallback( TextField control )
263 {
264   tet_infoline(" TestTextChangedCallback");
265
266   gTextChangedCallBackCalled = true;
267 }
268
269 static void TestMaxLengthReachedCallback( TextField control )
270 {
271   tet_infoline(" TestMaxLengthReachedCallback");
272
273   gMaxCharactersCallBackCalled = true;
274 }
275
276 static void TestInputFilteredCallback(TextField control, Toolkit::InputFilter::Property::Type type)
277 {
278   tet_infoline(" TestInputFilteredCallback");
279
280   if(type == Toolkit::InputFilter::Property::ACCEPTED)
281   {
282     gInputFilteredAcceptedCallbackCalled = true;
283   }
284   else if(type == Toolkit::InputFilter::Property::REJECTED)
285   {
286     gInputFilteredRejectedCallbackCalled = true;
287   }
288 }
289
290 static void TestInputStyleChangedCallback( TextField control, TextField::InputStyle::Mask mask )
291 {
292   tet_infoline(" TestInputStyleChangedCallback");
293
294   gInputStyleChangedCallbackCalled = true;
295   gInputStyleMask = mask;
296 }
297
298 // Generate a KeyEvent to send to Core.
299 Integration::KeyEvent GenerateKey( const std::string& keyName,
300                                    const std::string& logicalKey,
301                                    const std::string& keyString,
302                                    int keyCode,
303                                    int keyModifier,
304                                    unsigned long timeStamp,
305                                    const Integration::KeyEvent::State& keyState,
306                                    const std::string& compose = "",
307                                    const std::string& deviceName = DEFAULT_DEVICE_NAME,
308                                    const Device::Class::Type& deviceClass = Device::Class::NONE,
309                                    const Device::Subclass::Type& deviceSubclass = Device::Subclass::NONE )
310 {
311   return Integration::KeyEvent( keyName,
312                                 logicalKey,
313                                 keyString,
314                                 keyCode,
315                                 keyModifier,
316                                 timeStamp,
317                                 keyState,
318                                 compose,
319                                 deviceName,
320                                 deviceClass,
321                                 deviceSubclass );
322 }
323
324 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
325 {
326   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
327   {
328     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
329     {
330       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
331
332       Property::Value* valueSet = NULL;
333       if ( valueGet.first.type == Property::Key::INDEX )
334       {
335         valueSet = fontStyleMapSet.Find( valueGet.first.indexKey );
336       }
337       else
338       {
339         // Get Key is a string so searching Set Map for a string key
340         valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
341       }
342
343       if( NULL != valueSet )
344       {
345         if( valueSet->GetType() == Dali::Property::STRING && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
346         {
347           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
348           return false;
349         }
350         else if( valueSet->GetType() == Dali::Property::BOOLEAN && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
351         {
352           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
353           return false;
354         }
355         else if( valueSet->GetType() == Dali::Property::INTEGER && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
356         {
357           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
358           return false;
359         }
360         else if( valueSet->GetType() == Dali::Property::FLOAT && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
361         {
362           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
363           return false;
364         }
365         else if( valueSet->GetType() == Dali::Property::VECTOR2 && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
366         {
367           Vector2 vector2Get = valueGet.second.Get<Vector2>();
368           Vector2 vector2Set = valueSet->Get<Vector2>();
369           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
370           return false;
371         }
372         else if( valueSet->GetType() == Dali::Property::VECTOR4 && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
373         {
374           Vector4 vector4Get = valueGet.second.Get<Vector4>();
375           Vector4 vector4Set = valueSet->Get<Vector4>();
376           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 );
377           return false;
378         }
379       }
380       else
381       {
382         if ( valueGet.first.type == Property::Key::INDEX )
383         {
384           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
385         }
386         else
387         {
388           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
389         }
390         return false;
391       }
392     }
393   }
394
395   return true;
396 }
397
398 } // namespace
399
400 int UtcDaliToolkitTextFieldConstructorP(void)
401 {
402   ToolkitTestApplication application;
403   tet_infoline(" UtcDaliToolkitTextFieldConstructorP");
404   TextField textField;
405   DALI_TEST_CHECK( !textField );
406   END_TEST;
407 }
408
409 int UtcDaliToolkitTextFieldNewP(void)
410 {
411   ToolkitTestApplication application;
412   tet_infoline(" UtcDaliToolkitTextFieldNewP");
413   TextField textField = TextField::New();
414   DALI_TEST_CHECK( textField );
415   END_TEST;
416 }
417
418 int UtcDaliToolkitTextFieldDownCastP(void)
419 {
420   ToolkitTestApplication application;
421   tet_infoline(" UtcDaliToolkitTextFieldDownCastP");
422   TextField textField1 = TextField::New();
423   BaseHandle object( textField1 );
424
425   TextField textField2 = TextField::DownCast( object );
426   DALI_TEST_CHECK( textField2 );
427
428   TextField textField3 = DownCast< TextField >( object );
429   DALI_TEST_CHECK( textField3 );
430   END_TEST;
431 }
432
433 int UtcDaliToolkitTextFieldDownCastN(void)
434 {
435   ToolkitTestApplication application;
436   tet_infoline(" UtcDaliToolkitTextFieldDownCastN");
437   BaseHandle uninitializedObject;
438   TextField textField1 = TextField::DownCast( uninitializedObject );
439   DALI_TEST_CHECK( !textField1 );
440
441   TextField textField2 = DownCast< TextField >( uninitializedObject );
442   DALI_TEST_CHECK( !textField2 );
443   END_TEST;
444 }
445
446 int UtcDaliToolkitTextFieldCopyConstructorP(void)
447 {
448   ToolkitTestApplication application;
449   tet_infoline(" UtcDaliToolkitTextFieldCopyConstructorP");
450   TextField textField = TextField::New();
451   textField.SetProperty( TextField::Property::TEXT, "Test" );
452
453   TextField copy( textField );
454   DALI_TEST_CHECK( copy );
455   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextLabel::Property::TEXT ) == textField.GetProperty<std::string>( TextLabel::Property::TEXT ) );
456   END_TEST;
457 }
458
459 int UtcDaliTextFieldMoveConstructor(void)
460 {
461   ToolkitTestApplication application;
462
463   TextField textField = TextField::New();
464   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
465   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
466
467   TextField moved = std::move( textField );
468   DALI_TEST_CHECK( moved );
469   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
470   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
471   DALI_TEST_CHECK( !textField );
472
473   END_TEST;
474 }
475
476 int UtcDaliToolkitTextFieldAssignmentOperatorP(void)
477 {
478   ToolkitTestApplication application;
479   tet_infoline(" UtcDaliToolkitTextFieldAssignmentOperatorP");
480   TextField textField = TextField::New();
481   textField.SetProperty( TextField::Property::TEXT, "Test" );
482
483   TextField copy = textField;
484   DALI_TEST_CHECK( copy );
485   DALI_TEST_CHECK( copy.GetProperty<std::string>( TextField::Property::TEXT ) == textField.GetProperty<std::string>( TextField::Property::TEXT ) );
486   END_TEST;
487 }
488
489 int UtcDaliTextFieldMoveAssignment(void)
490 {
491   ToolkitTestApplication application;
492
493   TextField textField = TextField::New();
494   textField.SetProperty( TextEditor::Property::TEXT, "Test" );
495   DALI_TEST_CHECK( textField.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
496
497   TextField moved;
498   moved = std::move( textField );
499   DALI_TEST_CHECK( moved );
500   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
501   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextField::Property::TEXT ) == "Test" );
502   DALI_TEST_CHECK( !textField );
503
504   END_TEST;
505 }
506
507 int UtcDaliTextFieldNewP(void)
508 {
509   ToolkitTestApplication application;
510   tet_infoline(" UtcDaliToolkitTextFieldNewP");
511   TextField textField = TextField::New();
512   DALI_TEST_CHECK( textField );
513   END_TEST;
514 }
515
516 // Positive test case for a method
517 int UtcDaliTextFieldGetPropertyP(void)
518 {
519   ToolkitTestApplication application;
520   tet_infoline(" UtcDaliToolkitTextFieldGetPropertyP");
521   TextField field = TextField::New();
522   DALI_TEST_CHECK( field );
523
524   // Check Property Indices are correct
525   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextField::Property::RENDERING_BACKEND );
526   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextField::Property::TEXT );
527   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT ) == TextField::Property::PLACEHOLDER_TEXT );
528   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_FOCUSED ) == TextField::Property::PLACEHOLDER_TEXT_FOCUSED );
529   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextField::Property::FONT_FAMILY );
530   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextField::Property::FONT_STYLE );
531   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextField::Property::POINT_SIZE );
532   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MAX_LENGTH ) == TextField::Property::MAX_LENGTH );
533   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EXCEED_POLICY ) == TextField::Property::EXCEED_POLICY );
534   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextField::Property::HORIZONTAL_ALIGNMENT );
535   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextField::Property::VERTICAL_ALIGNMENT );
536   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextField::Property::TEXT_COLOR );
537   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER_TEXT_COLOR ) == TextField::Property::PLACEHOLDER_TEXT_COLOR );
538   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PRIMARY_CURSOR_COLOR ) == TextField::Property::PRIMARY_CURSOR_COLOR );
539   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SECONDARY_CURSOR_COLOR ) == TextField::Property::SECONDARY_CURSOR_COLOR );
540   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_CURSOR_BLINK ) == TextField::Property::ENABLE_CURSOR_BLINK );
541   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_INTERVAL ) == TextField::Property::CURSOR_BLINK_INTERVAL );
542   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_BLINK_DURATION ) == TextField::Property::CURSOR_BLINK_DURATION );
543   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_CURSOR_WIDTH ) == TextField::Property::CURSOR_WIDTH );
544   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_IMAGE ) == TextField::Property::GRAB_HANDLE_IMAGE );
545   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_PRESSED_IMAGE ) == TextField::Property::GRAB_HANDLE_PRESSED_IMAGE );
546   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_THRESHOLD ) == TextField::Property::SCROLL_THRESHOLD );
547   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SCROLL_SPEED ) == TextField::Property::SCROLL_SPEED );
548   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_IMAGE_LEFT );
549   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT );
550   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT );
551   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_PRESSED_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT );
552   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_LEFT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT );
553   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HANDLE_MARKER_IMAGE_RIGHT ) == TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT );
554   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SELECTION_HIGHLIGHT_COLOR ) == TextField::Property::SELECTION_HIGHLIGHT_COLOR );
555   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_DECORATION_BOUNDING_BOX ) == TextField::Property::DECORATION_BOUNDING_BOX );
556   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_METHOD_SETTINGS ) == TextField::Property::INPUT_METHOD_SETTINGS );
557   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_COLOR ) == TextField::Property::INPUT_COLOR );
558   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP ) == TextField::Property::ENABLE_MARKUP );
559   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_FAMILY ) == TextField::Property::INPUT_FONT_FAMILY );
560   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FONT_STYLE ) == TextField::Property::INPUT_FONT_STYLE );
561   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_POINT_SIZE ) == TextField::Property::INPUT_POINT_SIZE );
562   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextField::Property::UNDERLINE );
563   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_UNDERLINE ) == TextField::Property::INPUT_UNDERLINE );
564   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextField::Property::SHADOW );
565   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_SHADOW ) == TextField::Property::INPUT_SHADOW );
566   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextField::Property::EMBOSS );
567   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_EMBOSS ) == TextField::Property::INPUT_EMBOSS );
568   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextField::Property::OUTLINE );
569   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_OUTLINE ) == TextField::Property::INPUT_OUTLINE );
570   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_HIDDEN_INPUT_SETTINGS ) == TextField::Property::HIDDEN_INPUT_SETTINGS );
571   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextField::Property::PIXEL_SIZE );
572   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SELECTION ) == TextField::Property::ENABLE_SELECTION );
573   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_PLACEHOLDER ) == TextField::Property::PLACEHOLDER );
574   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextField::Property::ELLIPSIS );
575   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextField::Property::FONT_SIZE_SCALE );
576   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE ) == DevelTextField::Property::ENABLE_FONT_SIZE_SCALE );
577   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_SHIFT_SELECTION ) == DevelTextField::Property::ENABLE_SHIFT_SELECTION );
578   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE ) == DevelTextField::Property::ENABLE_GRAB_HANDLE );
579   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_MATCH_SYSTEM_LANGUAGE_DIRECTION ) == DevelTextField::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION );
580   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_ENABLE_GRAB_HANDLE_POPUP ) == DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP );
581   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextField::Property::BACKGROUND );
582   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_GRAB_HANDLE_COLOR ) == DevelTextField::Property::GRAB_HANDLE_COLOR );
583   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_FILTER ) == DevelTextField::Property::INPUT_FILTER );
584   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextField::Property::STRIKETHROUGH );
585   DALI_TEST_CHECK( field.GetPropertyIndex( PROPERTY_NAME_INPUT_STRIKETHROUGH ) == DevelTextField::Property::INPUT_STRIKETHROUGH );
586
587   END_TEST;
588 }
589
590 bool SetPropertyMapRetrieved( TextField& field, const Property::Index property, const std::string mapKey, const std::string mapValue )
591 {
592   bool result = false;
593   Property::Map imageMap;
594   imageMap[mapKey] =mapValue;
595
596   field.SetProperty( property , imageMap );
597   Property::Value propValue = field.GetProperty( property );
598   Property::Map* resultMap = propValue.GetMap();
599
600   if ( resultMap->Find( mapKey )->Get< std::string>() == mapValue )
601   {
602     result = true;
603   }
604
605   return result;
606 }
607
608 // Positive test case for a method
609 int UtcDaliTextFieldSetPropertyP(void)
610 {
611   ToolkitTestApplication application;
612   tet_infoline(" UtcDaliToolkitTextFieldSetPropertyP");
613   TextField field = TextField::New();
614   DALI_TEST_CHECK( field );
615   application.GetScene().Add( field );
616
617   // Note - we can't check the defaults since the stylesheets are platform-specific
618
619   // Check the render backend property.
620   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
621   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
622
623   field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
624   DALI_TEST_EQUALS( (DevelText::RenderingType)field.GetProperty<int>( DevelTextField::Property::RENDERING_BACKEND ), DevelText::RENDERING_VECTOR_BASED, TEST_LOCATION );
625
626   // Check text property.
627   field.SetProperty( TextField::Property::TEXT, "Setting Text" );
628   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
629
630   // Check placeholder text properties.
631   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
632   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT ), std::string("Setting Placeholder Text"), TEST_LOCATION );
633
634   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_FOCUSED, "Setting Placeholder Text Focused" );
635   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::PLACEHOLDER_TEXT_FOCUSED ), std::string("Setting Placeholder Text Focused"), TEST_LOCATION );
636
637   // Check font properties.
638   field.SetProperty( TextField::Property::FONT_FAMILY, "Setting font family" );
639   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
640
641   Property::Map fontStyleMapSet;
642   Property::Map fontStyleMapGet;
643   Property::Value* slantValue = NULL;
644
645   fontStyleMapSet.Insert( "weight", "bold" );
646   fontStyleMapSet.Insert( "width", "condensed" );
647   fontStyleMapSet.Insert( "slant", "italic" );
648   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
649
650   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
651   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
652   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
653
654   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
655   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
656
657   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 2.5f );
658   DALI_TEST_EQUALS( field.GetProperty<float>( DevelTextField::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
659   field.SetProperty( DevelTextField::Property::FONT_SIZE_SCALE, 1.0f );
660
661   field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, false );
662   DALI_TEST_EQUALS( field.GetProperty<bool>( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE ), false, TEST_LOCATION );
663   field.SetProperty( DevelTextField::Property::ENABLE_FONT_SIZE_SCALE, true );
664
665   // Reset font style.
666   fontStyleMapSet.Clear();
667   fontStyleMapSet.Insert( "weight", "normal" );
668   fontStyleMapSet.Insert( "slant", "oblique" );
669   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
670
671   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
672   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
673   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
674
675   fontStyleMapSet.Clear();
676   fontStyleMapSet.Insert( "slant", "roman" );
677   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
678   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
679
680   // Replace 'roman' for 'normal'.
681   slantValue = fontStyleMapGet.Find( "slant" );
682   if( NULL != slantValue )
683   {
684     if( "normal" == slantValue->Get<std::string>() )
685     {
686       fontStyleMapGet["slant"] = "roman";
687     }
688   }
689   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
690   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
691
692   fontStyleMapSet.Clear();
693
694   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
695   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
696   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
697   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
698
699   // Check that the MAX_LENGTH property can be correctly set
700   const int maxNumberOfCharacters = 20;
701   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
702   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::MAX_LENGTH ), maxNumberOfCharacters, TEST_LOCATION );
703
704   // Check exceed policy
705   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_CLIP );
706   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_CLIP ), TEST_LOCATION );
707   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
708   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::EXCEED_POLICY ), static_cast<int>( Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL ), TEST_LOCATION );
709
710   // Check that the Alignment properties can be correctly set
711   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "END" );
712   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::HORIZONTAL_ALIGNMENT ), "END", TEST_LOCATION );
713   field.SetProperty( TextField::Property::VERTICAL_ALIGNMENT, "CENTER" );
714   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
715
716   // Check text's color property
717   field.SetProperty( TextField::Property::TEXT_COLOR, Color::WHITE );
718   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::WHITE, TEST_LOCATION );
719
720   // Check placeholder text's color property.
721   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT_COLOR, Color::RED );
722   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PLACEHOLDER_TEXT_COLOR ), Color::RED, TEST_LOCATION );
723
724   // Check cursor properties
725   field.SetProperty( TextField::Property::PRIMARY_CURSOR_COLOR, Color::RED );
726   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::PRIMARY_CURSOR_COLOR ), Color::RED, TEST_LOCATION );
727   field.SetProperty( TextField::Property::SECONDARY_CURSOR_COLOR, Color::BLUE );
728   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SECONDARY_CURSOR_COLOR ), Color::BLUE, TEST_LOCATION );
729
730   field.SetProperty( TextField::Property::ENABLE_CURSOR_BLINK, false );
731   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_CURSOR_BLINK ), false, TEST_LOCATION );
732   field.SetProperty( TextField::Property::CURSOR_BLINK_INTERVAL, 1.f );
733   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_INTERVAL ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
734   field.SetProperty( TextField::Property::CURSOR_BLINK_DURATION, 10.f );
735   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::CURSOR_BLINK_DURATION ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
736   field.SetProperty( TextField::Property::CURSOR_WIDTH, 1 );
737   DALI_TEST_EQUALS( field.GetProperty<int>( TextField::Property::CURSOR_WIDTH ), 1, TEST_LOCATION );
738
739   // Check scroll properties.
740   field.SetProperty( TextField::Property::SCROLL_THRESHOLD, 1.f );
741   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_THRESHOLD ), 1.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
742   field.SetProperty( TextField::Property::SCROLL_SPEED, 100.f );
743   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::SCROLL_SPEED ), 100.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
744
745   // Check handle images
746   field.SetProperty( TextField::Property::GRAB_HANDLE_IMAGE, "image1" );
747   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_IMAGE ), "image1", TEST_LOCATION );
748   field.SetProperty( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE, "image2" );
749   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::GRAB_HANDLE_PRESSED_IMAGE ), "image2", TEST_LOCATION );
750   field.SetProperty( TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "image3" );
751
752   // Check handle images
753   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_LEFT, "filename", "leftHandleImage" )  );
754   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_IMAGE_RIGHT, "filename", "rightHandleImage" )  );
755   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_LEFT, "filename", "leftHandleImagePressed" )  );
756   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_PRESSED_IMAGE_RIGHT, "filename", "rightHandleImagePressed" )  );
757   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_LEFT, "filename", "leftHandleMarkerImage" )  );
758   DALI_TEST_CHECK( SetPropertyMapRetrieved( field, TextField::Property::SELECTION_HANDLE_MARKER_IMAGE_RIGHT, "filename", "rightHandleMarkerImage" )  );
759
760   // Check the highlight color
761   field.SetProperty( TextField::Property::SELECTION_HIGHLIGHT_COLOR, Color::GREEN );
762   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::SELECTION_HIGHLIGHT_COLOR ), Color::GREEN, TEST_LOCATION );
763
764   // Decoration bounding box
765   field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect<int>( 0, 0, 1, 1 ) );
766   DALI_TEST_EQUALS( field.GetProperty<Rect <int > >( TextField::Property::DECORATION_BOUNDING_BOX ), Rect<int>( 0, 0, 1, 1 ), TEST_LOCATION );
767
768   // Check the input method setting
769   Property::Map propertyMap;
770   InputMethod::PanelLayout::Type panelLayout = InputMethod::PanelLayout::NUMBER;
771   InputMethod::AutoCapital::Type autoCapital = InputMethod::AutoCapital::WORD;
772   InputMethod::ButtonAction::Type buttonAction = InputMethod::ButtonAction::GO;
773   int inputVariation = 1;
774   propertyMap["PANEL_LAYOUT"] = panelLayout;
775   propertyMap["AUTO_CAPITALIZE"] = autoCapital;
776   propertyMap["BUTTON_ACTION"] = buttonAction;
777   propertyMap["VARIATION"] = inputVariation;
778   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
779
780   Property::Value value = field.GetProperty( TextField::Property::INPUT_METHOD_SETTINGS );
781   Property::Map map;
782   DALI_TEST_CHECK( value.Get( map ) );
783
784   int layout = 0;
785   DALI_TEST_CHECK( map[ "PANEL_LAYOUT" ].Get( layout ) );
786   DALI_TEST_EQUALS( static_cast<int>(panelLayout), layout, TEST_LOCATION );
787
788   int capital = 0;
789   DALI_TEST_CHECK( map[ "AUTO_CAPITALIZE" ].Get( capital ) );
790   DALI_TEST_EQUALS( static_cast<int>(autoCapital), capital, TEST_LOCATION );
791
792   int action = 0;
793   DALI_TEST_CHECK( map[ "BUTTON_ACTION" ].Get( action ) );
794   DALI_TEST_EQUALS( static_cast<int>(buttonAction), action, TEST_LOCATION );
795
796   int variation = 0;
797   DALI_TEST_CHECK( map[ "VARIATION" ].Get( variation ) );
798   DALI_TEST_EQUALS( inputVariation, variation, TEST_LOCATION );
799
800   // Check input color property.
801   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
802   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::INPUT_COLOR ), Color::YELLOW, TEST_LOCATION );
803
804   // Check the enable markup property.
805   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
806   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
807   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ENABLE_MARKUP ) );
808
809   // Check input font properties.
810   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
811   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
812
813   fontStyleMapSet.Clear();
814   fontStyleMapSet.Insert( "weight", "bold" );
815   fontStyleMapSet.Insert( "width", "condensed" );
816   fontStyleMapSet.Insert( "slant", "italic" );
817
818   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
819   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
820   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
821   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
822
823   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
824   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
825
826   // Reset input font style.
827   fontStyleMapSet.Clear();
828   fontStyleMapSet.Insert( "weight", "normal" );
829   fontStyleMapSet.Insert( "slant", "oblique" );
830
831   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
832   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
833   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
834   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
835
836   fontStyleMapSet.Clear();
837   fontStyleMapSet.Insert( "slant", "roman" );
838
839   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
840   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
841
842   // Replace 'roman' for 'normal'.
843   slantValue = fontStyleMapGet.Find( "slant" );
844   if( NULL != slantValue )
845   {
846     if( "normal" == slantValue->Get<std::string>() )
847     {
848       fontStyleMapGet["slant"] = "roman";
849     }
850   }
851   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
852   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
853
854   fontStyleMapSet.Clear();
855
856   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
857   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
858   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
859   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
860
861   Property::Map strikethroughMapSet;
862   Property::Map strikethroughMapGet;
863
864   strikethroughMapSet.Insert( "enable", true );
865   strikethroughMapSet.Insert( "color", Color::RED );
866   strikethroughMapSet.Insert( "height", 2.0f );
867
868   // Check the strikethrough property
869   field.SetProperty( DevelTextField::Property::STRIKETHROUGH, strikethroughMapSet );
870
871   strikethroughMapGet = field.GetProperty<Property::Map>( DevelTextField::Property::STRIKETHROUGH );
872   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
873   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
874
875   // Check the input strikethrough property
876   field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "Strikethrough input properties" );
877   DALI_TEST_EQUALS( field.GetProperty<std::string>( DevelTextField::Property::INPUT_STRIKETHROUGH ), std::string("Strikethrough input properties"), TEST_LOCATION );
878
879   Property::Map underlineMapSet;
880   Property::Map underlineMapGet;
881
882   underlineMapSet.Insert( "enable", true );
883   underlineMapSet.Insert( "color", Color::RED );
884   underlineMapSet.Insert( "height", 1 );
885
886   // Check the underline property
887   field.SetProperty( TextField::Property::UNDERLINE, underlineMapSet );
888
889   underlineMapGet = field.GetProperty<Property::Map>( TextField::Property::UNDERLINE );
890   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
891   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
892
893   // Check the input underline property
894   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "Underline input properties" );
895   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_UNDERLINE ), std::string("Underline input properties"), TEST_LOCATION );
896
897   // Check the shadow property
898   Property::Map shadowMapSet;
899   Property::Map shadowMapGet;
900
901   shadowMapSet.Insert( "color", Color::GREEN );
902   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
903   shadowMapSet.Insert( "blurRadius", 3.0f );
904
905   field.SetProperty( TextField::Property::SHADOW, shadowMapSet );
906
907   shadowMapGet = field.GetProperty<Property::Map>( TextField::Property::SHADOW );
908   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
909   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
910
911   // Check the input shadow property
912   field.SetProperty( TextField::Property::INPUT_SHADOW, "Shadow input properties" );
913   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_SHADOW ), std::string("Shadow input properties"), TEST_LOCATION );
914
915   // Check the emboss property
916   field.SetProperty( TextField::Property::EMBOSS, "Emboss properties" );
917   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
918
919   // Check the input emboss property
920   field.SetProperty( TextField::Property::INPUT_EMBOSS, "Emboss input properties" );
921   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_EMBOSS ), std::string("Emboss input properties"), TEST_LOCATION );
922
923   // Check the outline property
924
925   // Test string type first
926   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
927   field.SetProperty( TextField::Property::OUTLINE, "Outline properties" );
928   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
929
930   // Then test the property map type
931   Property::Map outlineMapSet;
932   Property::Map outlineMapGet;
933
934   outlineMapSet["color"] = Color::RED;
935   outlineMapSet["width"] = 2.0f;
936
937   field.SetProperty( TextField::Property::OUTLINE, outlineMapSet );
938
939   outlineMapGet = field.GetProperty<Property::Map>( TextField::Property::OUTLINE );
940   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
941   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
942
943   // Check the input outline property
944   field.SetProperty( TextField::Property::INPUT_OUTLINE, "Outline input properties" );
945   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_OUTLINE ), std::string("Outline input properties"), TEST_LOCATION );
946
947   // Check the hidden input settings property
948   Property::Map hiddenMapSet;
949   Property::Map hiddenMapGet;
950   hiddenMapSet[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
951   hiddenMapSet[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 2;
952   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 4;
953   hiddenMapSet[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
954   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, hiddenMapSet );
955
956   hiddenMapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
957   DALI_TEST_EQUALS( hiddenMapSet.Count(), hiddenMapGet.Count(), TEST_LOCATION );
958   DALI_TEST_EQUALS( DaliTestCheckMaps( hiddenMapSet, hiddenMapGet ), true, TEST_LOCATION );
959
960   // Check the pixel size of font
961   field.SetProperty( TextField::Property::PIXEL_SIZE, 20.f );
962   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
963
964   // Check the enable selection property
965   field.SetProperty( TextField::Property::ENABLE_SELECTION, false );
966   DALI_TEST_EQUALS( field.GetProperty<bool>( TextField::Property::ENABLE_SELECTION ), false, TEST_LOCATION );
967
968   // Check the placeholder property with pixel size
969   Property::Map placeholderPixelSizeMapSet;
970   Property::Map placeholderPixelSizeMapGet;
971   Property::Map placeholderFontstyleMap;
972   placeholderPixelSizeMapSet["text"] = "Setting Placeholder Text";
973   placeholderPixelSizeMapSet["textFocused"] = "Setting Placeholder Text Focused";
974   placeholderPixelSizeMapSet["color"] = Color::BLUE;
975   placeholderPixelSizeMapSet["fontFamily"] = "Arial";
976   placeholderPixelSizeMapSet["pixelSize"] = 15.0f;
977   placeholderPixelSizeMapSet["ellipsis"] = true;
978
979   placeholderFontstyleMap.Insert( "weight", "bold" );
980   placeholderPixelSizeMapSet["placeholderFontStyle"] = placeholderFontstyleMap;
981   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderPixelSizeMapSet );
982
983   placeholderPixelSizeMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
984   DALI_TEST_EQUALS( placeholderPixelSizeMapGet.Count(), placeholderPixelSizeMapSet.Count(), TEST_LOCATION );
985
986   tet_infoline("Test Placeholder settings set as strings is converted correctly to Property Index key and holds set value");
987   Property::Map placeholderConversionMap;
988   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
989   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
990   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
991   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
992   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
993   placeholderConversionMap[ Text::PlaceHolder::Property::PIXEL_SIZE ] = placeholderPixelSizeMapSet["pixelSize"];
994
995   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderPixelSizeMapGet, placeholderConversionMap ), true, TEST_LOCATION );
996
997   // Check the placeholder property with point size
998   Property::Map placeholderMapSet;
999   Property::Map placeholderMapGet;
1000   placeholderMapSet["text"] = "Setting Placeholder Text";
1001   placeholderMapSet["textFocused"] = "Setting Placeholder Text Focused";
1002   placeholderMapSet["color"] = Color::RED;
1003   placeholderMapSet["fontFamily"] = "Arial";
1004   placeholderMapSet["pointSize"] = 12.0f;
1005   placeholderMapSet["ellipsis"] = false;
1006
1007   // Check the placeholder font style property
1008   placeholderFontstyleMap.Clear();
1009
1010   placeholderFontstyleMap.Insert( "weight", "bold" );
1011   placeholderFontstyleMap.Insert( "width", "condensed" );
1012   placeholderFontstyleMap.Insert( "slant", "italic" );
1013   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1014   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1015
1016   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1017   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1018
1019   placeholderConversionMap.Clear();
1020   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT ] = placeholderPixelSizeMapSet["text"];
1021   placeholderConversionMap[ Text::PlaceHolder::Property::TEXT_FOCUSED ] = placeholderPixelSizeMapSet["textFocused"] ;
1022   placeholderConversionMap[ Text::PlaceHolder::Property::COLOR ] = placeholderPixelSizeMapSet["color"];
1023   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1024   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_FAMILY ] = placeholderPixelSizeMapSet["fontFamily"];
1025   placeholderConversionMap[ Text::PlaceHolder::Property::POINT_SIZE ] = placeholderPixelSizeMapSet["pointSize"];
1026
1027   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1028
1029   // Reset font style.
1030   placeholderFontstyleMap.Clear();
1031   placeholderFontstyleMap.Insert( "weight", "normal" );
1032   placeholderFontstyleMap.Insert( "slant", "oblique" );
1033   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1034   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1035
1036   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1037   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1038
1039   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1040   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1041
1042   placeholderFontstyleMap.Clear();
1043   placeholderFontstyleMap.Insert( "slant", "roman" );
1044   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1045   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1046
1047   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1048
1049   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1050
1051   placeholderFontstyleMap.Clear();
1052   placeholderMapSet["fontStyle"] = placeholderFontstyleMap;
1053   placeholderConversionMap[ Text::PlaceHolder::Property::FONT_STYLE ] = placeholderPixelSizeMapSet["fontStyle"];
1054
1055   field.SetProperty( TextField::Property::PLACEHOLDER, placeholderMapSet );
1056   placeholderMapGet = field.GetProperty<Property::Map>( TextField::Property::PLACEHOLDER );
1057   DALI_TEST_EQUALS( placeholderMapGet.Count(), placeholderMapSet.Count(), TEST_LOCATION );
1058
1059   DALI_TEST_EQUALS( DaliTestCheckMaps( placeholderMapGet, placeholderConversionMap ), true, TEST_LOCATION );
1060
1061   // Check the ellipsis property
1062   DALI_TEST_CHECK( !field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1063   field.SetProperty( TextField::Property::ELLIPSIS, true );
1064   DALI_TEST_CHECK( field.GetProperty<bool>( TextField::Property::ELLIPSIS ) );
1065
1066   field.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
1067   DALI_TEST_EQUALS( field.GetProperty<int>( Actor::Property::LAYOUT_DIRECTION ), static_cast<int>( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1068
1069   // Test the ENABLE_GRAB_HANDLE_POPUP property
1070   DALI_TEST_CHECK( field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1071   field.SetProperty( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP, false );
1072   DALI_TEST_CHECK( !field.GetProperty<bool>( DevelTextField::Property::ENABLE_GRAB_HANDLE_POPUP ) );
1073
1074   // Check the background property
1075   field.SetProperty( DevelTextField::Property::BACKGROUND, Color::RED );
1076   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::BACKGROUND ), Color::RED, TEST_LOCATION );
1077
1078   //Check handle color
1079   field.SetProperty( DevelTextField::Property::GRAB_HANDLE_COLOR, Color::GREEN );
1080   DALI_TEST_EQUALS( field.GetProperty<Vector4>( DevelTextField::Property::GRAB_HANDLE_COLOR ), Color::GREEN, TEST_LOCATION );
1081
1082   // Check the input filter property
1083   Property::Map inputFilterMapSet;
1084   Property::Map inputFilterMapGet;
1085   inputFilterMapSet[InputFilter::Property::ACCEPTED] = "[\\w]";
1086   inputFilterMapSet[InputFilter::Property::REJECTED] = "[\\d]";
1087
1088   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1089
1090   inputFilterMapGet = field.GetProperty<Property::Map>(DevelTextField::Property::INPUT_FILTER);
1091   DALI_TEST_EQUALS(inputFilterMapGet.Count(), inputFilterMapSet.Count(), TEST_LOCATION);
1092
1093   // Clear
1094   inputFilterMapSet.Clear();
1095   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilterMapSet);
1096
1097   application.SendNotification();
1098   application.Render();
1099
1100   END_TEST;
1101 }
1102
1103 // Positive Atlas Text Renderer test
1104 int utcDaliTextFieldAtlasRenderP(void)
1105 {
1106   ToolkitTestApplication application;
1107   tet_infoline(" UtcDaliToolkitTextFieldAtlasRenderP");
1108   StyleManager styleManager = StyleManager::Get();
1109   styleManager.ApplyDefaultTheme();
1110   TextField field = TextField::New();
1111   DALI_TEST_CHECK( field );
1112
1113   field.SetProperty( TextField::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1114
1115   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1116
1117   application.GetScene().Add( field );
1118
1119   try
1120   {
1121     // Render some text with the shared atlas backend
1122     field.SetProperty( DevelTextField::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
1123     application.SendNotification();
1124     application.Render();
1125   }
1126   catch( ... )
1127   {
1128     tet_result(TET_FAIL);
1129   }
1130   END_TEST;
1131 }
1132
1133 // Positive test for the anchorClicked signal.
1134 int utcDaliTextFieldAnchorClicked01(void)
1135 {
1136   ToolkitTestApplication application;
1137   tet_infoline(" utcDaliTextFieldAnchorClicked01");
1138   TextField field = TextField::New();
1139   DALI_TEST_CHECK(field);
1140
1141   application.GetScene().Add(field);
1142
1143   // connect to the anchor clicked signal.
1144   ConnectionTracker* testTracker = new ConnectionTracker();
1145   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1146   bool anchorClickedSignal = false;
1147   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1148
1149   gAnchorClickedCallBackCalled = false;
1150   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1151   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1152   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1153   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1154   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1155
1156   application.SendNotification();
1157   application.Render();
1158   field.SetKeyInputFocus();
1159
1160   // Create a tap event to touch the text field.
1161   TestGenerateTap(application, 5.0f, 25.0f);
1162   application.SendNotification();
1163   application.Render();
1164
1165   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1166   DALI_TEST_CHECK(anchorClickedSignal);
1167
1168   gAnchorClickedCallBackNotCalled = true;
1169   // Tap the outside of anchor, callback should not be called.
1170   TestGenerateTap(application, 150.f, 100.f);
1171   application.SendNotification();
1172   application.Render();
1173
1174   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1175
1176   END_TEST;
1177 }
1178
1179 // Positive test for the anchorClicked signal.
1180 int utcDaliTextFieldAnchorClicked02(void)
1181 {
1182   ToolkitTestApplication application;
1183   tet_infoline(" utcDaliTextFieldAnchorClicked02");
1184   TextField field = TextField::New();
1185   DALI_TEST_CHECK(field);
1186
1187   application.GetScene().Add(field);
1188
1189   // connect to the anchor clicked signal.
1190   ConnectionTracker* testTracker = new ConnectionTracker();
1191   DevelTextField::AnchorClickedSignal(field).Connect(&TestAnchorClickedCallback);
1192   bool anchorClickedSignal = false;
1193   field.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1194
1195   gAnchorClickedCallBackCalled = false;
1196   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1197   field.SetProperty(TextField::Property::ENABLE_MARKUP, true);
1198   field.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1199   field.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1200   field.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1201
1202   application.SendNotification();
1203   application.Render();
1204   field.SetKeyInputFocus();
1205
1206   // Avoid a crash when core load gl resources.
1207   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1208
1209   // Create a tap event to touch the text field.
1210   TestGenerateTap(application, 30.0f, 25.0f, 100);
1211   application.SendNotification();
1212   application.Render();
1213
1214   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1215   DALI_TEST_CHECK(anchorClickedSignal);
1216
1217
1218   // For coverage InsertTextAnchor, RemoveTextAnchor
1219   // first index insert
1220   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1221   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1222   application.SendNotification();
1223   application.Render();
1224
1225   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1226   application.SendNotification();
1227   application.Render();
1228
1229   gAnchorClickedCallBackCalled = false;
1230   // Create a tap event to touch the text field.
1231   TestGenerateTap(application, 30.0f, 25.0f, 700);
1232   application.SendNotification();
1233   field.SetKeyInputFocus();
1234
1235   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1236
1237   // last index insert
1238   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1239   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1240   application.SendNotification();
1241   application.Render();
1242
1243   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1244   application.SendNotification();
1245   application.Render();
1246
1247   gAnchorClickedCallBackCalled = false;
1248   // Create a tap event to touch the text field.
1249   TestGenerateTap(application, 30.0f, 25.0f, 1300);
1250   application.SendNotification();
1251   field.SetKeyInputFocus();
1252
1253   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1254
1255   // mid index insert
1256   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1257   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1258   application.SendNotification();
1259   application.Render();
1260
1261   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1262   application.SendNotification();
1263   application.Render();
1264
1265   gAnchorClickedCallBackCalled = false;
1266   // Create a tap event to touch the text field.
1267   TestGenerateTap(application, 30.0f, 25.0f, 1900);
1268   application.SendNotification();
1269   field.SetKeyInputFocus();
1270
1271   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1272
1273   // first index remove
1274   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1275   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1276   application.SendNotification();
1277   application.Render();
1278
1279   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1280   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));
1281   application.SendNotification();
1282   application.Render();
1283
1284   gAnchorClickedCallBackCalled = false;
1285   // Create a tap event to touch the text field.
1286   TestGenerateTap(application, 30.0f, 25.0f, 2500);
1287   application.SendNotification();
1288   field.SetKeyInputFocus();
1289
1290   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1291
1292   // last index remove
1293   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1294   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 5);
1295   application.SendNotification();
1296   application.Render();
1297
1298   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1299   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));
1300   application.SendNotification();
1301   application.Render();
1302
1303   gAnchorClickedCallBackCalled = false;
1304   // Create a tap event to touch the text field.
1305   TestGenerateTap(application, 30.0f, 25.0f, 3100);
1306   application.SendNotification();
1307   application.Render();
1308
1309   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1310
1311   // middle index
1312   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1313   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 2);
1314   application.SendNotification();
1315   application.Render();
1316
1317   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1318   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));
1319   application.SendNotification();
1320   application.Render();
1321
1322   gAnchorClickedCallBackCalled = false;
1323   // Create a tap event to touch the text field.
1324   TestGenerateTap(application, 30.0f, 25.0f, 3700);
1325   application.SendNotification();
1326   application.Render();
1327
1328   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1329
1330   // 0 ~ 1 index remove
1331   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1332   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 0);
1333   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 1);
1334   application.SendNotification();
1335   application.Render();
1336
1337   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1338   application.SendNotification();
1339   application.Render();
1340
1341   gAnchorClickedCallBackCalled = false;
1342   // Create a tap event to touch the text field.
1343   TestGenerateTap(application, 30.0f, 25.0f, 4300);
1344   application.SendNotification();
1345   application.Render();
1346
1347   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1348
1349   // 1 ~ 3 index remove
1350   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1351   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 1);
1352   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 3);
1353   application.SendNotification();
1354   application.Render();
1355
1356   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1357   application.SendNotification();
1358   application.Render();
1359
1360   gAnchorClickedCallBackCalled = false;
1361   // Create a tap event to touch the text field.
1362   TestGenerateTap(application, 30.0f, 25.0f, 4900);
1363   application.SendNotification();
1364   application.Render();
1365
1366   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1367
1368   // 3 ~ 4 index remove
1369   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1370   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_START, 3);
1371   field.SetProperty( DevelTextField::Property::SELECTED_TEXT_END, 4);
1372   application.SendNotification();
1373   application.Render();
1374
1375   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1376   application.SendNotification();
1377   application.Render();
1378
1379   gAnchorClickedCallBackCalled = false;
1380   // Create a tap event to touch the text field.
1381   TestGenerateTap(application, 30.0f, 25.0f, 5500);
1382   application.SendNotification();
1383   application.Render();
1384
1385   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1386
1387   // Remove front of anchor
1388   field.SetProperty(TextField::Property::TEXT, "TIZEN<a href='https://www.tizen.org'>TIZEN</a>");
1389   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 3);
1390   application.SendNotification();
1391   application.Render();
1392
1393   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1394   application.SendNotification();
1395   application.Render();
1396
1397   // Remove whole text
1398   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1399   DevelTextField::SelectWholeText(field);
1400   application.SendNotification();
1401   application.Render();
1402
1403   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1404   application.SendNotification();
1405   application.Render();
1406
1407   // Remove all with backspace
1408   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1409   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 1);
1410   application.SendNotification();
1411   application.Render();
1412
1413   application.ProcessEvent(GenerateKey("", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1414   application.SendNotification();
1415   application.Render();
1416
1417   // Remove all with delete
1418   field.SetProperty(TextField::Property::TEXT, "<a href='https://www.tizen.org'>T</a>");
1419   field.SetProperty(DevelTextField::Property::PRIMARY_CURSOR_POSITION, 0);
1420   application.SendNotification();
1421   application.Render();
1422
1423   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));
1424   application.SendNotification();
1425   application.Render();
1426
1427   END_TEST;
1428 }
1429
1430 // Positive test for the textChanged signal.
1431 int utcDaliTextFieldTextChangedP(void)
1432 {
1433   ToolkitTestApplication application;
1434   tet_infoline(" utcDaliTextFieldTextChangedP");
1435   TextField field = TextField::New();
1436   DALI_TEST_CHECK( field );
1437
1438   application.GetScene().Add( field );
1439
1440   // connect to the text changed signal.
1441   ConnectionTracker* testTracker = new ConnectionTracker();
1442   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1443   bool textChangedSignal = false;
1444   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1445
1446   gTextChangedCallBackCalled = false;
1447   field.SetProperty( TextField::Property::TEXT, "ABC" );
1448   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1449   DALI_TEST_CHECK( textChangedSignal );
1450
1451   application.SendNotification();
1452   field.SetKeyInputFocus();
1453
1454   gTextChangedCallBackCalled = false;
1455   application.ProcessEvent( GenerateKey( "D", "", "D", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "D", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1456   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1457
1458   // Remove all text
1459   field.SetProperty( TextField::Property::TEXT, "" );
1460
1461   // Pressing backspace key: TextChangedCallback should not be called when there is no text in textfield.
1462   gTextChangedCallBackCalled = false;
1463   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1464   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1465
1466   // Pressing delete key: TextChangedCallback should not be called when there is no text in textfield.
1467   gTextChangedCallBackCalled = false;
1468   application.ProcessEvent( GenerateKey( "", "", "", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1469   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1470
1471   END_TEST;
1472 }
1473
1474 int utcDaliTextFieldTextChangedWithInputMethodContext(void)
1475 {
1476   ToolkitTestApplication application;
1477   tet_infoline(" utcDaliTextFieldTextChangedWithInputMethodContext");
1478   TextField field = TextField::New();
1479   DALI_TEST_CHECK( field );
1480
1481
1482   application.GetScene().Add( field );
1483
1484   // connect to the text changed signal.
1485   ConnectionTracker* testTracker = new ConnectionTracker();
1486   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1487   bool textChangedSignal = false;
1488   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1489
1490
1491   // get InputMethodContext
1492   std::string text;
1493   InputMethodContext::EventData imfEvent;
1494   InputMethodContext inputMethodContext = DevelTextField::GetInputMethodContext( field );
1495
1496   field.SetKeyInputFocus();
1497   field.SetProperty( DevelTextField::Property::ENABLE_EDITING, true );
1498
1499   // input text
1500   gTextChangedCallBackCalled = false;
1501   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "ㅎ", 0, 1 );
1502   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1503   application.SendNotification();
1504   application.Render();
1505   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1506   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ㅎ"), TEST_LOCATION );
1507
1508   gTextChangedCallBackCalled = false;
1509   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "호", 0, 1 );
1510   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1511   application.SendNotification();
1512   application.Render();
1513   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1514   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호"), TEST_LOCATION );
1515
1516   gTextChangedCallBackCalled = false;
1517   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "혿", 0, 1 );
1518   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1519   application.SendNotification();
1520   application.Render();
1521   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1522   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("혿"), TEST_LOCATION );
1523
1524   gTextChangedCallBackCalled = false;
1525   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "", 0, 1 );
1526   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1527   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1528
1529   imfEvent = InputMethodContext::EventData( InputMethodContext::COMMIT, "호", 0, 1 );
1530   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1531   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1532
1533   imfEvent = InputMethodContext::EventData( InputMethodContext::PRE_EDIT, "두", 1, 2 );
1534   inputMethodContext.EventReceivedSignal().Emit(inputMethodContext, imfEvent);
1535   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1536
1537   application.SendNotification();
1538   application.Render();
1539   DALI_TEST_CHECK( gTextChangedCallBackCalled );
1540   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("호두"), TEST_LOCATION );
1541
1542   END_TEST;
1543 }
1544
1545
1546 // Negative test for the textChanged signal.
1547 int utcDaliTextFieldTextChangedN(void)
1548 {
1549   ToolkitTestApplication application;
1550   tet_infoline(" utcDaliTextFieldTextChangedN");
1551   TextField field = TextField::New();
1552   DALI_TEST_CHECK( field );
1553
1554   application.GetScene().Add( field );
1555
1556   // connect to the text changed signal.
1557   ConnectionTracker* testTracker = new ConnectionTracker();
1558   field.TextChangedSignal().Connect(&TestTextChangedCallback);
1559   bool textChangedSignal = false;
1560   field.ConnectSignal( testTracker, "textChanged",   CallbackFunctor(&textChangedSignal) );
1561
1562   gTextChangedCallBackCalled = false;
1563   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "ABC" ); // Setting placeholder, not TEXT
1564   application.SendNotification();
1565   application.Render();
1566   DALI_TEST_CHECK( !gTextChangedCallBackCalled );
1567   DALI_TEST_CHECK( !textChangedSignal );
1568
1569   END_TEST;
1570 }
1571
1572 // Positive test for Max Characters reached signal.
1573 int utcDaliTextFieldMaxCharactersReachedP(void)
1574 {
1575   ToolkitTestApplication application;
1576   tet_infoline(" utcDaliTextFieldMaxCharactersReachedP");
1577   TextField field = TextField::New();
1578   DALI_TEST_CHECK( field );
1579
1580   application.GetScene().Add( field );
1581
1582   const int maxNumberOfCharacters = 1;
1583   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1584
1585   field.SetKeyInputFocus();
1586
1587   // connect to the text changed signal.
1588   ConnectionTracker* testTracker = new ConnectionTracker();
1589   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1590   bool maxLengthReachedSignal = false;
1591   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1592
1593   gMaxCharactersCallBackCalled = false;
1594
1595   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1596   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1597
1598   DALI_TEST_CHECK( gMaxCharactersCallBackCalled );
1599   DALI_TEST_CHECK( maxLengthReachedSignal );
1600
1601   END_TEST;
1602 }
1603
1604 // Negative test for Max Characters reached signal.
1605 int utcDaliTextFieldMaxCharactersReachedN(void)
1606 {
1607   ToolkitTestApplication application;
1608   tet_infoline(" utcDaliTextFieldMaxCharactersReachedN");
1609   TextField field = TextField::New();
1610   DALI_TEST_CHECK( field );
1611
1612   application.GetScene().Add( field );
1613
1614   const int maxNumberOfCharacters = 3;
1615   field.SetProperty( TextField::Property::MAX_LENGTH, maxNumberOfCharacters );
1616
1617   field.SetKeyInputFocus();
1618
1619   // connect to the text changed signal.
1620   ConnectionTracker* testTracker = new ConnectionTracker();
1621   field.MaxLengthReachedSignal().Connect(&TestMaxLengthReachedCallback);
1622   bool maxLengthReachedSignal = false;
1623   field.ConnectSignal( testTracker, "maxLengthReached",   CallbackFunctor(&maxLengthReachedSignal) );
1624
1625   gMaxCharactersCallBackCalled = false;
1626
1627   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1628   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1629
1630   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1631   DALI_TEST_CHECK( !maxLengthReachedSignal );
1632
1633   application.ProcessEvent( GenerateKey( "Return", "", "\r", KEY_RETURN_CODE, 0, 0, Integration::KeyEvent::DOWN, "\r", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
1634
1635   DALI_TEST_CHECK( !gMaxCharactersCallBackCalled );
1636   DALI_TEST_CHECK( !maxLengthReachedSignal );
1637
1638   END_TEST;
1639 }
1640
1641 // Positive test for Input Filtered signal.
1642 int utcDaliTextFieldInputFilteredP(void)
1643 {
1644   ToolkitTestApplication application;
1645   tet_infoline(" utcDaliTextFieldInputFilteredP");
1646   TextField field = TextField::New();
1647   DALI_TEST_CHECK(field);
1648
1649   application.GetScene().Add(field);
1650
1651   Property::Map inputFilter;
1652
1653   // Only digit is accepted.
1654   inputFilter[InputFilter::Property::ACCEPTED] = "[\\d]";
1655
1656   // Set input filter to TextField.
1657   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1658
1659   field.SetKeyInputFocus();
1660
1661   // connect to the input filtered signal.
1662   ConnectionTracker* testTracker = new ConnectionTracker();
1663   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1664   bool inputFilteredSignal = false;
1665   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1666
1667   gInputFilteredAcceptedCallbackCalled = false;
1668
1669   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ));
1670
1671   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1672   DALI_TEST_CHECK(inputFilteredSignal);
1673
1674   // Word is rejected.
1675   inputFilter[InputFilter::Property::ACCEPTED] = "";
1676   inputFilter[InputFilter::Property::REJECTED] = "[\\w]";
1677
1678   // Set input filter to TextField.
1679   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1680
1681   field.SetKeyInputFocus();
1682
1683   inputFilteredSignal = false;
1684   gInputFilteredRejectedCallbackCalled = false;
1685
1686   application.ProcessEvent(GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1687
1688   DALI_TEST_CHECK(gInputFilteredAcceptedCallbackCalled);
1689   DALI_TEST_CHECK(inputFilteredSignal);
1690
1691   END_TEST;
1692 }
1693
1694 // Negative test for Input Filtered signal.
1695 int utcDaliTextFieldInputFilteredN(void)
1696 {
1697   ToolkitTestApplication application;
1698   tet_infoline(" utcDaliTextFieldInputFilteredP");
1699   TextField field = TextField::New();
1700   DALI_TEST_CHECK(field);
1701
1702   application.GetScene().Add(field);
1703
1704   Property::Map inputFilter;
1705
1706   // Only word is accepted.
1707   inputFilter[InputFilter::Property::ACCEPTED] = "[\\w]";
1708
1709   // Set input filter to TextField.
1710   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1711
1712   field.SetKeyInputFocus();
1713
1714   // connect to the input filtered signal.
1715   ConnectionTracker* testTracker = new ConnectionTracker();
1716   DevelTextField::InputFilteredSignal(field).Connect(&TestInputFilteredCallback);
1717   bool inputFilteredSignal = false;
1718   field.ConnectSignal(testTracker, "inputFiltered", CallbackFunctor(&inputFilteredSignal));
1719
1720   gInputFilteredAcceptedCallbackCalled = false;
1721
1722   // Key a, d should not be filtered.
1723   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1724   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1725   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1726   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1727
1728   // Backspace, Delete should not be filtered.
1729   application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1730   application.ProcessEvent(GenerateKey( "Delete", "", "Delete", Dali::DevelKey::DALI_KEY_DELETE, 0, 0, Integration::KeyEvent::DOWN, "Delete", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1731
1732   // Render and notify
1733   application.SendNotification();
1734   application.Render();
1735
1736   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1737   DALI_TEST_CHECK(!inputFilteredSignal);
1738
1739   // Digit is rejected.
1740   inputFilter[InputFilter::Property::ACCEPTED] = "";
1741   inputFilter[InputFilter::Property::REJECTED] = "[\\d]";
1742
1743   field.SetProperty(DevelTextField::Property::INPUT_FILTER, inputFilter);
1744
1745   field.SetKeyInputFocus();
1746
1747   inputFilteredSignal = false;
1748   gInputFilteredRejectedCallbackCalled = false;
1749
1750   // Key a, d should not be filtered.
1751   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1752   application.ProcessEvent(GenerateKey("a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1753   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1754   application.ProcessEvent(GenerateKey("d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1755
1756   // Backspace, Delete should not be filtered.
1757   application.ProcessEvent(GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE));
1758   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));
1759
1760   // Render and notify
1761   application.SendNotification();
1762   application.Render();
1763
1764   DALI_TEST_CHECK(!gInputFilteredAcceptedCallbackCalled);
1765   DALI_TEST_CHECK(!inputFilteredSignal);
1766
1767   END_TEST;
1768 }
1769
1770 int utcDaliTextFieldInputStyleChanged01(void)
1771 {
1772   // The text-field emits signals when the input style changes. These changes of style are
1773   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1774   // can't be emitted during the size negotiation as the callbacks may update the UI.
1775   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1776   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1777   ToolkitTestApplication application;
1778   tet_infoline(" utcDaliTextFieldInputStyleChanged01");
1779
1780   // Load some fonts.
1781
1782   char* pathNamePtr = get_current_dir_name();
1783   const std::string pathName( pathNamePtr );
1784   free( pathNamePtr );
1785
1786   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1787   fontClient.SetDpi( 93u, 93u );
1788
1789   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1790   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
1791
1792   TextField field = TextField::New();
1793   DALI_TEST_CHECK( field );
1794
1795
1796   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
1797   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
1798   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
1799
1800   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
1801   field.SetProperty( TextField::Property::TEXT, "<font family='DejaVuSerif' size='18'>He<color value='green'>llo</color> <font weight='bold'>world</font> demo</font>" );
1802
1803   // connect to the text changed signal.
1804   ConnectionTracker* testTracker = new ConnectionTracker();
1805   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
1806   bool inputStyleChangedSignal = false;
1807   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
1808
1809   application.GetScene().Add( field );
1810
1811   // Render and notify
1812   application.SendNotification();
1813   application.Render();
1814
1815   // Executes the idle callbacks added by the text control on the change of input style.
1816   application.RunIdles();
1817
1818   gInputStyleChangedCallbackCalled = false;
1819   gInputStyleMask = TextField::InputStyle::NONE;
1820   inputStyleChangedSignal = false;
1821
1822   // Create a tap event to touch the text field.
1823   TestGenerateTap( application, 18.0f, 25.0f );
1824
1825   // Render and notify
1826   application.SendNotification();
1827   application.Render();
1828
1829   // Executes the idle callbacks added by the text control on the change of input style.
1830   application.RunIdles();
1831
1832   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1833   if( gInputStyleChangedCallbackCalled )
1834   {
1835     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY | TextField::InputStyle::POINT_SIZE ), TEST_LOCATION );
1836
1837     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
1838     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
1839
1840     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
1841     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1842   }
1843   DALI_TEST_CHECK( inputStyleChangedSignal );
1844
1845   gInputStyleChangedCallbackCalled = false;
1846   gInputStyleMask = TextField::InputStyle::NONE;
1847   inputStyleChangedSignal = false;
1848
1849   // Create a tap event to touch the text field.
1850   TestGenerateTap( application, 30.0f, 25.0f );
1851
1852   // Render and notify
1853   application.SendNotification();
1854   application.Render();
1855
1856   // Executes the idle callbacks added by the text control on the change of input style.
1857   application.RunIdles();
1858
1859   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1860   DALI_TEST_CHECK( !inputStyleChangedSignal );
1861
1862   gInputStyleChangedCallbackCalled = false;
1863   gInputStyleMask = TextField::InputStyle::NONE;
1864   inputStyleChangedSignal = false;
1865
1866   // Create a tap event to touch the text field.
1867   TestGenerateTap( application, 43.0f, 25.0f );
1868
1869   // Render and notify
1870   application.SendNotification();
1871   application.Render();
1872
1873   // Executes the idle callbacks added by the text control on the change of input style.
1874   application.RunIdles();
1875
1876   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1877   if( gInputStyleChangedCallbackCalled )
1878   {
1879     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR ), TEST_LOCATION );
1880
1881     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1882     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
1883   }
1884   DALI_TEST_CHECK( inputStyleChangedSignal );
1885
1886   gInputStyleChangedCallbackCalled = false;
1887   gInputStyleMask = TextField::InputStyle::NONE;
1888   inputStyleChangedSignal = false;
1889
1890   // Create a tap event to touch the text field.
1891   TestGenerateTap( application, 88.0f, 25.0f );
1892
1893   // Render and notify
1894   application.SendNotification();
1895   application.Render();
1896
1897   // Executes the idle callbacks added by the text control on the change of input style.
1898   application.RunIdles();
1899
1900   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1901   if( gInputStyleChangedCallbackCalled )
1902   {
1903     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::COLOR | TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1904
1905     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
1906     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
1907
1908     const Property::Map fontStyleMapGet = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<Property::Map>();
1909
1910     Property::Map fontStyleMapSet;
1911     fontStyleMapSet.Insert( "weight", "bold" );
1912
1913     DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
1914     DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
1915   }
1916   DALI_TEST_CHECK( inputStyleChangedSignal );
1917
1918   gInputStyleChangedCallbackCalled = false;
1919   gInputStyleMask = TextField::InputStyle::NONE;
1920   inputStyleChangedSignal = false;
1921
1922   // Create a tap event to touch the text field.
1923   TestGenerateTap( application, 115.0f, 25.0f );
1924
1925   // Render and notify
1926   application.SendNotification();
1927   application.Render();
1928
1929   // Executes the idle callbacks added by the text control on the change of input style.
1930   application.RunIdles();
1931
1932   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1933   DALI_TEST_CHECK( !inputStyleChangedSignal );
1934
1935   gInputStyleChangedCallbackCalled = false;
1936   gInputStyleMask = TextField::InputStyle::NONE;
1937   inputStyleChangedSignal = false;
1938
1939   // Create a tap event to touch the text field.
1940   TestGenerateTap( application, 164.0f, 25.0f );
1941
1942   // Render and notify
1943   application.SendNotification();
1944   application.Render();
1945
1946   // Executes the idle callbacks added by the text control on the change of input style.
1947   application.RunIdles();
1948
1949   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
1950   if( gInputStyleChangedCallbackCalled )
1951   {
1952     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ), static_cast<unsigned int>( TextField::InputStyle::FONT_STYLE ), TEST_LOCATION );
1953
1954     const std::string style = field.GetProperty( TextField::Property::INPUT_FONT_STYLE ).Get<std::string>();
1955     DALI_TEST_CHECK( style.empty() );
1956   }
1957   DALI_TEST_CHECK( inputStyleChangedSignal );
1958
1959   gInputStyleChangedCallbackCalled = false;
1960   gInputStyleMask = TextField::InputStyle::NONE;
1961   inputStyleChangedSignal = false;
1962
1963   // Create a tap event to touch the text field.
1964   TestGenerateTap( application, 191.0f, 25.0f );
1965
1966   // Render and notify
1967   application.SendNotification();
1968   application.Render();
1969
1970   // Executes the idle callbacks added by the text control on the change of input style.
1971   application.RunIdles();
1972
1973   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
1974   DALI_TEST_CHECK( !inputStyleChangedSignal );
1975
1976   END_TEST;
1977 }
1978
1979 int utcDaliTextFieldInputStyleChanged02(void)
1980 {
1981   // The text-field emits signals when the input style changes. These changes of style are
1982   // detected during the relayout process (size negotiation), i.e after the cursor has been moved. Signals
1983   // can't be emitted during the size negotiation as the callbacks may update the UI.
1984   // The text-field adds an idle callback to the adaptor to emit the signals after the size negotiation.
1985   // The ToolkitTestApplication creates an implementation of the adaptor stub and a queue of idle callbacks.
1986   ToolkitTestApplication application;
1987   tet_infoline(" utcDaliTextFieldInputStyleChanged02");
1988
1989   // Load some fonts.
1990
1991   char* pathNamePtr = get_current_dir_name();
1992   const std::string pathName( pathNamePtr );
1993   free( pathNamePtr );
1994
1995   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1996   fontClient.SetDpi( 93u, 93u );
1997
1998   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif.ttf", DEFAULT_FONT_SIZE );
1999   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/dejavu/DejaVuSerif-Bold.ttf", DEFAULT_FONT_SIZE );
2000
2001   TextField field = TextField::New();
2002   DALI_TEST_CHECK( field );
2003
2004   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2005   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2006   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2007
2008   field.SetProperty( TextField::Property::ENABLE_MARKUP, true );
2009   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>" );
2010
2011   // connect to the text changed signal.
2012   ConnectionTracker* testTracker = new ConnectionTracker();
2013   field.InputStyleChangedSignal().Connect( &TestInputStyleChangedCallback );
2014   bool inputStyleChangedSignal = false;
2015   field.ConnectSignal( testTracker, "inputStyleChanged",   CallbackFunctor(&inputStyleChangedSignal) );
2016
2017   application.GetScene().Add( field );
2018
2019   // Render and notify
2020   application.SendNotification();
2021   application.Render();
2022
2023   // Executes the idle callbacks added by the text control on the change of input style.
2024   application.RunIdles();
2025
2026   gInputStyleChangedCallbackCalled = false;
2027   gInputStyleMask = TextField::InputStyle::NONE;
2028   inputStyleChangedSignal = false;
2029
2030   // Create a tap event to touch the text field.
2031   TestGenerateTap( application, 53.0f, 25.0f, 100 );
2032   TestGenerateTap( application, 53.0f, 25.0f, 200 );
2033
2034   // Render and notify
2035   application.SendNotification();
2036   application.Render();
2037
2038   // Executes the idle callbacks added by the text control on the change of input style.
2039   application.RunIdles();
2040
2041   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2042   if( gInputStyleChangedCallbackCalled )
2043   {
2044     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2045                       static_cast<unsigned int>( TextField::InputStyle::FONT_FAMILY |
2046                                                  TextField::InputStyle::POINT_SIZE  |
2047                                                  TextField::InputStyle::COLOR ),
2048                       TEST_LOCATION );
2049
2050     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2051     DALI_TEST_EQUALS( color, Color::GREEN, TEST_LOCATION );
2052
2053     const std::string fontFamily = field.GetProperty( TextField::Property::INPUT_FONT_FAMILY ).Get<std::string>();
2054     DALI_TEST_EQUALS( fontFamily, "DejaVuSerif", TEST_LOCATION );
2055
2056     const float pointSize = field.GetProperty( TextField::Property::INPUT_POINT_SIZE ).Get<float>();
2057     DALI_TEST_EQUALS( pointSize, 18.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2058   }
2059   DALI_TEST_CHECK( inputStyleChangedSignal );
2060
2061   gInputStyleChangedCallbackCalled = false;
2062   gInputStyleMask = TextField::InputStyle::NONE;
2063   inputStyleChangedSignal = false;
2064
2065   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2066
2067   // Render and notify
2068   application.SendNotification();
2069   application.Render();
2070
2071   // Executes the idle callbacks added by the text control on the change of input style.
2072   application.RunIdles();
2073
2074   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2075   if( gInputStyleChangedCallbackCalled )
2076   {
2077     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2078                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2079                       TEST_LOCATION );
2080
2081     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2082     DALI_TEST_EQUALS( color, Color::BLUE, TEST_LOCATION );
2083   }
2084   DALI_TEST_CHECK( inputStyleChangedSignal );
2085
2086   gInputStyleChangedCallbackCalled = false;
2087   gInputStyleMask = TextField::InputStyle::NONE;
2088   inputStyleChangedSignal = false;
2089
2090   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2091
2092   // Render and notify
2093   application.SendNotification();
2094   application.Render();
2095
2096   // Executes the idle callbacks added by the text control on the change of input style.
2097   application.RunIdles();
2098
2099   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2100   DALI_TEST_CHECK( !inputStyleChangedSignal );
2101
2102   gInputStyleChangedCallbackCalled = false;
2103   gInputStyleMask = TextField::InputStyle::NONE;
2104   inputStyleChangedSignal = false;
2105
2106   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2107
2108   // Render and notify
2109   application.SendNotification();
2110   application.Render();
2111
2112   // Executes the idle callbacks added by the text control on the change of input style.
2113   application.RunIdles();
2114
2115   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2116   if( gInputStyleChangedCallbackCalled )
2117   {
2118     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2119                       static_cast<unsigned int>( TextField::InputStyle::COLOR ),
2120                       TEST_LOCATION );
2121
2122     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2123     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2124   }
2125   DALI_TEST_CHECK( inputStyleChangedSignal );
2126
2127   gInputStyleChangedCallbackCalled = false;
2128   gInputStyleMask = TextField::InputStyle::NONE;
2129   inputStyleChangedSignal = false;
2130
2131   field.SetProperty( TextField::Property::INPUT_COLOR, Color::YELLOW );
2132
2133   Property::Map fontStyleMapSet;
2134   fontStyleMapSet.Insert( "weight", "thin" );
2135   fontStyleMapSet.Insert( "width", "condensed" );
2136   fontStyleMapSet.Insert( "slant", "italic" );
2137
2138   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2139   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 20.f );
2140
2141   field.SetProperty( TextField::Property::INPUT_UNDERLINE, "underline" );
2142   field.SetProperty( TextField::Property::INPUT_SHADOW, "shadow" );
2143   field.SetProperty( TextField::Property::INPUT_EMBOSS, "emboss" );
2144   field.SetProperty( TextField::Property::INPUT_OUTLINE, "outline" );
2145   field.SetProperty( DevelTextField::Property::INPUT_STRIKETHROUGH, "strikethrough" );
2146
2147   // Render and notify
2148   application.SendNotification();
2149   application.Render();
2150
2151   // Executes the idle callbacks added by the text control on the change of input style.
2152   application.RunIdles();
2153
2154   DALI_TEST_CHECK( !gInputStyleChangedCallbackCalled );
2155   DALI_TEST_CHECK( !inputStyleChangedSignal );
2156
2157   // Create a tap event to touch the text field.
2158   TestGenerateTap( application, 63.0f, 25.0f, 700 );
2159
2160   // Render and notify
2161   application.SendNotification();
2162   application.Render();
2163
2164   // Executes the idle callbacks added by the text control on the change of input style.
2165   application.RunIdles();
2166
2167   DALI_TEST_CHECK( gInputStyleChangedCallbackCalled );
2168   if( gInputStyleChangedCallbackCalled )
2169   {
2170     DALI_TEST_EQUALS( static_cast<unsigned int>( gInputStyleMask ),
2171                       static_cast<unsigned int>( TextField::InputStyle::COLOR |
2172                                                  TextField::InputStyle::POINT_SIZE |
2173                                                  TextField::InputStyle::FONT_STYLE |
2174                                                  TextField::InputStyle::UNDERLINE |
2175                                                  TextField::InputStyle::SHADOW |
2176                                                  TextField::InputStyle::EMBOSS |
2177                                                  TextField::InputStyle::OUTLINE ),
2178                       TEST_LOCATION );
2179
2180     const Vector4 color = field.GetProperty( TextField::Property::INPUT_COLOR ).Get<Vector4>();
2181     DALI_TEST_EQUALS( color, Color::BLACK, TEST_LOCATION );
2182   }
2183   DALI_TEST_CHECK( inputStyleChangedSignal );
2184
2185   END_TEST;
2186 }
2187
2188 int utcDaliTextFieldEvent01(void)
2189 {
2190   ToolkitTestApplication application;
2191   tet_infoline(" utcDaliTextFieldEvent01");
2192
2193   // Creates a tap event. After creating a tap event the text field should
2194   // have the focus and add text with key events should be possible.
2195
2196   TextField field = TextField::New();
2197   DALI_TEST_CHECK( field );
2198
2199   application.GetScene().Add( field );
2200
2201   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2202   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2203   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2204
2205   // Render and notify
2206   application.SendNotification();
2207   application.Render();
2208
2209   // Avoid a crash when core load gl resources.
2210   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2211
2212   // Render and notify
2213   application.SendNotification();
2214   application.Render();
2215
2216   // Add a key event but as the text field has not the focus it should do nothing.
2217   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2218
2219   // Render and notify
2220   application.SendNotification();
2221   application.Render();
2222
2223   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2224
2225   // Create a tap event to touch the text field.
2226   TestGenerateTap( application, 150.0f, 25.0f );
2227
2228   // Render and notify
2229   application.SendNotification();
2230   application.Render();
2231
2232   // Pressing delete key should be fine even if there is no text in TextField.
2233   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 ) );
2234   // Render and notify
2235   application.SendNotification();
2236   application.Render();
2237
2238   // Now the text field has the focus, so it can handle the key events.
2239   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2240   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2241
2242   // Render and notify
2243   application.SendNotification();
2244   application.Render();
2245
2246   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2247
2248   // Create a second text field and send key events to it.
2249   TextField field2 = TextField::New();
2250
2251   field2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2252   field2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2253   field2.SetProperty( Actor::Property::SIZE, Vector2( 100.f, 100.f ) );
2254   field2.SetProperty( Actor::Property::POSITION, Vector2( 100.0f, 100.0f ));
2255
2256   application.GetScene().Add( field2 );
2257
2258   // Render and notify
2259   application.SendNotification();
2260   application.Render();
2261
2262   // Create a tap event on the second text field.
2263   TestGenerateTap( application, 150.0f, 125.0f );
2264
2265   // Render and notify
2266   application.SendNotification();
2267   application.Render();
2268
2269   // The second text field has the focus. It should handle the key events.
2270   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2271   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2272
2273   // Render and notify
2274   application.SendNotification();
2275   application.Render();
2276
2277   // Check the text has been added to the second text field.
2278   DALI_TEST_EQUALS( field2.GetProperty<std::string>( TextField::Property::TEXT ), std::string("aa"), TEST_LOCATION );
2279
2280   END_TEST;
2281 }
2282
2283 int utcDaliTextFieldEvent02(void)
2284 {
2285   ToolkitTestApplication application;
2286   tet_infoline(" utcDaliTextFieldEvent02");
2287
2288   // Checks if the right number of actors are created.
2289
2290   TextField field = TextField::New();
2291   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2292   DALI_TEST_CHECK( field );
2293   LoadMarkerImages(application, field);
2294
2295   application.GetScene().Add( field );
2296
2297   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2298   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2299   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2300
2301   // Avoid a crash when core load gl resources.
2302   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2303
2304   // Render and notify
2305   application.SendNotification();
2306   application.Render();
2307
2308   // Check there are the expected number of children ( stencil ).
2309   DALI_TEST_EQUALS( field.GetChildCount(), 1u, TEST_LOCATION );
2310
2311   Actor stencil = field.GetChildAt( 0u );
2312   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2313
2314   // Create a tap event to touch the text field.
2315   TestGenerateTap( application, 150.0f, 25.0f, 300 );
2316
2317   // Render and notify
2318   application.SendNotification();
2319   application.Render();
2320
2321   Actor layer = field.GetChildAt( 1u );
2322   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2323   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2324
2325   // Now the text field has the focus, so it can handle the key events.
2326   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2327   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2328
2329   // Render and notify
2330   application.SendNotification();
2331   application.Render();
2332
2333   // Checks the cursor and the renderer have been created.
2334   DALI_TEST_EQUALS( layer.GetChildCount(), 1u, TEST_LOCATION ); // The cursor.
2335   DALI_TEST_EQUALS( stencil.GetChildCount(), 1u, TEST_LOCATION ); // The renderer
2336
2337   Control cursor = Control::DownCast( layer.GetChildAt( 0u ) );
2338   DALI_TEST_CHECK( cursor );
2339
2340   // The offscreen root actor has a container with all the actors which contain the text renderers.
2341   Actor container = stencil.GetChildAt( 0u );
2342   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2343   {
2344     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2345     DALI_TEST_CHECK( renderer );
2346   }
2347
2348   // Move the cursor and check the position changes.
2349   Vector3 position1 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2350   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2351
2352   // Render and notify
2353   application.SendNotification();
2354   application.Render();
2355
2356   Vector3 position2 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2357   DALI_TEST_CHECK( position2.x < position1.x );
2358
2359   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_RIGHT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2360
2361   // Render and notify
2362   application.SendNotification();
2363   application.Render();
2364
2365   Vector3 position3 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2366   DALI_TEST_EQUALS( position1, position3, TEST_LOCATION ); // Should be in the same position1.
2367
2368
2369   // Move the cursor to the first position.
2370   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2371   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_CURSOR_LEFT, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2372
2373   // Render and notify
2374   application.SendNotification();
2375   application.Render();
2376
2377   Vector3 position4 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2378
2379   // Send some taps and check the cursor positions.
2380
2381   // Try to tap at the beginning.
2382   TestGenerateTap( application, 1.0f, 25.0f, 900 );
2383
2384   // Render and notify
2385   application.SendNotification();
2386   application.Render();
2387
2388   // Cursor position should be the same than position1.
2389   Vector3 position5 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2390
2391   DALI_TEST_EQUALS( position4, position5, TEST_LOCATION ); // Should be in the same position2.
2392
2393   // Tap away from the start position.
2394   TestGenerateTap( application, 16.0f, 25.0f, 1500 );
2395
2396   // Render and notify
2397   application.SendNotification();
2398   application.Render();
2399
2400   Vector3 position6 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2401
2402   DALI_TEST_CHECK( position6.x > position5.x );
2403
2404   // Remove all the text.
2405   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2406   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2407   field.SetProperty( TextField::Property::TEXT, "" );
2408
2409   // Render and notify
2410   application.SendNotification();
2411   application.Render();
2412
2413   // Cursor position should be the same than position2.
2414   Vector3 position7 = cursor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION );
2415
2416   DALI_TEST_EQUALS( position4, position7, TEST_LOCATION );// Should be in the same position2.
2417
2418   // Should not be a renderer.
2419   DALI_TEST_EQUALS( stencil.GetChildCount(), 0u, TEST_LOCATION );
2420
2421   // Chanege exceed policy (EXCEED_POLICY_ORIGINAL doesn't use stencil )
2422   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2423   field.SetProperty( TextField::Property::EXCEED_POLICY, Dali::Toolkit::TextField::EXCEED_POLICY_ORIGINAL );
2424
2425   application.SendNotification();
2426   application.Render();
2427
2428   // There are renderer and decorator layer
2429   DALI_TEST_EQUALS( field.GetChildCount(), 2u, TEST_LOCATION );
2430
2431   END_TEST;
2432 }
2433
2434 int utcDaliTextFieldEvent03(void)
2435 {
2436   ToolkitTestApplication application;
2437   tet_infoline(" utcDaliTextFieldEvent03");
2438
2439   // Checks if the highlight actor is created.
2440
2441   TextField field = TextField::New();
2442   DALI_TEST_CHECK( field );
2443
2444   application.GetScene().Add( field );
2445
2446   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2447   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2448   field.SetProperty( Actor::Property::SIZE, Vector2( 30.f, 50.f ) );
2449   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2450   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2451
2452   // Avoid a crash when core load gl resources.
2453   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2454   LoadMarkerImages(application, field);
2455
2456   // Render and notify
2457   application.SendNotification();
2458   application.Render();
2459
2460   // Tap first to get the focus.
2461   TestGenerateTap( application, 3.0f, 25.0f );
2462
2463   // Render and notify
2464   application.SendNotification();
2465   application.Render();
2466
2467   // Double tap to select a word.
2468   TestGenerateTap( application, 3.0f, 25.0f );
2469
2470   // Render and notify
2471   application.SendNotification();
2472   application.Render();
2473
2474   // The offscreen root actor should have two actors: the renderer and the highlight actor.
2475   Actor stencil = field.GetChildAt( 0u );
2476
2477   // The highlight actor is drawn first, so is the first actor in the list
2478   Renderer highlight = stencil.GetChildAt( 0u ).GetRendererAt( 0u );
2479   DALI_TEST_CHECK( highlight );
2480
2481   // The offscreen root actor has a container with all the actors which contain the text renderers.
2482   Actor container = stencil.GetChildAt( 1u );
2483   for( unsigned int index = 0; index < container.GetChildCount(); ++index )
2484   {
2485     Renderer renderer = container.GetChildAt( index ).GetRendererAt( 0u );
2486     DALI_TEST_CHECK( renderer );
2487   }
2488
2489   END_TEST;
2490 }
2491
2492 int utcDaliTextFieldEvent04(void)
2493 {
2494   ToolkitTestApplication application;
2495   tet_infoline(" utcDaliTextFieldEvent04");
2496
2497   // Checks if the highlight actor is created.
2498
2499   TextField field = TextField::New();
2500   DALI_TEST_CHECK( field );
2501   application.GetScene().Add( field );
2502   LoadMarkerImages(application, field);
2503   // Render and notify
2504   application.SendNotification();
2505   application.Render();
2506
2507   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2508   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2509   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2510   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2511   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2512
2513   // Avoid a crash when core load gl resources.
2514   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2515   // Render and notify
2516   application.SendNotification();
2517   application.Render();
2518
2519   // Create a tap event to touch the text field.
2520   TestGenerateTap( application, 150.0f, 25.0f );
2521   // Render and notify
2522   application.SendNotification();
2523   application.Render();
2524
2525
2526   // Tap first to get the focus.
2527   TestGenerateTap( application, 1.0f, 25.0f );
2528
2529   // Render and notify
2530   application.SendNotification();
2531   application.Render();
2532
2533   // Double tap to select a word.
2534   TestGenerateTap( application, 1.0f, 25.0f );
2535
2536   // Render and notify
2537   application.SendNotification();
2538   application.Render();
2539
2540   // Tap grab handle
2541   TestGenerateTap( application, 0.0f, 40.0f );
2542   END_TEST;
2543 }
2544
2545 int utcDaliTextFieldEvent05(void)
2546 {
2547   ToolkitTestApplication application;
2548   tet_infoline(" utcDaliTextFieldEvent05");
2549
2550   // Checks dragging of cursor/grab handle
2551
2552   TextField field = TextField::New();
2553   DALI_TEST_CHECK( field );
2554   application.GetScene().Add( field );
2555   LoadMarkerImages(application, field);
2556   // Render and notify
2557   application.SendNotification();
2558   application.Render();
2559
2560   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2561   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2562   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2563   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2564   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2565
2566   // Avoid a crash when core load gl resources.
2567   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2568   // Render and notify
2569   application.SendNotification();
2570   application.Render();
2571
2572   // Create a tap event to touch the text field.
2573   TestGenerateTap( application, 150.0f, 25.0f );
2574   // Render and notify
2575   application.SendNotification();
2576   application.Render();
2577
2578   // Tap first to get the focus.
2579   TestGenerateTap( application, 1.0f, 25.0f );
2580
2581   // Render and notify
2582   application.SendNotification();
2583   application.Render();
2584
2585   // Double tap to select a word.
2586   TestGenerateTap( application, 1.0f, 25.0f );
2587
2588   // Render and notify
2589   application.SendNotification();
2590   application.Render();
2591
2592   Actor stencil = field.GetChildAt( 1u );
2593   END_TEST;
2594 }
2595
2596 int utcDaliTextFieldEvent06(void)
2597 {
2598   ToolkitTestApplication application;
2599   tet_infoline(" utcDaliTextFieldEvent06");
2600
2601   // Checks Longpress when in edit mode
2602
2603   TextField field = TextField::New();
2604   DALI_TEST_CHECK( field );
2605   application.GetScene().Add( field );
2606   LoadMarkerImages(application, field);
2607   // Render and notify
2608   application.SendNotification();
2609   application.Render();
2610
2611   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2612   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2613   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2614   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2615   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2616
2617   // Avoid a crash when core load gl resources.
2618   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2619   // Render and notify
2620   application.SendNotification();
2621   application.Render();
2622
2623   // Create a tap event to touch the text field.
2624   TestGenerateTap( application, 150.0f, 25.0f );
2625   // Render and notify
2626   application.SendNotification();
2627   application.Render();
2628
2629
2630   // Tap first to get the focus.
2631   TestGenerateTap( application, 1.0f, 25.0f );
2632
2633   // Render and notify
2634   application.SendNotification();
2635   application.Render();
2636
2637   // Long Press
2638   TestGenerateLongPress(application, 1.0f, 25.0f);
2639
2640   // Render and notify
2641   application.SendNotification();
2642   application.Render();
2643
2644   END_TEST;
2645 }
2646
2647 int utcDaliTextFieldEvent07(void)
2648 {
2649   ToolkitTestApplication application;
2650   tet_infoline(" utcDaliTextFieldEvent07");
2651
2652   // Checks Longpress to start edit mode
2653
2654   TextField field = TextField::New();
2655   DALI_TEST_CHECK( field );
2656   application.GetScene().Add( field );
2657   LoadMarkerImages(application, field);
2658   // Render and notify
2659   application.SendNotification();
2660   application.Render();
2661
2662   field.SetProperty( TextField::Property::TEXT, "Thisisalongtextforthesizeofthetextfield." );
2663   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2664   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2665   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2666   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2667   Property::Map propertyMap;
2668   propertyMap["PANEL_LAYOUT"] = InputMethod::PanelLayout::PASSWORD;
2669   field.SetProperty( TextField::Property::INPUT_METHOD_SETTINGS, propertyMap );
2670
2671   // Avoid a crash when core load gl resources.
2672   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2673   // Render and notify
2674   application.SendNotification();
2675   application.Render();
2676
2677   // Long Press
2678   TestGenerateLongPress(application, 1.0f, 25.0f);
2679
2680   // Render and notify
2681   application.SendNotification();
2682   application.Render();
2683
2684   END_TEST;
2685 }
2686
2687 int utcDaliTextFieldEvent08(void)
2688 {
2689   ToolkitTestApplication application;
2690   tet_infoline(" utcDaliTextFieldEvent08");
2691
2692   Dali::Clipboard clipboard = Clipboard::Get();
2693   clipboard.SetItem("testTextFieldEvent");
2694
2695   // Checks Longpress when only place holder text
2696
2697   TextField field = TextField::New();
2698   DALI_TEST_CHECK( field );
2699   application.GetScene().Add( field );
2700   LoadMarkerImages(application, field);
2701   // Render and notify
2702   application.SendNotification();
2703   application.Render();
2704
2705   field.SetProperty( TextField::Property::PLACEHOLDER_TEXT, "Setting Placeholder Text" );
2706   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2707   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2708   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2709   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2710
2711   // Avoid a crash when core load gl resources.
2712   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2713   // Render and notify
2714   application.SendNotification();
2715   application.Render();
2716
2717   // Long Press
2718   TestGenerateLongPress( application, 1.0f, 25.0f, 20 );
2719
2720   // Render and notify
2721   application.SendNotification();
2722   application.Render();
2723
2724   Wait(application, 500);
2725
2726   TestEndLongPress( application, 1.0f, 25.0f, 520 );
2727
2728   // Long Press
2729   TestGenerateLongPress( application, 1.0f, 25.0f, 600 );
2730
2731   // Render and notify
2732   application.Render();
2733
2734   Wait(application, 500);
2735
2736   Integration::Scene stage = application.GetScene();
2737   Layer layer = stage.GetRootLayer();
2738   Actor actor = layer.FindChildByName("optionPaste");
2739
2740   if (actor)
2741   {
2742     Vector3 worldPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::WORLD_POSITION );
2743     Vector2 halfStageSize = stage.GetSize() / 2.0f;
2744     Vector2 position(worldPosition.x + halfStageSize.width, worldPosition.y + halfStageSize.height);
2745
2746     Dali::Integration::TouchEvent event;
2747     event = Dali::Integration::TouchEvent();
2748     event.AddPoint( GetPointDownInside( position ) );
2749     application.ProcessEvent( event );
2750
2751     event = Dali::Integration::TouchEvent();
2752     event.AddPoint( GetPointUpInside( position ) );
2753     application.ProcessEvent( event );
2754   }
2755   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextEditor::Property::TEXT ), std::string("testTextFieldEvent"), TEST_LOCATION );
2756
2757   END_TEST;
2758 }
2759
2760 int utcDaliTextFieldEvent09(void)
2761 {
2762   ToolkitTestApplication application;
2763   tet_infoline(" utcDaliTextFieldEvent09");
2764
2765   TextField field = TextField::New();
2766   DALI_TEST_CHECK( field );
2767   application.GetScene().Add( field );
2768   LoadMarkerImages(application, field);
2769   // Render and notify
2770   application.SendNotification();
2771   application.Render();
2772
2773   field.SetProperty( TextField::Property::TEXT, "Hello" );
2774   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2775   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2776   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2777   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2778
2779   // Avoid a crash when core load gl resources.
2780   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2781
2782   // Create a tap event to touch the text field.
2783   TestGenerateTap( application, 150.0f, 25.0f );
2784   application.SendNotification();
2785   application.Render();
2786
2787   Property::Map map;
2788   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_NONE;
2789   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2790   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2791   application.SendNotification();
2792   application.Render();
2793
2794   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_ALL;
2795   map[ HiddenInput::Property::SUBSTITUTE_CHARACTER ] = 0x23;
2796   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2797   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2798   application.SendNotification();
2799   application.Render();
2800
2801   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::HIDE_COUNT;
2802   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2803   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2804   for( unsigned int index = 0u; index < 5u; ++index )
2805   {
2806     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2807     application.SendNotification();
2808     application.Render();
2809   }
2810
2811   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_COUNT;
2812   map[ HiddenInput::Property::SUBSTITUTE_COUNT ] = 2;
2813   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2814   for( unsigned int index = 0u; index < 5u; ++index )
2815   {
2816     application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2817     application.SendNotification();
2818     application.Render();
2819   }
2820
2821   map[ HiddenInput::Property::MODE ] = HiddenInput::Mode::SHOW_LAST_CHARACTER;
2822   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 0;
2823   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2824   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_BACKSPACE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2825   application.SendNotification();
2826   application.Render();
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   map[ HiddenInput::Property::SHOW_LAST_CHARACTER_DURATION ] = 100;
2832   field.SetProperty( TextField::Property::HIDDEN_INPUT_SETTINGS, map );
2833   application.ProcessEvent( GenerateKey( "d", "", "d", 0, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2834   application.SendNotification();
2835   application.Render();
2836
2837   Property::Map mapGet;
2838   mapGet = field.GetProperty<Property::Map>( TextField::Property::HIDDEN_INPUT_SETTINGS );
2839   DALI_TEST_EQUALS( map.Count(), mapGet.Count(), TEST_LOCATION );
2840   DALI_TEST_EQUALS( DaliTestCheckMaps( map, mapGet ), true, TEST_LOCATION );
2841   END_TEST;
2842 }
2843
2844
2845 int utcDaliTextFieldStyleWhilstSelected(void)
2846 {
2847   ToolkitTestApplication application;
2848   tet_infoline(" utcDaliTextFieldStyleWhilstSelected");
2849
2850   // Change font and styles whilst text is selected whilst word selected
2851
2852   TextField field = TextField::New();
2853   DALI_TEST_CHECK( field );
2854   application.GetScene().Add( field );
2855   LoadMarkerImages(application, field);
2856   // Render and notify
2857   application.SendNotification();
2858   application.Render();
2859
2860   field.SetProperty( TextField::Property::TEXT, "This is a long text for the size of the text-field." );
2861   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
2862   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2863   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2864   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2865
2866   // Avoid a crash when core load gl resources.
2867   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2868   // Render and notify
2869   application.SendNotification();
2870   application.Render();
2871
2872   // Create a tap event to touch the text field.
2873   TestGenerateTap( application, 150.0f, 25.0f );
2874   // Render and notify
2875   application.SendNotification();
2876   application.Render();
2877
2878
2879   // Tap first to get the focus.
2880   TestGenerateTap( application, 1.0f, 25.0f );
2881
2882   // Render and notify
2883   application.SendNotification();
2884   application.Render();
2885
2886   // Double tap to select a word.
2887   TestGenerateTap( application, 1.0f, 25.0f );
2888
2889   // Render and notify
2890   application.SendNotification();
2891   application.Render();
2892
2893   field.SetProperty( TextField::Property::INPUT_FONT_FAMILY, "Setting input font family" );
2894   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::INPUT_FONT_FAMILY ), "Setting input font family", TEST_LOCATION );
2895
2896   Property::Map fontStyleMapSet;
2897   Property::Map fontStyleMapGet;
2898
2899   fontStyleMapSet.Insert( "weight", "bold" );
2900   fontStyleMapSet.Insert( "slant", "italic" );
2901   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2902
2903   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2904   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2905   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2906
2907   fontStyleMapSet.Clear();
2908   fontStyleMapSet.Insert( "width", "expanded" );
2909   fontStyleMapSet.Insert( "slant", "italic" );
2910   field.SetProperty( TextField::Property::INPUT_FONT_STYLE, fontStyleMapSet );
2911
2912   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::INPUT_FONT_STYLE );
2913   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2914   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2915
2916   field.SetProperty( TextField::Property::INPUT_POINT_SIZE, 12.f );
2917   DALI_TEST_EQUALS( field.GetProperty<float>( TextField::Property::INPUT_POINT_SIZE ), 12.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
2918
2919   field.SetProperty( TextField::Property::TEXT_COLOR, Color::RED );
2920   DALI_TEST_EQUALS( field.GetProperty<Vector4>( TextField::Property::TEXT_COLOR ), Color::RED, TEST_LOCATION );
2921
2922   fontStyleMapSet.Clear();
2923   fontStyleMapSet.Insert( "weight", "bold" );
2924   fontStyleMapSet.Insert( "slant", "italic" );
2925
2926   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2927
2928   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2929   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2930   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2931
2932   fontStyleMapSet.Clear();
2933   fontStyleMapSet.Insert( "width", "expanded" );
2934
2935   field.SetProperty( TextField::Property::FONT_STYLE, fontStyleMapSet );
2936
2937   fontStyleMapGet = field.GetProperty<Property::Map>( TextField::Property::FONT_STYLE );
2938   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
2939   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
2940
2941   // Press Escape to increase coverage
2942   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2943   application.SendNotification();
2944   application.Render();
2945
2946   DALI_TEST_CHECK( !field.HasKeyInputFocus() );
2947
2948   END_TEST;
2949 }
2950
2951 int utcDaliTextFieldEscKeyLoseFocus(void)
2952 {
2953   ToolkitTestApplication application;
2954   tet_infoline(" utcDaliTextFieldEscKeyLoseFocus");
2955
2956   // Creates a tap event. After creating a tap event the text field should
2957   // have the focus and add text with key events should be possible.
2958
2959   TextField field = TextField::New();
2960   DALI_TEST_CHECK( field );
2961
2962   application.GetScene().Add( field );
2963
2964   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
2965   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2966   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2967
2968   // Avoid a crash when core load gl resources.
2969   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2970
2971   // Render and notify
2972   application.SendNotification();
2973   application.Render();
2974
2975   // Add a key event but as the text field has not the focus it should do nothing.
2976   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2977   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2978
2979   // Render and notify
2980   application.SendNotification();
2981   application.Render();
2982
2983   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string(""), TEST_LOCATION );
2984
2985   // Create a tap event to touch the text field.
2986   TestGenerateTap( application, 150.0f, 25.0f );
2987
2988   // Render and notify
2989   application.SendNotification();
2990   application.Render();
2991
2992   // Now the text field has the focus, so it can handle the key events.
2993   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2994   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2995   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::DOWN, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2996   application.ProcessEvent( GenerateKey( "d", "", "d", KEY_D_CODE, 0, 0, Integration::KeyEvent::UP, "d", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
2997
2998   // Render and notify
2999   application.SendNotification();
3000   application.Render();
3001
3002   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3003
3004   // Generate a Esc key event. The text field should lose the focus.
3005   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::DOWN, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3006   application.ProcessEvent( GenerateKey( "", "", "", DALI_KEY_ESCAPE, 0, 0, Integration::KeyEvent::UP, "", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3007
3008   // Render and notify
3009   application.SendNotification();
3010   application.Render();
3011
3012   DALI_TEST_EQUALS( false, field.HasKeyInputFocus(), TEST_LOCATION );
3013
3014   // No more text should be introduced
3015   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::DOWN, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3016   application.ProcessEvent( GenerateKey( "a", "", "a", KEY_A_CODE, 0, 0, Integration::KeyEvent::UP, "a", DEFAULT_DEVICE_NAME, Device::Class::NONE, Device::Subclass::NONE ) );
3017
3018   // Render and notify
3019   application.SendNotification();
3020   application.Render();
3021
3022   DALI_TEST_EQUALS( field.GetProperty<std::string>( TextField::Property::TEXT ), std::string("ad"), TEST_LOCATION );
3023
3024   END_TEST;
3025 }
3026
3027 int utcDaliTextFieldSomeSpecialKeys(void)
3028 {
3029   ToolkitTestApplication application;
3030   tet_infoline(" utcDaliTextFieldSomeSpecialKeys");
3031
3032   // Checks some special keys when the text is selected.
3033
3034   TextField field = TextField::New();
3035   DALI_TEST_CHECK( field );
3036   application.GetScene().Add( field );
3037   LoadMarkerImages(application, field);
3038   // Render and notify
3039   application.SendNotification();
3040   application.Render();
3041
3042   const std::string longText( "This is a long text for the size of the text-field." );
3043
3044   field.SetProperty( TextField::Property::TEXT, longText );
3045   field.SetProperty( TextField::Property::POINT_SIZE, 10.f );
3046   field.SetProperty( Actor::Property::SIZE, Vector2( 300.f, 50.f ) );
3047   field.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
3048   field.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
3049
3050   // Avoid a crash when core load gl resources.
3051   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
3052   // Render and notify
3053   application.SendNotification();
3054   application.Render();
3055
3056   // Create a tap event to touch the text field.
3057   TestGenerateTap( application, 150.0f, 25.0f );