Add a callback to get textfitted font size.
[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   END_TEST;
855 }
856
857 int UtcDaliToolkitTextlabelScrollingP(void)
858 {
859   ToolkitTestApplication application;
860   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
861   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
862   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
863
864   DALI_TEST_CHECK( labelImmediate );
865   DALI_TEST_CHECK( labelFinished );
866   // Avoid a crash when core load gl resources.
867   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
868   application.GetScene().Add( labelImmediate );
869   // Turn on all the effects
870   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
871   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
872   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
873   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
874   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
875
876   application.GetScene().Add( labelFinished );
877   // Turn on all the effects
878   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
879   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
880   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
881   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
882   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
883
884
885
886   try
887   {
888     // Render some text with the shared atlas backend
889     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
890     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
891
892     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
893     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
894
895     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
896     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
897     application.SendNotification();
898     application.Render();
899
900     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
901     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
902     application.SendNotification();
903     application.Render();
904
905   }
906   catch( ... )
907   {
908     tet_result(TET_FAIL);
909   }
910
911   END_TEST;
912 }
913
914 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
915 {
916   ToolkitTestApplication application;
917   TextLabel labelShort = TextLabel::New("Some text to scroll");
918   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!");
919
920   DALI_TEST_CHECK( labelShort );
921   DALI_TEST_CHECK( labelLong );
922   // Avoid a crash when core load gl resources.
923   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
924   application.GetScene().Add( labelShort );
925   // Turn on all the effects
926   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
927   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
928   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
929   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
930   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
931   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
932
933   application.GetScene().Add( labelLong );
934   // Turn on all the effects
935   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
936   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
937   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
938   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
939   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
940   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
941
942   try
943   {
944     // Render some text with the shared atlas backend
945     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
946     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
947     application.SendNotification();
948     application.Render();
949
950     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
951     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
952     application.SendNotification();
953     application.Render();
954
955   }
956   catch( ... )
957   {
958     tet_result(TET_FAIL);
959   }
960
961   END_TEST;
962 }
963
964 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
965 {
966   ToolkitTestApplication application;
967   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
968   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
969
970   DALI_TEST_CHECK( labelShort );
971   DALI_TEST_CHECK( labelLong );
972   // Avoid a crash when core load gl resources.
973   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
974   application.GetScene().Add( labelShort );
975   // Turn on all the effects
976   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
977   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
978   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
979   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
980   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
981   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
982
983   application.GetScene().Add( labelLong );
984   // Turn on all the effects
985   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
986   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
987   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
988   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
989   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
990   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
991
992   try
993   {
994     // Render some text with the shared atlas backend
995     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
996     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
997     application.SendNotification();
998     application.Render();
999
1000     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1001     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1002     application.SendNotification();
1003     application.Render();
1004
1005   }
1006   catch( ... )
1007   {
1008     tet_result(TET_FAIL);
1009   }
1010
1011   END_TEST;
1012 }
1013
1014 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1015 {
1016   ToolkitTestApplication application;
1017   TextLabel labelShort = TextLabel::New("Some text to scroll");
1018   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!");
1019
1020   DALI_TEST_CHECK( labelShort );
1021   DALI_TEST_CHECK( labelLong );
1022   // Avoid a crash when core load gl resources.
1023   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1024   application.GetScene().Add( labelShort );
1025   // Turn on all the effects
1026   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1027   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1028   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1029   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1030   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1031   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1032
1033   application.GetScene().Add( labelLong );
1034   // Turn on all the effects
1035   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1036   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1037   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1038   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1039   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1040   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1041
1042   try
1043   {
1044     // Render some text with the shared atlas backend
1045     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1046     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1047     application.SendNotification();
1048     application.Render();
1049
1050     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1051     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1052     application.SendNotification();
1053     application.Render();
1054
1055   }
1056   catch( ... )
1057   {
1058     tet_result(TET_FAIL);
1059   }
1060
1061   END_TEST;
1062 }
1063
1064 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1065 {
1066   ToolkitTestApplication application;
1067   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1068   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1069
1070   DALI_TEST_CHECK( labelShort );
1071   DALI_TEST_CHECK( labelLong );
1072   // Avoid a crash when core load gl resources.
1073   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1074   application.GetScene().Add( labelShort );
1075   // Turn on all the effects
1076   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1077   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1078   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1079   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1080   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1081   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1082
1083   application.GetScene().Add( labelLong );
1084   // Turn on all the effects
1085   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1086   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1087   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1088   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1089   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1090   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1091
1092   try
1093   {
1094     // Render some text with the shared atlas backend
1095     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1096     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1097     application.SendNotification();
1098     application.Render();
1099
1100     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1101     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1102     application.SendNotification();
1103     application.Render();
1104
1105   }
1106   catch( ... )
1107   {
1108     tet_result(TET_FAIL);
1109   }
1110
1111   END_TEST;
1112 }
1113
1114 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1115 {
1116   ToolkitTestApplication application;
1117   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1118   TextLabel label = TextLabel::New("Some text to scroll");
1119   DALI_TEST_CHECK( label );
1120   // Avoid a crash when core load gl resources.
1121   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1122   application.GetScene().Add( label );
1123   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1124   // Turn on all the effects
1125   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1126   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1127   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1128   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1129
1130   // Render the text.
1131   application.SendNotification();
1132   application.Render();
1133
1134   unsigned int actorCount1 = label.GetChildCount();
1135   tet_printf("Initial actor count is(%d)\n", actorCount1 );
1136
1137   try
1138   {
1139     // Render some text with the shared atlas backend
1140     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1141     application.SendNotification();
1142     application.Render(2000);
1143
1144     unsigned int actorCount1 = label.GetChildCount();
1145     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1146
1147     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1148
1149     // Render the text.
1150     application.SendNotification();
1151     application.Render();
1152
1153     unsigned int actorCount2 = label.GetChildCount();
1154     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1155
1156     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1157
1158   }
1159   catch( ... )
1160   {
1161     tet_result(TET_FAIL);
1162   }
1163
1164   END_TEST;
1165 }
1166
1167 int UtcDaliToolkitTextlabelScrollingN(void)
1168 {
1169   ToolkitTestApplication application;
1170   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1171
1172   TextLabel label = TextLabel::New("Some text to scroll");
1173   DALI_TEST_CHECK( label );
1174
1175   application.GetScene().Add( label );
1176
1177   // Avoid a crash when core load gl resources.
1178   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1179
1180   // The text scrolling works only on single line text.
1181   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1182
1183   // Turn on all the effects.
1184   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1185   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1186   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1187
1188   // Enable the auto scrolling effect.
1189   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1190
1191   // The auto scrolling shouldn't be enabled.
1192   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1193   DALI_TEST_CHECK( !enabled );
1194
1195   END_TEST;
1196 }
1197
1198 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1199 {
1200   ToolkitTestApplication application;
1201   tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
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   // Turn on all the effects.
1212   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1213   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1214   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1215
1216   try
1217   {
1218     // Enable the auto scrolling effect.
1219     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1220     label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1221
1222     // Disable the ellipsis
1223     label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1224
1225     // Render the text.
1226     application.SendNotification();
1227     application.Render();
1228
1229     // Stop auto scrolling
1230     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1231
1232     // Check the ellipsis property
1233     DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1234   }
1235   catch( ... )
1236   {
1237     tet_result(TET_FAIL);
1238   }
1239
1240   END_TEST;
1241 }
1242
1243 int UtcDaliToolkitTextlabelEllipsis(void)
1244 {
1245   ToolkitTestApplication application;
1246   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1247
1248   TextLabel label = TextLabel::New("Hello world");
1249   DALI_TEST_CHECK( label );
1250
1251   // Avoid a crash when core load gl resources.
1252   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1253
1254   application.GetScene().Add( label );
1255
1256   // Turn on all the effects
1257   label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1258   label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1259   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1260
1261   try
1262   {
1263     // Render the text.
1264     application.SendNotification();
1265     application.Render();
1266   }
1267   catch( ... )
1268   {
1269     tet_result(TET_FAIL);
1270   }
1271
1272   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
1273   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1274   label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1275
1276   try
1277   {
1278     // Render the text.
1279     application.SendNotification();
1280     application.Render();
1281   }
1282   catch( ... )
1283   {
1284     tet_result(TET_FAIL);
1285   }
1286
1287
1288   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1289   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1290   label.SetProperty( Actor::Property::SIZE, Vector2( 400.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   END_TEST;
1304 }
1305
1306 int UtcDaliToolkitTextlabelTextWrapMode(void)
1307 {
1308   ToolkitTestApplication application;
1309   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1310
1311   int lineCount =0 ;
1312
1313   TextLabel label = TextLabel::New();
1314   label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1315   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1316   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1317
1318
1319
1320   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1321   application.GetScene().Add( label );
1322
1323   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1324   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1325
1326   application.SendNotification();
1327   application.Render();
1328
1329   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1330   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1331
1332   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1333   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1334
1335   application.SendNotification();
1336   application.Render();
1337
1338   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1339   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1340
1341   application.SendNotification();
1342   application.Render();
1343
1344   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1345   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1346
1347   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1348   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1349
1350   application.SendNotification();
1351   application.Render();
1352
1353   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1354   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1355
1356   tet_infoline( "Ensure invalid string does not change wrapping mode" );
1357   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1358   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1359
1360   END_TEST;
1361 }
1362
1363 int UtcDaliToolkitTextLabelColorComponents(void)
1364 {
1365   ToolkitTestApplication application;
1366
1367   TextLabel label = TextLabel::New();
1368   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1369   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1370   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1371   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1372   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1373
1374   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1375   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1376   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1377   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1378   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1379
1380   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1381   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1382   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1383   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
1384   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1385
1386   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1387   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1388   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1389
1390   // Test a transparent text - Rendering should be skipped.
1391   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1392   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1393
1394   application.GetScene().Add( label );
1395
1396   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1397   drawTrace.Enable( true );
1398
1399   application.SendNotification();
1400   application.Render();
1401
1402   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION );  // Should be rendered
1403
1404   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1405
1406   drawTrace.Reset();
1407
1408   application.SendNotification();
1409   application.Render();
1410
1411   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1412
1413   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1414
1415   drawTrace.Reset();
1416
1417   application.SendNotification();
1418   application.Render();
1419
1420   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1421
1422   END_TEST;
1423 }
1424
1425 int UtcDaliToolkitTextlabelTextStyle01(void)
1426 {
1427   ToolkitTestApplication application;
1428   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1429
1430   TextLabel label = TextLabel::New();
1431   label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1432   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1433   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1434   application.GetScene().Add( label );
1435
1436   Property::Map outlineMapSet;
1437   Property::Map outlineMapGet;
1438
1439   outlineMapSet["color"] = Color::BLUE;
1440   outlineMapSet["width"] = 2.0f;
1441   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1442
1443   application.SendNotification();
1444   application.Render();
1445
1446   Property::Map shadowMapSet;
1447   shadowMapSet.Insert( "color", "green" );
1448   shadowMapSet.Insert( "offset", "2 2" );
1449   shadowMapSet.Insert( "blurRadius", "3" );
1450   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1451
1452   outlineMapSet["color"] = Color::RED;
1453   outlineMapSet["width"] = 0.0f;
1454   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1455
1456   application.SendNotification();
1457   application.Render();
1458
1459   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1460
1461   Property::Value* colorValue = outlineMapGet.Find("color");
1462
1463   bool colorMatched( false );
1464
1465   if ( colorValue )
1466   {
1467      Property::Type valueType = colorValue->GetType();
1468
1469      if ( Property::STRING == valueType )
1470      {
1471        std::string stringValue;
1472        colorValue->Get( stringValue );
1473        if (  stringValue == "red" )
1474        {
1475          colorMatched = true;
1476        }
1477      }
1478      else if ( Property::VECTOR4 == valueType )
1479      {
1480        Vector4 colorVector4;
1481        colorValue->Get( colorVector4 );
1482        if (  colorVector4 == Color::RED )
1483        {
1484          colorMatched = true;
1485        }
1486      }
1487   }
1488
1489   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1490
1491   END_TEST;
1492 }
1493
1494 int UtcDaliToolkitTextlabelMultiline(void)
1495 {
1496   ToolkitTestApplication application;
1497   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1498
1499   TextLabel label = TextLabel::New();
1500   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1501   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1502   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1503   application.GetScene().Add( label );
1504
1505   application.SendNotification();
1506   application.Render();
1507
1508   int lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1509   DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1510
1511   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1512
1513   application.SendNotification();
1514   application.Render();
1515
1516   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1517   DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1518
1519
1520   END_TEST;
1521 }
1522
1523 int UtcDaliToolkitTextlabelTextDirection(void)
1524 {
1525   ToolkitTestApplication application;
1526   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1527
1528   TextLabel label = TextLabel::New();
1529   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1530
1531   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1532   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1533   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
1534   application.GetScene().Add( label );
1535
1536   // Test LTR text
1537   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1538
1539   // Test RTL text
1540   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1541   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1542
1543   // Test RTL text starting with weak character
1544   label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1545   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1546
1547   // Test RTL text string with emoji and weak character
1548   label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1549   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1550
1551   END_TEST;
1552 }
1553
1554 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1555 {
1556   ToolkitTestApplication application;
1557   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1558
1559   TextLabel label = TextLabel::New();
1560
1561   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP  );
1562   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1563   label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1564   label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1565   application.GetScene().Add( label );
1566   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1567
1568   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE  );
1569   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1570
1571   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM  );
1572   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1573
1574   END_TEST;
1575 }
1576
1577 int UtcDaliToolkitTextLabelBitmapFont(void)
1578 {
1579   ToolkitTestApplication application;
1580   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1581
1582   DevelText::BitmapFontDescription fontDescription;
1583   fontDescription.name = "Digits";
1584   fontDescription.underlinePosition = 0.f;
1585   fontDescription.underlineThickness = 0.f;
1586
1587   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1588   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1589   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1590   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1591   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1592   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1593   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1594   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1595   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1596   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1597   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1598
1599   TextAbstraction::BitmapFont bitmapFont;
1600   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1601
1602   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1603   fontClient.GetFontId( bitmapFont );
1604
1605   TextLabel label = TextLabel::New();
1606
1607   label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1608   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1609
1610   // 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.
1611   DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1612
1613   application.GetScene().Add( label );
1614
1615   application.SendNotification();
1616   application.Render();
1617
1618   // The text has been rendered if the height of the text-label is the height of the line.
1619   DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1620
1621   END_TEST;
1622 }
1623
1624 int ConvertPointToPixel( float point )
1625 {
1626   unsigned int horizontalDpi = 0u;
1627   unsigned int verticalDpi = 0u;
1628   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1629   fontClient.GetDpi( horizontalDpi, verticalDpi );
1630
1631   return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1632 }
1633
1634 int UtcDaliToolkitTextlabelTextFit(void)
1635 {
1636   ToolkitTestApplication application;
1637   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1638   TextLabel label = TextLabel::New();
1639   Vector2 size( 460.0f, 100.0f );
1640   label.SetProperty( Actor::Property::SIZE, size );
1641   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1642
1643    // connect to the text git changed signal.
1644   ConnectionTracker* testTracker = new ConnectionTracker();
1645   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1646   bool textFitChangedSignal = false;
1647   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1648   gTextFitChangedCallBackCalled = false;
1649
1650   // check point size
1651   Property::Map textFitMapSet;
1652   textFitMapSet["enable"] = true;
1653   textFitMapSet["minSize"] = 10.f;
1654   textFitMapSet["maxSize"] = 100.f;
1655   textFitMapSet["stepSize"] = -1.f;
1656   textFitMapSet["fontSizeType"] = "pointSize";
1657
1658   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1659   label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1660
1661   application.GetScene().Add( label );
1662
1663   application.SendNotification();
1664   application.Render();
1665
1666   const Vector3 EXPECTED_NATURAL_SIZE( 450.0f, 96.0f, 0.0f );
1667   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1668
1669   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
1670   DALI_TEST_CHECK(textFitChangedSignal);
1671
1672   // check pixel size
1673   textFitMapSet.Clear();
1674   textFitMapSet["enable"] = true;
1675   textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1676   textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1677   textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1678   textFitMapSet["fontSizeType"] = "pixelSize";
1679
1680   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1681
1682   application.SendNotification();
1683   application.Render();
1684
1685   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1686
1687   END_TEST;
1688 }
1689
1690 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1691 {
1692   ToolkitTestApplication application;
1693   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1694
1695   DevelText::BitmapFontDescription fontDescription;
1696   fontDescription.name = "Digits";
1697   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1698
1699   TextAbstraction::BitmapFont bitmapFont;
1700   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1701
1702   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1703   fontClient.GetFontId( bitmapFont );
1704
1705   TextLabel label = TextLabel::New();
1706   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1707   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1708   label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1709   label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1710   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1711
1712   Property::Map underlineMapSet;
1713   underlineMapSet.Clear();
1714   underlineMapSet.Insert( "enable", true );
1715   underlineMapSet.Insert( "color", Color::RED );
1716   underlineMapSet.Insert( "height", 1 );
1717   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1718   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1719
1720   application.GetScene().Add( label );
1721
1722   application.SendNotification();
1723   application.Render();
1724
1725   const int maxTextureSize = Dali::GetMaxTextureSize();
1726   // Whether the rendered text is greater than maxTextureSize
1727   DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1728
1729   // Check if the number of renderers is greater than 1.
1730   DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1731
1732   END_TEST;
1733 }
1734
1735 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1736 {
1737   ToolkitTestApplication application;
1738   tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1739
1740   Vector2 size( 300.0f, 100.0f );
1741
1742   Dali::Toolkit::DevelText::RendererParameters textParameters;
1743   textParameters.text = "This is a sample text to get the last index.";
1744   textParameters.layout = "multiLine";
1745   textParameters.fontSize = 20.f;
1746   textParameters.textWidth = 300u;
1747   textParameters.textHeight = 100u;
1748   textParameters.ellipsisEnabled = true;
1749   Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1750
1751   DALI_TEST_CHECK( !indexArray.Empty() );
1752   DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1753
1754   END_TEST;
1755 }
1756
1757 int UtcDaliToolkitTextlabelFontSizeScale(void)
1758 {
1759   ToolkitTestApplication application;
1760   tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1761
1762   TextLabel label = TextLabel::New();
1763   label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1764   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1765   Vector3 nonScaledSize = label.GetNaturalSize();
1766
1767   TextLabel labelScaled = TextLabel::New();
1768   labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1769   labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1770   labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1771   Vector3 scaledSize = labelScaled.GetNaturalSize();
1772
1773   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1774
1775   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1776   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1777   nonScaledSize = label.GetNaturalSize();
1778
1779   labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1780   labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1781   labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1782   scaledSize = labelScaled.GetNaturalSize();
1783
1784   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1785
1786   END_TEST;
1787 }
1788
1789 // Positive test for the anchorClicked signal.
1790 int UtcDaliToolkitTextlabelAnchorClicked(void)
1791 {
1792   ToolkitTestApplication application;
1793   tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1794   TextLabel label = TextLabel::New();
1795   DALI_TEST_CHECK(label);
1796
1797   application.GetScene().Add(label);
1798
1799   // connect to the anchor clicked signal.
1800   ConnectionTracker* testTracker = new ConnectionTracker();
1801   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1802   bool anchorClickedSignal = false;
1803   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1804
1805   gAnchorClickedCallBackCalled = false;
1806   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1807   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1808   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1809   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1810   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1811
1812   application.SendNotification();
1813   application.Render();
1814
1815   // Create a tap event to touch the text label.
1816   TestGenerateTap(application, 5.0f, 25.0f, 100);
1817   application.SendNotification();
1818   application.Render();
1819
1820   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1821   DALI_TEST_CHECK(anchorClickedSignal);
1822
1823   // reset
1824   gAnchorClickedCallBackCalled = false;
1825   anchorClickedSignal = false;
1826   label.SetProperty(TextLabel::Property::TEXT, "");
1827   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
1828
1829   application.SendNotification();
1830   application.Render();
1831
1832   // sets anchor text
1833   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1834   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1835   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1836   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1837   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1838
1839   application.SendNotification();
1840   application.Render();
1841
1842   // Create a tap event to touch the text label.
1843   TestGenerateTap(application, 5.0f, 25.0f, 200);
1844   application.SendNotification();
1845   application.Render();
1846
1847   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1848   DALI_TEST_CHECK(anchorClickedSignal);
1849
1850
1851   gAnchorClickedCallBackNotCalled = true;
1852   // Tap the outside of anchor, callback should not be called.
1853   TestGenerateTap(application, 150.f, 100.f, 300);
1854   application.SendNotification();
1855   application.Render();
1856
1857   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
1858
1859   END_TEST;
1860 }
1861
1862 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
1863 {
1864   ToolkitTestApplication application;
1865   tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
1866
1867   //TextLabel is not using Atlas but this is to unify font-size on text-controllers
1868
1869   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
1870   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1871   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
1872
1873   // Create a text editor
1874   TextLabel textLabel = TextLabel::New();
1875   //Set size to avoid automatic eliding
1876   textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
1877   //Set very large font-size using point-size
1878   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
1879   //Specify font-family
1880   textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1881   //Set text to check if appear or not
1882   textLabel.SetProperty( TextLabel::Property::TEXT, "A");
1883
1884   application.GetScene().Add( textLabel );
1885
1886   application.SendNotification();
1887   application.Render();
1888   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
1889   Vector3 naturalSize = textLabel.GetNaturalSize();
1890
1891   DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
1892   DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
1893
1894   END_TEST;
1895 }
1896
1897 int UtcDaliTextLabelHyphenWrapMode(void)
1898 {
1899   ToolkitTestApplication application;
1900   tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
1901
1902   int lineCount =0;
1903   TextLabel label = TextLabel::New();
1904   label.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ));
1905   label.SetProperty( TextLabel::Property::POINT_SIZE, 12.f );
1906   label.SetProperty( TextLabel::Property::MULTI_LINE, true);
1907   application.GetScene().Add( label );
1908   application.SendNotification();
1909   application.Render();
1910
1911   label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1912   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::HYPHENATION);
1913   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
1914
1915   application.SendNotification();
1916   application.Render();
1917
1918   lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1919   /*
1920     text will be :
1921     Hi Exp-
1922     erimen
1923   */
1924   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1925
1926   label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
1927   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::MIXED);
1928   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
1929
1930   application.SendNotification();
1931   application.Render();
1932
1933   lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1934   /*
1935     text will be :
1936     Hi
1937     Experi-
1938     men
1939   */
1940   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
1941
1942   END_TEST;
1943 }
1944
1945
1946 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
1947 {
1948   ToolkitTestApplication application;
1949
1950   tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
1951
1952   int lineCountBefore =0 ;
1953   int lineCountAfter =0 ;
1954
1955   // Create a text editor
1956   TextLabel textLabel = TextLabel::New();
1957   //Set very large font-size using point-size
1958   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
1959   //Specify font-family
1960   textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1961   //Specify size
1962   textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
1963   //Set text longer than width of textLabel
1964   textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
1965   //Set line wrap mode Character
1966   textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1967   textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
1968
1969   application.GetScene().Add( textLabel );
1970
1971   application.SendNotification();
1972   application.Render();
1973
1974
1975   lineCountBefore =  textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1976
1977   textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
1978   lineCountAfter =  textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1979
1980   // When the text changed, the Line-count should be updated according to new text.
1981   // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
1982   DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
1983   DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
1984
1985
1986   END_TEST;
1987 }
1988
1989 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
1990 {
1991   ToolkitTestApplication application;
1992   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
1993   TextLabel textLabel = TextLabel::New();
1994
1995   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
1996   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
1997
1998   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
1999   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2000   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2001
2002   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2003   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2004   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2005
2006   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2007   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2008   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2009
2010   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2011   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2012   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2013
2014   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2015   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2016   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2017
2018   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2019   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2020   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2021
2022   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2023   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2024   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2025
2026   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2027   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2028   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2029
2030   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2031   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2032   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2033
2034   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2035   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2036   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2037
2038   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2039   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2040   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2041
2042   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2043   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2044   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2045
2046
2047   END_TEST;
2048 }