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