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