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