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