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