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