Set TapGesture only if there is an anchor.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.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-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
27 #include <dali/devel-api/text-abstraction/bitmap-font.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/adaptor-framework/image-loading.h>
30 #include <dali-toolkit/devel-api/text/bitmap-font.h>
31 #include <dali-toolkit/devel-api/text/rendering-backend.h>
32 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
33
34 using namespace Dali;
35 using namespace Toolkit;
36
37 void dali_textlabel_startup(void)
38 {
39   test_return_value = TET_UNDEF;
40 }
41
42 void dali_textlabel_cleanup(void)
43 {
44   test_return_value = TET_PASS;
45 }
46
47 namespace
48 {
49
50 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE =  "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
64
65 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE = "underline";
67 const char* const PROPERTY_NAME_SHADOW = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
71
72 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
73 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
74 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
75 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
76
77 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
78
79 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
80 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
81
82 static bool gAnchorClickedCallBackCalled;
83 static bool gAnchorClickedCallBackNotCalled;
84
85 struct CallbackFunctor
86 {
87   CallbackFunctor(bool* callbackFlag)
88   : mCallbackFlag( callbackFlag )
89   {
90   }
91
92   void operator()()
93   {
94     *mCallbackFlag = true;
95   }
96   bool* mCallbackFlag;
97 };
98
99 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
100 {
101   tet_infoline(" TestAnchorClickedCallback");
102
103   gAnchorClickedCallBackNotCalled = false;
104
105   if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
106   {
107     gAnchorClickedCallBackCalled = true;
108   }
109 }
110
111 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
112 {
113   const Property::Map::SizeType size = mapGet.Count();
114
115   if( size == mapSet.Count() )
116   {
117     for( unsigned int index = 0u; index < size; ++index )
118     {
119       const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
120
121       // Find the keys of the 'get' map
122       Property::Index indexKey = valueGet.first.indexKey;
123       std::string stringKey = valueGet.first.stringKey;
124
125       if( !indexConversionTable.empty() )
126       {
127         if( stringKey.empty() )
128         {
129           stringKey = indexConversionTable[ indexKey ];
130         }
131
132         if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
133         {
134           Property::Index index = 0u;
135           for( auto key : indexConversionTable )
136           {
137             if( key == stringKey )
138             {
139               indexKey = index;
140               break;
141             }
142             ++index;
143           }
144         }
145       }
146
147       const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
148
149       if( nullptr != valueSet )
150       {
151         if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
152         {
153           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
154           return false;
155         }
156         else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
157         {
158           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
159           return false;
160         }
161         else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
162         {
163           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
164           return false;
165         }
166         else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
167         {
168           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
169           return false;
170         }
171         else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
172         {
173           Vector2 vector2Get = valueGet.second.Get<Vector2>();
174           Vector2 vector2Set = valueSet->Get<Vector2>();
175           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
176           return false;
177         }
178         else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
179         {
180           Vector4 vector4Get = valueGet.second.Get<Vector4>();
181           Vector4 vector4Set = valueSet->Get<Vector4>();
182           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 );
183           return false;
184         }
185       }
186       else
187       {
188         if ( valueGet.first.type == Property::Key::INDEX )
189         {
190           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
191         }
192         else
193         {
194           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
195         }
196         return false;
197       }
198     }
199   }
200
201   return true;
202 }
203
204 } // namespace
205
206 int UtcDaliToolkitTextLabelConstructorP(void)
207 {
208   ToolkitTestApplication application;
209   tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
210   TextLabel textLabel;
211   DALI_TEST_CHECK( !textLabel );
212   END_TEST;
213 }
214
215 int UtcDaliToolkitTextLabelNewP(void)
216 {
217   ToolkitTestApplication application;
218   tet_infoline(" UtcDaliToolkitTextLabelNewP");
219   TextLabel textLabel = TextLabel::New( "Test Text" );
220   DALI_TEST_CHECK( textLabel );
221   END_TEST;
222 }
223
224 int UtcDaliToolkitTextLabelDownCastP(void)
225 {
226   ToolkitTestApplication application;
227   tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
228   TextLabel textLabel1 = TextLabel::New();
229   BaseHandle object( textLabel1 );
230
231   TextLabel textLabel2 = TextLabel::DownCast( object );
232   DALI_TEST_CHECK( textLabel2 );
233
234   TextLabel textLabel3 = DownCast< TextLabel >( object );
235   DALI_TEST_CHECK( textLabel3 );
236   END_TEST;
237 }
238
239 int UtcDaliToolkitTextLabelDownCastN(void)
240 {
241   ToolkitTestApplication application;
242   tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
243   BaseHandle uninitializedObject;
244   TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
245   DALI_TEST_CHECK( !textLabel1 );
246
247   TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
248   DALI_TEST_CHECK( !textLabel2 );
249   END_TEST;
250 }
251
252 int UtcDaliToolkitTextLabelCopyConstructorP(void)
253 {
254   ToolkitTestApplication application;
255   tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
256   TextLabel textLabel = TextLabel::New();
257   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
258
259   TextLabel copy( textLabel );
260   DALI_TEST_CHECK( copy );
261   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
262   END_TEST;
263 }
264
265 int UtcDaliTextLabelMoveConstructor(void)
266 {
267   ToolkitTestApplication application;
268
269   TextLabel textLabel = TextLabel::New();
270   textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
271   DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
272
273   TextLabel moved = std::move( textLabel );
274   DALI_TEST_CHECK( moved );
275   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
276   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
277   DALI_TEST_CHECK( !textLabel );
278
279   END_TEST;
280 }
281
282 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
283 {
284   ToolkitTestApplication application;
285   tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
286   TextLabel textLabel = TextLabel::New();
287   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
288
289   TextLabel copy = textLabel;
290   DALI_TEST_CHECK( copy );
291   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
292   END_TEST;
293 }
294
295 int UtcDaliTextLabelMoveAssignment(void)
296 {
297   ToolkitTestApplication application;
298
299   TextLabel textLabel = TextLabel::New();
300   textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
301   DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
302
303   TextLabel moved;
304   moved = std::move( textLabel );
305   DALI_TEST_CHECK( moved );
306   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
307   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
308   DALI_TEST_CHECK( !textLabel );
309
310   END_TEST;
311 }
312
313 // Positive test case for a method
314 int UtcDaliToolkitTextLabelGetPropertyP(void)
315 {
316   ToolkitTestApplication application;
317   tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
318   TextLabel label = TextLabel::New("Test Text");
319   DALI_TEST_CHECK( label );
320
321   // Check Property Indices are correct
322   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
323   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
324   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
325   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
326   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
327   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
328   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
329   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
330   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
331   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
332   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
333   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
334   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
335   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
336   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
337   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
338   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
339   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
340   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
341   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
342   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
343   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
344   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
345   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
346   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS_POSITION ) == DevelTextLabel::Property::ELLIPSIS_POSITION );
347
348   END_TEST;
349 }
350
351 int UtcDaliToolkitTextLabelSetPropertyP(void)
352 {
353   ToolkitTestApplication application;
354   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
355   TextLabel label = TextLabel::New();
356   DALI_TEST_CHECK( label );
357
358   application.GetScene().Add( label );
359
360   // Note - we can't check the defaults since the stylesheets are platform-specific
361   label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
362   DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
363
364   // Check that text can be correctly reset
365   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
366   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
367
368   // Check font properties.
369   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
370   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
371
372   Property::Map fontStyleMapSet;
373   Property::Map fontStyleMapGet;
374
375   fontStyleMapSet.Insert( "weight", "bold" );
376   fontStyleMapSet.Insert( "width", "condensed" );
377   fontStyleMapSet.Insert( "slant", "italic" );
378   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
379
380   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
381   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
382   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
383
384   // Check the old font style format.
385   fontStyleMapSet.Clear();
386   fontStyleMapSet.Insert( "weight", "thin" );
387   fontStyleMapSet.Insert( "width", "expanded" );
388   fontStyleMapSet.Insert( "slant", "oblique" );
389   const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
390
391   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
392   std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
393   DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
394
395   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
396   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
397
398   label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
399   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
400   label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
401
402   // Reset font style.
403   fontStyleMapSet.Clear();
404   fontStyleMapSet.Insert( "weight", "normal" );
405   fontStyleMapSet.Insert( "slant", "oblique" );
406
407   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
408   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
409   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
410   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
411
412   fontStyleMapSet.Clear();
413   fontStyleMapSet.Insert( "slant", "roman" );
414
415   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
416   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
417   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
418
419   // Replace 'roman' for 'normal'.
420   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
421   if( NULL != slantValue )
422   {
423     if( "normal" == slantValue->Get<std::string>() )
424     {
425       fontStyleMapGet["slant"] = "roman";
426     }
427   }
428   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
429
430   fontStyleMapSet.Clear();
431
432   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
433   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
434   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
435   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
436
437   // Toggle multi-line
438   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
439   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
440
441   // Check that the Alignment properties can be correctly set
442   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
443   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
444   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
445   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
446
447   // Check that text color can be properly set
448   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
449   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
450
451   Property::Map underlineMapSet;
452   Property::Map underlineMapGet;
453
454   underlineMapSet.Insert( "enable", false );
455   underlineMapSet.Insert( "color", Color::BLUE );
456   underlineMapSet.Insert( "height", 0 );
457
458   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
459   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
460   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
461
462   TextLabel label2 = TextLabel::New( "New text" );
463   DALI_TEST_CHECK( label2 );
464   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
465
466   // Check the enable markup property.
467   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
468   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
469   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
470
471   // Check the text property when markup is enabled
472   label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
473   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
474
475   // Check for incomplete marks.
476   label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
477   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
478   try
479   {
480     application.SendNotification();
481     application.Render();
482   }
483   catch( ... )
484   {
485     tet_result(TET_FAIL);
486   }
487
488   // Check autoscroll properties
489   const int SCROLL_SPEED = 80;
490   const int SCROLL_LOOPS = 4;
491   const float SCROLL_GAP = 50.0f;
492   const float SCROLL_LOOP_DELAY = 0.3f;
493   const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
494   const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
495
496   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
497   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
498   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
499   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
500   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
501   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
502   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
503   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
504   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
505   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
506   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
507   DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
508
509   //Check autoscroll stop type property
510   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
511   DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
512
513   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
514   DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
515
516   // test natural size with multi-line and line spacing
517   {
518     TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
519     Vector3 oneLineNaturalSize = label3.GetNaturalSize();
520     label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
521     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
522     Vector3 multiLineNaturalSize = label3.GetNaturalSize();
523
524     // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
525     // The height of the text when multi-line is enabled will be larger
526     DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
527     DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
528
529     // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
530     // Everything else will remain the same
531     int lineSpacing = 20;
532     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
533     Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
534     expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
535     DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
536   }
537
538   // single line, line spacing must not affect natural size of the text, only add the spacing to the height
539   {
540     TextLabel label3 = TextLabel::New("Some text here end there end here");
541     label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
542     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
543     Vector3 textNaturalSize = label3.GetNaturalSize();
544     int lineSpacing = 20;
545     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
546     Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
547     expectedNaturalSizeWithLineSpacing.height += lineSpacing;
548     DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
549   }
550   // Check the line spacing property
551   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
552   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
553   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
554
555   // Check the underline property
556   underlineMapSet.Clear();
557   underlineMapSet.Insert( "enable", true );
558   underlineMapSet.Insert( "color", Color::RED );
559   underlineMapSet.Insert( "height", 1 );
560
561   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
562
563   application.SendNotification();
564   application.Render();
565
566   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
567   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
568   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
569
570   underlineMapSet.Clear();
571   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
572   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
573   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
574
575   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
576
577   application.SendNotification();
578   application.Render();
579
580   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
581   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
582   std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
583   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
584
585   underlineMapSet.Clear();
586
587   Property::Map underlineDisabledMapGet;
588   underlineDisabledMapGet.Insert( "enable", false );
589   underlineDisabledMapGet.Insert( "color", Color::GREEN );
590   underlineDisabledMapGet.Insert( "height", 2 );
591
592   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
593
594   application.SendNotification();
595   application.Render();
596
597   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
598   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
599   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
600
601   // Check the shadow property
602
603   Property::Map shadowMapSet;
604   Property::Map shadowMapGet;
605
606   shadowMapSet.Insert( "color", Color::GREEN );
607   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
608   shadowMapSet.Insert( "blurRadius", 5.0f );
609
610   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
611
612   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
613   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
614   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
615
616   shadowMapSet.Clear();
617
618   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
619   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
620   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
621
622   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
623
624   // Replace the offset (string) by a vector2
625   shadowMapSet.Clear();
626   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
627   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
628   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
629
630   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
631   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
632   std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
633   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
634
635   shadowMapSet.Clear();
636   Property::Map shadowDisabledMapGet;
637   shadowDisabledMapGet.Insert( "color", Color::BLUE );
638   shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
639   shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
640
641   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
642
643   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
644   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
645   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
646
647   // Check the emboss property
648   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
649   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
650
651   // Check the outline property
652
653   // Test string type first
654   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
655   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
656   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
657
658   // Then test the property map type
659   Property::Map outlineMapSet;
660   Property::Map outlineMapGet;
661
662   outlineMapSet["color"] = Color::RED;
663   outlineMapSet["width"] = 2.0f;
664   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
665
666   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
667   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
668   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
669
670   outlineMapSet.Clear();
671   outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
672   outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
673   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
674
675   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
676   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
677   std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
678   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
679
680   // Check the background property
681   Property::Map backgroundMapSet;
682   Property::Map backgroundMapGet;
683
684   backgroundMapSet["enable"] = true;
685   backgroundMapSet["color"] = Color::RED;
686   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
687
688   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
689   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
690   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
691
692   backgroundMapSet.Clear();
693   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
694   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
695   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
696
697   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
698   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
699   std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
700   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
701
702   // Check the pixel size of font
703   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
704   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
705
706   // Check the ellipsis property
707   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
708   label.SetProperty( TextLabel::Property::ELLIPSIS, false );
709   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
710
711   // Check the layout direction property
712   label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
713   DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
714
715   // Check the line size property
716   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
717   label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
718   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
719
720   application.SendNotification();
721   application.Render();
722
723   END_TEST;
724 }
725
726 int UtcDaliToolkitTextlabelAtlasRenderP(void)
727 {
728   ToolkitTestApplication application;
729   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
730   TextLabel label = TextLabel::New("Test Text");
731   DALI_TEST_CHECK( label );
732
733   // Avoid a crash when core load gl resources.
734   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
735
736   application.GetScene().Add( label );
737
738   // Turn on all the effects
739   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
740   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
741
742   Property::Map underlineMap;
743   underlineMap.Insert( "enable", true );
744   underlineMap.Insert( "color", Color::RED );
745   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
746
747   Property::Map shadowMap;
748   shadowMap.Insert( "color", Color::BLUE );
749   shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
750   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
751
752   try
753   {
754     // Render some text with the shared atlas backend
755     label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
756     application.SendNotification();
757     application.Render();
758   }
759   catch( ... )
760   {
761     tet_result(TET_FAIL);
762   }
763
764   try
765   {
766     // Render some text with the shared atlas backend
767     label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
768     application.SendNotification();
769     application.Render();
770   }
771   catch( ... )
772   {
773     tet_result(TET_FAIL);
774   }
775   END_TEST;
776 }
777
778 int UtcDaliToolkitTextLabelLanguagesP(void)
779 {
780   ToolkitTestApplication application;
781   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
782   TextLabel label = TextLabel::New();
783   DALI_TEST_CHECK( label );
784
785   application.GetScene().Add( label );
786
787   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
788                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
789                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
790                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
791                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
792                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
793
794   label.SetProperty( TextLabel::Property::TEXT, scripts );
795   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
796
797   application.SendNotification();
798   application.Render();
799
800   END_TEST;
801 }
802
803 int UtcDaliToolkitTextLabelEmojisP(void)
804 {
805   ToolkitTestApplication application;
806   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
807   TextLabel label = TextLabel::New();
808   DALI_TEST_CHECK( label );
809
810   application.GetScene().Add( label );
811
812   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
813
814   char* pathNamePtr = get_current_dir_name();
815   const std::string pathName( pathNamePtr );
816   free( pathNamePtr );
817
818   TextAbstraction::FontDescription fontDescription;
819   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
820   fontDescription.family = "BreezeColorEmoji";
821   fontDescription.width = TextAbstraction::FontWidth::NONE;
822   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
823   fontDescription.slant = TextAbstraction::FontSlant::NONE;
824
825   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
826
827   const std::string emojis = "<font family='BreezeColorEmoji' size='60'>\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84</font>";
828   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
829   label.SetProperty( TextLabel::Property::TEXT, emojis );
830
831   Property::Map shadowMap;
832   shadowMap.Insert( "color", "green" );
833   shadowMap.Insert( "offset", "2 2" );
834   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
835
836   application.SendNotification();
837   application.Render();
838
839   END_TEST;
840 }
841
842 int UtcDaliToolkitTextlabelScrollingP(void)
843 {
844   ToolkitTestApplication application;
845   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
846   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
847   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
848
849   DALI_TEST_CHECK( labelImmediate );
850   DALI_TEST_CHECK( labelFinished );
851   // Avoid a crash when core load gl resources.
852   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
853   application.GetScene().Add( labelImmediate );
854   // Turn on all the effects
855   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
856   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
857   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
858   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
859   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
860
861   application.GetScene().Add( labelFinished );
862   // Turn on all the effects
863   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
864   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
865   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
866   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
867   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
868
869
870
871   try
872   {
873     // Render some text with the shared atlas backend
874     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
875     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
876
877     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
878     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
879
880     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
881     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
882     application.SendNotification();
883     application.Render();
884
885     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
886     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
887     application.SendNotification();
888     application.Render();
889
890   }
891   catch( ... )
892   {
893     tet_result(TET_FAIL);
894   }
895
896   END_TEST;
897 }
898
899 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
900 {
901   ToolkitTestApplication application;
902   TextLabel labelShort = TextLabel::New("Some text to scroll");
903   TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
904
905   DALI_TEST_CHECK( labelShort );
906   DALI_TEST_CHECK( labelLong );
907   // Avoid a crash when core load gl resources.
908   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
909   application.GetScene().Add( labelShort );
910   // Turn on all the effects
911   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
912   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
913   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
914   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
915   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
916   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
917
918   application.GetScene().Add( labelLong );
919   // Turn on all the effects
920   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
921   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
922   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
923   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
924   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
925   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
926
927   try
928   {
929     // Render some text with the shared atlas backend
930     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
931     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
932     application.SendNotification();
933     application.Render();
934
935     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
936     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
937     application.SendNotification();
938     application.Render();
939
940   }
941   catch( ... )
942   {
943     tet_result(TET_FAIL);
944   }
945
946   END_TEST;
947 }
948
949 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
950 {
951   ToolkitTestApplication application;
952   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
953   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
954
955   DALI_TEST_CHECK( labelShort );
956   DALI_TEST_CHECK( labelLong );
957   // Avoid a crash when core load gl resources.
958   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
959   application.GetScene().Add( labelShort );
960   // Turn on all the effects
961   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
962   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
963   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
964   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
965   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
966   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
967
968   application.GetScene().Add( labelLong );
969   // Turn on all the effects
970   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
971   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
972   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
973   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
974   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
975   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
976
977   try
978   {
979     // Render some text with the shared atlas backend
980     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
981     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
982     application.SendNotification();
983     application.Render();
984
985     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
986     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
987     application.SendNotification();
988     application.Render();
989
990   }
991   catch( ... )
992   {
993     tet_result(TET_FAIL);
994   }
995
996   END_TEST;
997 }
998
999 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1000 {
1001   ToolkitTestApplication application;
1002   TextLabel labelShort = TextLabel::New("Some text to scroll");
1003   TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
1004
1005   DALI_TEST_CHECK( labelShort );
1006   DALI_TEST_CHECK( labelLong );
1007   // Avoid a crash when core load gl resources.
1008   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1009   application.GetScene().Add( labelShort );
1010   // Turn on all the effects
1011   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1012   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1013   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1014   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1015   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1016   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1017
1018   application.GetScene().Add( labelLong );
1019   // Turn on all the effects
1020   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1021   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1022   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1023   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1024   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1025   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1026
1027   try
1028   {
1029     // Render some text with the shared atlas backend
1030     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1031     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1032     application.SendNotification();
1033     application.Render();
1034
1035     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1036     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1037     application.SendNotification();
1038     application.Render();
1039
1040   }
1041   catch( ... )
1042   {
1043     tet_result(TET_FAIL);
1044   }
1045
1046   END_TEST;
1047 }
1048
1049 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1050 {
1051   ToolkitTestApplication application;
1052   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1053   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1054
1055   DALI_TEST_CHECK( labelShort );
1056   DALI_TEST_CHECK( labelLong );
1057   // Avoid a crash when core load gl resources.
1058   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1059   application.GetScene().Add( labelShort );
1060   // Turn on all the effects
1061   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1062   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1063   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1064   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1065   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1066   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1067
1068   application.GetScene().Add( labelLong );
1069   // Turn on all the effects
1070   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1071   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1072   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1073   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1074   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1075   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1076
1077   try
1078   {
1079     // Render some text with the shared atlas backend
1080     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1081     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1082     application.SendNotification();
1083     application.Render();
1084
1085     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1086     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1087     application.SendNotification();
1088     application.Render();
1089
1090   }
1091   catch( ... )
1092   {
1093     tet_result(TET_FAIL);
1094   }
1095
1096   END_TEST;
1097 }
1098
1099 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1100 {
1101   ToolkitTestApplication application;
1102   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1103   TextLabel label = TextLabel::New("Some text to scroll");
1104   DALI_TEST_CHECK( label );
1105   // Avoid a crash when core load gl resources.
1106   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1107   application.GetScene().Add( label );
1108   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1109   // Turn on all the effects
1110   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1111   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1112   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1113   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1114
1115   // Render the text.
1116   application.SendNotification();
1117   application.Render();
1118
1119   unsigned int actorCount1 = label.GetChildCount();
1120   tet_printf("Initial actor count is(%d)\n", actorCount1 );
1121
1122   try
1123   {
1124     // Render some text with the shared atlas backend
1125     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1126     application.SendNotification();
1127     application.Render(2000);
1128
1129     unsigned int actorCount1 = label.GetChildCount();
1130     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1131
1132     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1133
1134     // Render the text.
1135     application.SendNotification();
1136     application.Render();
1137
1138     unsigned int actorCount2 = label.GetChildCount();
1139     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1140
1141     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1142
1143   }
1144   catch( ... )
1145   {
1146     tet_result(TET_FAIL);
1147   }
1148
1149   END_TEST;
1150 }
1151
1152 int UtcDaliToolkitTextlabelScrollingN(void)
1153 {
1154   ToolkitTestApplication application;
1155   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1156
1157   TextLabel label = TextLabel::New("Some text to scroll");
1158   DALI_TEST_CHECK( label );
1159
1160   application.GetScene().Add( label );
1161
1162   // Avoid a crash when core load gl resources.
1163   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1164
1165   // The text scrolling works only on single line text.
1166   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1167
1168   // Turn on all the effects.
1169   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1170   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1171   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1172
1173   // Enable the auto scrolling effect.
1174   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1175
1176   // The auto scrolling shouldn't be enabled.
1177   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1178   DALI_TEST_CHECK( !enabled );
1179
1180   END_TEST;
1181 }
1182
1183 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1184 {
1185   ToolkitTestApplication application;
1186   tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1187
1188   TextLabel label = TextLabel::New("Some text to scroll");
1189   DALI_TEST_CHECK( label );
1190
1191   application.GetScene().Add( label );
1192
1193   // Avoid a crash when core load gl resources.
1194   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1195
1196   // Turn on all the effects.
1197   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1198   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1199   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1200
1201   try
1202   {
1203     // Enable the auto scrolling effect.
1204     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1205     label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1206
1207     // Disable the ellipsis
1208     label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1209
1210     // Render the text.
1211     application.SendNotification();
1212     application.Render();
1213
1214     // Stop auto scrolling
1215     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1216
1217     // Check the ellipsis property
1218     DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1219   }
1220   catch( ... )
1221   {
1222     tet_result(TET_FAIL);
1223   }
1224
1225   END_TEST;
1226 }
1227
1228 int UtcDaliToolkitTextlabelEllipsis(void)
1229 {
1230   ToolkitTestApplication application;
1231   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1232
1233   TextLabel label = TextLabel::New("Hello world");
1234   DALI_TEST_CHECK( label );
1235
1236   // Avoid a crash when core load gl resources.
1237   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1238
1239   application.GetScene().Add( label );
1240
1241   // Turn on all the effects
1242   label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1243   label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1244   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1245
1246   try
1247   {
1248     // Render the text.
1249     application.SendNotification();
1250     application.Render();
1251   }
1252   catch( ... )
1253   {
1254     tet_result(TET_FAIL);
1255   }
1256
1257   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
1258   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1259   label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1260
1261   try
1262   {
1263     // Render the text.
1264     application.SendNotification();
1265     application.Render();
1266   }
1267   catch( ... )
1268   {
1269     tet_result(TET_FAIL);
1270   }
1271
1272
1273   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1274   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1275   label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1276
1277   try
1278   {
1279     // Render the text.
1280     application.SendNotification();
1281     application.Render();
1282   }
1283   catch( ... )
1284   {
1285     tet_result(TET_FAIL);
1286   }
1287
1288   END_TEST;
1289 }
1290
1291 int UtcDaliToolkitTextlabelTextWrapMode(void)
1292 {
1293   ToolkitTestApplication application;
1294   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1295
1296   int lineCount =0 ;
1297
1298   TextLabel label = TextLabel::New();
1299   label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1300   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1301   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1302
1303
1304
1305   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1306   application.GetScene().Add( label );
1307
1308   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1309   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1310
1311   application.SendNotification();
1312   application.Render();
1313
1314   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1315   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1316
1317   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1318   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1319
1320   application.SendNotification();
1321   application.Render();
1322
1323   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1324   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1325
1326   application.SendNotification();
1327   application.Render();
1328
1329   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1330   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1331
1332   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1333   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1334
1335   application.SendNotification();
1336   application.Render();
1337
1338   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1339   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1340
1341   tet_infoline( "Ensure invalid string does not change wrapping mode" );
1342   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1343   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1344
1345   END_TEST;
1346 }
1347
1348 int UtcDaliToolkitTextLabelColorComponents(void)
1349 {
1350   ToolkitTestApplication application;
1351
1352   TextLabel label = TextLabel::New();
1353   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1354   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1355   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1356   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1357   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1358
1359   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1360   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1361   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1362   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1363   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1364
1365   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1366   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1367   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1368   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
1369   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1370
1371   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1372   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1373   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1374
1375   // Test a transparent text - Rendering should be skipped.
1376   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1377   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1378
1379   application.GetScene().Add( label );
1380
1381   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1382   drawTrace.Enable( true );
1383
1384   application.SendNotification();
1385   application.Render();
1386
1387   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION );  // Should be rendered
1388
1389   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1390
1391   drawTrace.Reset();
1392
1393   application.SendNotification();
1394   application.Render();
1395
1396   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1397
1398   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1399
1400   drawTrace.Reset();
1401
1402   application.SendNotification();
1403   application.Render();
1404
1405   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1406
1407   END_TEST;
1408 }
1409
1410 int UtcDaliToolkitTextlabelTextStyle01(void)
1411 {
1412   ToolkitTestApplication application;
1413   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1414
1415   TextLabel label = TextLabel::New();
1416   label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1417   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1418   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1419   application.GetScene().Add( label );
1420
1421   Property::Map outlineMapSet;
1422   Property::Map outlineMapGet;
1423
1424   outlineMapSet["color"] = Color::BLUE;
1425   outlineMapSet["width"] = 2.0f;
1426   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1427
1428   application.SendNotification();
1429   application.Render();
1430
1431   Property::Map shadowMapSet;
1432   shadowMapSet.Insert( "color", "green" );
1433   shadowMapSet.Insert( "offset", "2 2" );
1434   shadowMapSet.Insert( "blurRadius", "3" );
1435   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1436
1437   outlineMapSet["color"] = Color::RED;
1438   outlineMapSet["width"] = 0.0f;
1439   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1440
1441   application.SendNotification();
1442   application.Render();
1443
1444   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1445
1446   Property::Value* colorValue = outlineMapGet.Find("color");
1447
1448   bool colorMatched( false );
1449
1450   if ( colorValue )
1451   {
1452      Property::Type valueType = colorValue->GetType();
1453
1454      if ( Property::STRING == valueType )
1455      {
1456        std::string stringValue;
1457        colorValue->Get( stringValue );
1458        if (  stringValue == "red" )
1459        {
1460          colorMatched = true;
1461        }
1462      }
1463      else if ( Property::VECTOR4 == valueType )
1464      {
1465        Vector4 colorVector4;
1466        colorValue->Get( colorVector4 );
1467        if (  colorVector4 == Color::RED )
1468        {
1469          colorMatched = true;
1470        }
1471      }
1472   }
1473
1474   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1475
1476   END_TEST;
1477 }
1478
1479 int UtcDaliToolkitTextlabelMultiline(void)
1480 {
1481   ToolkitTestApplication application;
1482   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1483
1484   TextLabel label = TextLabel::New();
1485   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1486   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1487   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1488   application.GetScene().Add( label );
1489
1490   application.SendNotification();
1491   application.Render();
1492
1493   int lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1494   DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1495
1496   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1497
1498   application.SendNotification();
1499   application.Render();
1500
1501   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1502   DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1503
1504
1505   END_TEST;
1506 }
1507
1508 int UtcDaliToolkitTextlabelTextDirection(void)
1509 {
1510   ToolkitTestApplication application;
1511   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1512
1513   TextLabel label = TextLabel::New();
1514   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1515
1516   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1517   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1518   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
1519   application.GetScene().Add( label );
1520
1521   // Test LTR text
1522   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1523
1524   // Test RTL text
1525   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1526   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1527
1528   // Test RTL text starting with weak character
1529   label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1530   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1531
1532   // Test RTL text string with emoji and weak character
1533   label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1534   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1535
1536   END_TEST;
1537 }
1538
1539 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1540 {
1541   ToolkitTestApplication application;
1542   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1543
1544   TextLabel label = TextLabel::New();
1545
1546   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP  );
1547   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1548   label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1549   label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1550   application.GetScene().Add( label );
1551   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1552
1553   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE  );
1554   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1555
1556   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM  );
1557   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1558
1559   END_TEST;
1560 }
1561
1562 int UtcDaliToolkitTextLabelBitmapFont(void)
1563 {
1564   ToolkitTestApplication application;
1565   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1566
1567   DevelText::BitmapFontDescription fontDescription;
1568   fontDescription.name = "Digits";
1569   fontDescription.underlinePosition = 0.f;
1570   fontDescription.underlineThickness = 0.f;
1571
1572   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1573   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1574   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1575   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1576   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1577   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1578   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1579   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1580   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1581   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1582   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1583
1584   TextAbstraction::BitmapFont bitmapFont;
1585   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1586
1587   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1588   fontClient.GetFontId( bitmapFont );
1589
1590   TextLabel label = TextLabel::New();
1591
1592   label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1593   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1594
1595   // The text has been laid out with the bitmap font if the natural size is the sum of all the width (322) and 34 height.
1596   DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1597
1598   application.GetScene().Add( label );
1599
1600   application.SendNotification();
1601   application.Render();
1602
1603   // The text has been rendered if the height of the text-label is the height of the line.
1604   DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1605
1606   END_TEST;
1607 }
1608
1609 int ConvertPointToPixel( float point )
1610 {
1611   unsigned int horizontalDpi = 0u;
1612   unsigned int verticalDpi = 0u;
1613   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1614   fontClient.GetDpi( horizontalDpi, verticalDpi );
1615
1616   return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1617 }
1618
1619 int UtcDaliToolkitTextlabelTextFit(void)
1620 {
1621   ToolkitTestApplication application;
1622   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1623   TextLabel label = TextLabel::New();
1624   Vector2 size( 460.0f, 100.0f );
1625   label.SetProperty( Actor::Property::SIZE, size );
1626   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1627
1628   // check point size
1629   Property::Map textFitMapSet;
1630   textFitMapSet["enable"] = true;
1631   textFitMapSet["minSize"] = 10.f;
1632   textFitMapSet["maxSize"] = 100.f;
1633   textFitMapSet["stepSize"] = -1.f;
1634   textFitMapSet["fontSizeType"] = "pointSize";
1635
1636   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1637   label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1638
1639   application.GetScene().Add( label );
1640
1641   application.SendNotification();
1642   application.Render();
1643
1644   const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
1645   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1646
1647   // check pixel size
1648   textFitMapSet.Clear();
1649   textFitMapSet["enable"] = true;
1650   textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1651   textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1652   textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1653   textFitMapSet["fontSizeType"] = "pixelSize";
1654
1655   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1656
1657   application.SendNotification();
1658   application.Render();
1659
1660   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1661
1662   END_TEST;
1663 }
1664
1665 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1666 {
1667   ToolkitTestApplication application;
1668   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1669
1670   DevelText::BitmapFontDescription fontDescription;
1671   fontDescription.name = "Digits";
1672   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1673
1674   TextAbstraction::BitmapFont bitmapFont;
1675   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1676
1677   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1678   fontClient.GetFontId( bitmapFont );
1679
1680   TextLabel label = TextLabel::New();
1681   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1682   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1683   label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1684   label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1685   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1686
1687   Property::Map underlineMapSet;
1688   underlineMapSet.Clear();
1689   underlineMapSet.Insert( "enable", true );
1690   underlineMapSet.Insert( "color", Color::RED );
1691   underlineMapSet.Insert( "height", 1 );
1692   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1693   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1694
1695   application.GetScene().Add( label );
1696
1697   application.SendNotification();
1698   application.Render();
1699
1700   const int maxTextureSize = Dali::GetMaxTextureSize();
1701   // Whether the rendered text is greater than maxTextureSize
1702   DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1703
1704   // Check if the number of renderers is greater than 1.
1705   DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1706
1707   END_TEST;
1708 }
1709
1710 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1711 {
1712   ToolkitTestApplication application;
1713   tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1714
1715   Vector2 size( 300.0f, 100.0f );
1716
1717   Dali::Toolkit::DevelText::RendererParameters textParameters;
1718   textParameters.text = "This is a sample text to get the last index.";
1719   textParameters.layout = "multiLine";
1720   textParameters.fontSize = 20.f;
1721   textParameters.textWidth = 300u;
1722   textParameters.textHeight = 100u;
1723   textParameters.ellipsisEnabled = true;
1724   Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1725
1726   DALI_TEST_CHECK( !indexArray.Empty() );
1727   DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1728
1729   END_TEST;
1730 }
1731
1732 int UtcDaliToolkitTextlabelFontSizeScale(void)
1733 {
1734   ToolkitTestApplication application;
1735   tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1736
1737   TextLabel label = TextLabel::New();
1738   label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1739   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1740   Vector3 nonScaledSize = label.GetNaturalSize();
1741
1742   TextLabel labelScaled = TextLabel::New();
1743   labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1744   labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1745   labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1746   Vector3 scaledSize = labelScaled.GetNaturalSize();
1747
1748   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1749
1750   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1751   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1752   nonScaledSize = label.GetNaturalSize();
1753
1754   labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1755   labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1756   labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1757   scaledSize = labelScaled.GetNaturalSize();
1758
1759   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1760
1761   END_TEST;
1762 }
1763
1764 // Positive test for the anchorClicked signal.
1765 int UtcDaliToolkitTextlabelAnchorClicked(void)
1766 {
1767   ToolkitTestApplication application;
1768   tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1769   TextLabel label = TextLabel::New();
1770   DALI_TEST_CHECK(label);
1771
1772   application.GetScene().Add(label);
1773
1774   // connect to the anchor clicked signal.
1775   ConnectionTracker* testTracker = new ConnectionTracker();
1776   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1777   bool anchorClickedSignal = false;
1778   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1779
1780   gAnchorClickedCallBackCalled = false;
1781   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1782   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1783   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1784   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1785   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1786
1787   application.SendNotification();
1788   application.Render();
1789
1790   // Create a tap event to touch the text label.
1791   TestGenerateTap(application, 5.0f, 25.0f, 100);
1792   application.SendNotification();
1793   application.Render();
1794
1795   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1796   DALI_TEST_CHECK(anchorClickedSignal);
1797
1798   // reset
1799   gAnchorClickedCallBackCalled = false;
1800   anchorClickedSignal = false;
1801   label.SetProperty(TextLabel::Property::TEXT, "");
1802   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
1803
1804   application.SendNotification();
1805   application.Render();
1806
1807   // sets anchor text
1808   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1809   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1810   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1811   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1812   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1813
1814   application.SendNotification();
1815   application.Render();
1816
1817   // Create a tap event to touch the text label.
1818   TestGenerateTap(application, 5.0f, 25.0f, 200);
1819   application.SendNotification();
1820   application.Render();
1821
1822   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1823   DALI_TEST_CHECK(anchorClickedSignal);
1824
1825
1826   gAnchorClickedCallBackNotCalled = true;
1827   // Tap the outside of anchor, callback should not be called.
1828   TestGenerateTap(application, 150.f, 100.f, 300);
1829   application.SendNotification();
1830   application.Render();
1831
1832   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1833
1834   END_TEST;
1835 }
1836
1837 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
1838 {
1839   ToolkitTestApplication application;
1840   tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
1841
1842   //TextLabel is not using Atlas but this is to unify font-size on text-controllers
1843
1844   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
1845   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1846   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1847
1848   // Create a text editor
1849   TextLabel textLabel = TextLabel::New();
1850   //Set size to avoid automatic eliding
1851   textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
1852   //Set very large font-size using point-size
1853   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
1854   //Specify font-family
1855   textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1856   //Set text to check if appear or not
1857   textLabel.SetProperty( TextLabel::Property::TEXT, "A");
1858
1859   application.GetScene().Add( textLabel );
1860
1861   application.SendNotification();
1862   application.Render();
1863   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
1864   Vector3 naturalSize = textLabel.GetNaturalSize();
1865
1866   DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
1867   DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
1868
1869   END_TEST;
1870 }
1871
1872 int UtcDaliTextLabelHyphenWrapMode(void)
1873 {
1874   ToolkitTestApplication application;
1875   tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
1876
1877   int lineCount =0;
1878   TextLabel label = TextLabel::New();
1879   label.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ));
1880   label.SetProperty( TextLabel::Property::POINT_SIZE, 12.f );
1881   label.SetProperty( TextLabel::Property::MULTI_LINE, true);
1882   application.GetScene().Add( label );
1883   application.SendNotification();
1884   application.Render();
1885
1886   label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1887   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::HYPHENATION);
1888   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
1889
1890   application.SendNotification();
1891   application.Render();
1892
1893   lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1894   /*
1895     text will be :
1896     Hi Exp-
1897     erimen
1898   */
1899   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1900
1901   label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1902   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::MIXED);
1903   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
1904
1905   application.SendNotification();
1906   application.Render();
1907
1908   lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1909   /*
1910     text will be :
1911     Hi
1912     Experi-
1913     men
1914   */
1915   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1916
1917   END_TEST;
1918 }
1919
1920
1921 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
1922 {
1923   ToolkitTestApplication application;
1924
1925   tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
1926
1927   int lineCountBefore =0 ;
1928   int lineCountAfter =0 ;
1929
1930   // Create a text editor
1931   TextLabel textLabel = TextLabel::New();
1932   //Set very large font-size using point-size
1933   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
1934   //Specify font-family
1935   textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1936   //Specify size
1937   textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
1938   //Set text longer than width of textLabel
1939   textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
1940   //Set line wrap mode Character
1941   textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1942   textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
1943
1944   application.GetScene().Add( textLabel );
1945
1946   application.SendNotification();
1947   application.Render();
1948
1949
1950   lineCountBefore =  textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1951
1952   textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
1953   lineCountAfter =  textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1954
1955   // When the text changed, the Line-count should be updated according to new text.
1956   // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
1957   DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
1958   DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
1959
1960
1961   END_TEST;
1962 }
1963
1964 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
1965 {
1966   ToolkitTestApplication application;
1967   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
1968   TextLabel textLabel = TextLabel::New();
1969
1970   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
1971   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
1972
1973   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
1974   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
1975   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
1976
1977   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
1978   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
1979   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
1980
1981   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
1982   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
1983   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
1984
1985   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
1986   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
1987   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
1988
1989   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
1990   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
1991   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
1992
1993   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
1994   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
1995   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
1996
1997   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
1998   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
1999   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2000
2001   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2002   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2003   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2004
2005   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2006   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2007   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2008
2009   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2010   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2011   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2012
2013   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2014   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2015   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2016
2017   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2018   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2019   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2020
2021
2022   END_TEST;
2023 }