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