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