Merge "Support Asynchronous Loading of Animated Image" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2020 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
33 using namespace Dali;
34 using namespace Toolkit;
35
36 void dali_textlabel_startup(void)
37 {
38   test_return_value = TET_UNDEF;
39 }
40
41 void dali_textlabel_cleanup(void)
42 {
43   test_return_value = TET_PASS;
44 }
45
46 namespace
47 {
48
49 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
50 const char* const PROPERTY_NAME_TEXT = "text";
51 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
52 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
53 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
54 const char* const PROPERTY_NAME_MULTI_LINE =  "multiLine";
55 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
56 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
57 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
58 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
63
64 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
65 const char* const PROPERTY_NAME_UNDERLINE = "underline";
66 const char* const PROPERTY_NAME_SHADOW = "shadow";
67 const char* const PROPERTY_NAME_EMBOSS = "emboss";
68 const char* const PROPERTY_NAME_OUTLINE = "outline";
69 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
70
71 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
72 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
73 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
74
75 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
76 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
77
78 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
79 {
80   const Property::Map::SizeType size = mapGet.Count();
81
82   if( size == mapSet.Count() )
83   {
84     for( unsigned int index = 0u; index < size; ++index )
85     {
86       const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
87
88       // Find the keys of the 'get' map
89       Property::Index indexKey = valueGet.first.indexKey;
90       std::string stringKey = valueGet.first.stringKey;
91
92       if( !indexConversionTable.empty() )
93       {
94         if( stringKey.empty() )
95         {
96           stringKey = indexConversionTable[ indexKey ];
97         }
98
99         if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
100         {
101           Property::Index index = 0u;
102           for( auto key : indexConversionTable )
103           {
104             if( key == stringKey )
105             {
106               indexKey = index;
107               break;
108             }
109             ++index;
110           }
111         }
112       }
113
114       const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
115
116       if( nullptr != valueSet )
117       {
118         if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
119         {
120           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
121           return false;
122         }
123         else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
124         {
125           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
126           return false;
127         }
128         else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
129         {
130           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
131           return false;
132         }
133         else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
134         {
135           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
136           return false;
137         }
138         else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
139         {
140           Vector2 vector2Get = valueGet.second.Get<Vector2>();
141           Vector2 vector2Set = valueSet->Get<Vector2>();
142           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
143           return false;
144         }
145         else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
146         {
147           Vector4 vector4Get = valueGet.second.Get<Vector4>();
148           Vector4 vector4Set = valueSet->Get<Vector4>();
149           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 );
150           return false;
151         }
152       }
153       else
154       {
155         if ( valueGet.first.type == Property::Key::INDEX )
156         {
157           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
158         }
159         else
160         {
161           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
162         }
163         return false;
164       }
165     }
166   }
167
168   return true;
169 }
170
171 } // namespace
172
173 int UtcDaliToolkitTextLabelConstructorP(void)
174 {
175   ToolkitTestApplication application;
176   tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
177   TextLabel textLabel;
178   DALI_TEST_CHECK( !textLabel );
179   END_TEST;
180 }
181
182 int UtcDaliToolkitTextLabelNewP(void)
183 {
184   ToolkitTestApplication application;
185   tet_infoline(" UtcDaliToolkitTextLabelNewP");
186   TextLabel textLabel = TextLabel::New( "Test Text" );
187   DALI_TEST_CHECK( textLabel );
188   END_TEST;
189 }
190
191 int UtcDaliToolkitTextLabelDownCastP(void)
192 {
193   ToolkitTestApplication application;
194   tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
195   TextLabel textLabel1 = TextLabel::New();
196   BaseHandle object( textLabel1 );
197
198   TextLabel textLabel2 = TextLabel::DownCast( object );
199   DALI_TEST_CHECK( textLabel2 );
200
201   TextLabel textLabel3 = DownCast< TextLabel >( object );
202   DALI_TEST_CHECK( textLabel3 );
203   END_TEST;
204 }
205
206 int UtcDaliToolkitTextLabelDownCastN(void)
207 {
208   ToolkitTestApplication application;
209   tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
210   BaseHandle uninitializedObject;
211   TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
212   DALI_TEST_CHECK( !textLabel1 );
213
214   TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
215   DALI_TEST_CHECK( !textLabel2 );
216   END_TEST;
217 }
218
219 int UtcDaliToolkitTextLabelCopyConstructorP(void)
220 {
221   ToolkitTestApplication application;
222   tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
223   TextLabel textLabel = TextLabel::New();
224   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
225
226   TextLabel copy( textLabel );
227   DALI_TEST_CHECK( copy );
228   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
229   END_TEST;
230 }
231
232 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
233 {
234   ToolkitTestApplication application;
235   tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
236   TextLabel textLabel = TextLabel::New();
237   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
238
239   TextLabel copy = textLabel;
240   DALI_TEST_CHECK( copy );
241   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
242   END_TEST;
243 }
244
245 // Positive test case for a method
246 int UtcDaliToolkitTextLabelGetPropertyP(void)
247 {
248   ToolkitTestApplication application;
249   tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
250   TextLabel label = TextLabel::New("Test Text");
251   DALI_TEST_CHECK( label );
252
253   // Check Property Indices are correct
254   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
255   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
256   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
257   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
258   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
259   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
260   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
261   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
262   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
263   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
264   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
265   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
266   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
267   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
268   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
269   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
270   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
271   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
272   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
273   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
274   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
275   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
276   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
277
278   END_TEST;
279 }
280
281 int UtcDaliToolkitTextLabelSetPropertyP(void)
282 {
283   ToolkitTestApplication application;
284   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
285   TextLabel label = TextLabel::New();
286   DALI_TEST_CHECK( label );
287
288   Stage::GetCurrent().Add( label );
289
290   // Note - we can't check the defaults since the stylesheets are platform-specific
291   label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
292   DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
293
294   // Check that text can be correctly reset
295   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
296   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
297
298   // Check font properties.
299   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
300   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
301
302   Property::Map fontStyleMapSet;
303   Property::Map fontStyleMapGet;
304
305   fontStyleMapSet.Insert( "weight", "bold" );
306   fontStyleMapSet.Insert( "width", "condensed" );
307   fontStyleMapSet.Insert( "slant", "italic" );
308   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
309
310   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
311   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
312   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
313
314   // Check the old font style format.
315   fontStyleMapSet.Clear();
316   fontStyleMapSet.Insert( "weight", "thin" );
317   fontStyleMapSet.Insert( "width", "expanded" );
318   fontStyleMapSet.Insert( "slant", "oblique" );
319   const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
320
321   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
322   std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
323   DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
324
325   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
326   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
327
328   // Reset font style.
329   fontStyleMapSet.Clear();
330   fontStyleMapSet.Insert( "weight", "normal" );
331   fontStyleMapSet.Insert( "slant", "oblique" );
332
333   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
334   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
335   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
336   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
337
338   fontStyleMapSet.Clear();
339   fontStyleMapSet.Insert( "slant", "roman" );
340
341   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
342   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
343   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
344
345   // Replace 'roman' for 'normal'.
346   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
347   if( NULL != slantValue )
348   {
349     if( "normal" == slantValue->Get<std::string>() )
350     {
351       fontStyleMapGet["slant"] = "roman";
352     }
353   }
354   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
355
356   fontStyleMapSet.Clear();
357
358   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
359   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
360   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
361   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
362
363   // Toggle multi-line
364   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
365   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
366
367   // Check that the Alignment properties can be correctly set
368   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
369   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
370   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
371   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
372
373   // Check that text color can be properly set
374   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
375   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
376
377   Property::Map underlineMapSet;
378   Property::Map underlineMapGet;
379
380   underlineMapSet.Insert( "enable", false );
381   underlineMapSet.Insert( "color", Color::BLUE );
382   underlineMapSet.Insert( "height", 0 );
383
384   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
385   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
386   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
387
388   TextLabel label2 = TextLabel::New( "New text" );
389   DALI_TEST_CHECK( label2 );
390   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
391
392   // Check the enable markup property.
393   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
394   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
395   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
396
397   // Check the text property when markup is enabled
398   label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
399   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
400
401   // Check for incomplete marks.
402   label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
403   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
404   try
405   {
406     application.SendNotification();
407     application.Render();
408   }
409   catch( ... )
410   {
411     tet_result(TET_FAIL);
412   }
413
414   // Check autoscroll properties
415   const int SCROLL_SPEED = 80;
416   const int SCROLL_LOOPS = 4;
417   const float SCROLL_GAP = 50.0f;
418   const float SCROLL_LOOP_DELAY = 0.3f;
419   const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
420   const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
421
422   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
423   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
424   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
425   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
426   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
427   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
428   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
429   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
430   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
431   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
432   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
433   DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
434
435   //Check autoscroll stop type property
436   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
437   DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
438
439   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
440   DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
441
442   // test natural size with multi-line and line spacing
443   {
444     TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
445     Vector3 oneLineNaturalSize = label3.GetNaturalSize();
446     label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
447     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
448     Vector3 multiLineNaturalSize = label3.GetNaturalSize();
449
450     // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
451     // The height of the text when multi-line is enabled will be larger
452     DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
453     DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
454
455     // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
456     // Everything else will remain the same
457     int lineSpacing = 20;
458     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
459     Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
460     expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
461     DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
462   }
463
464   // single line, line spacing must not affect natural size of the text, only add the spacing to the height
465   {
466     TextLabel label3 = TextLabel::New("Some text here end there end here");
467     label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
468     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
469     Vector3 textNaturalSize = label3.GetNaturalSize();
470     int lineSpacing = 20;
471     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
472     Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
473     expectedNaturalSizeWithLineSpacing.height += lineSpacing;
474     DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
475   }
476   // Check the line spacing property
477   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
478   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
479   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
480
481   // Check the underline property
482   underlineMapSet.Clear();
483   underlineMapSet.Insert( "enable", true );
484   underlineMapSet.Insert( "color", Color::RED );
485   underlineMapSet.Insert( "height", 1 );
486
487   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
488
489   application.SendNotification();
490   application.Render();
491
492   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
493   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
494   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
495
496   underlineMapSet.Clear();
497   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
498   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
499   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
500
501   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
502
503   application.SendNotification();
504   application.Render();
505
506   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
507   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
508   std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
509   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
510
511   underlineMapSet.Clear();
512
513   Property::Map underlineDisabledMapGet;
514   underlineDisabledMapGet.Insert( "enable", false );
515   underlineDisabledMapGet.Insert( "color", Color::GREEN );
516   underlineDisabledMapGet.Insert( "height", 2 );
517
518   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
519
520   application.SendNotification();
521   application.Render();
522
523   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
524   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
525   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
526
527   // Check the shadow property
528
529   Property::Map shadowMapSet;
530   Property::Map shadowMapGet;
531
532   shadowMapSet.Insert( "color", Color::GREEN );
533   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
534   shadowMapSet.Insert( "blurRadius", 5.0f );
535
536   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
537
538   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
539   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
540   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
541
542   shadowMapSet.Clear();
543
544   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
545   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
546   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
547
548   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
549
550   // Replace the offset (string) by a vector2
551   shadowMapSet.Clear();
552   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
553   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
554   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
555
556   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
557   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
558   std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
559   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
560
561   shadowMapSet.Clear();
562   Property::Map shadowDisabledMapGet;
563   shadowDisabledMapGet.Insert( "color", Color::BLUE );
564   shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
565   shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
566
567   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
568
569   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
570   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
571   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
572
573   // Check the emboss property
574   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
575   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
576
577   // Check the outline property
578
579   // Test string type first
580   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
581   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
582   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
583
584   // Then test the property map type
585   Property::Map outlineMapSet;
586   Property::Map outlineMapGet;
587
588   outlineMapSet["color"] = Color::RED;
589   outlineMapSet["width"] = 2.0f;
590   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
591
592   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
593   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
594   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
595
596   outlineMapSet.Clear();
597   outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
598   outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
599   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
600
601   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
602   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
603   std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
604   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
605
606   // Check the background property
607   Property::Map backgroundMapSet;
608   Property::Map backgroundMapGet;
609
610   backgroundMapSet["enable"] = true;
611   backgroundMapSet["color"] = Color::RED;
612   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
613
614   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
615   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
616   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
617
618   backgroundMapSet.Clear();
619   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
620   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
621   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
622
623   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
624   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
625   std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
626   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
627
628   // Check the pixel size of font
629   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
630   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
631
632   // Check the ellipsis property
633   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
634   label.SetProperty( TextLabel::Property::ELLIPSIS, false );
635   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
636
637   // Check the layout direction property
638   label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
639   DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
640
641   // Check the line size property
642   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
643   label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
644   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
645
646   application.SendNotification();
647   application.Render();
648
649   END_TEST;
650 }
651
652 int UtcDaliToolkitTextlabelAtlasRenderP(void)
653 {
654   ToolkitTestApplication application;
655   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
656   TextLabel label = TextLabel::New("Test Text");
657   DALI_TEST_CHECK( label );
658
659   // Avoid a crash when core load gl resources.
660   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
661
662   Stage::GetCurrent().Add( label );
663
664   // Turn on all the effects
665   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
666   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
667
668   Property::Map underlineMap;
669   underlineMap.Insert( "enable", true );
670   underlineMap.Insert( "color", Color::RED );
671   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
672
673   Property::Map shadowMap;
674   shadowMap.Insert( "color", Color::BLUE );
675   shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
676   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
677
678   try
679   {
680     // Render some text with the shared atlas backend
681     label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
682     application.SendNotification();
683     application.Render();
684   }
685   catch( ... )
686   {
687     tet_result(TET_FAIL);
688   }
689
690   try
691   {
692     // Render some text with the shared atlas backend
693     label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
694     application.SendNotification();
695     application.Render();
696   }
697   catch( ... )
698   {
699     tet_result(TET_FAIL);
700   }
701   END_TEST;
702 }
703
704 int UtcDaliToolkitTextLabelLanguagesP(void)
705 {
706   ToolkitTestApplication application;
707   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
708   TextLabel label = TextLabel::New();
709   DALI_TEST_CHECK( label );
710
711   Stage::GetCurrent().Add( label );
712
713   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
714                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
715                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
716                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
717                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
718                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
719
720   label.SetProperty( TextLabel::Property::TEXT, scripts );
721   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
722
723   application.SendNotification();
724   application.Render();
725
726   END_TEST;
727 }
728
729 int UtcDaliToolkitTextLabelEmojisP(void)
730 {
731   ToolkitTestApplication application;
732   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
733   TextLabel label = TextLabel::New();
734   DALI_TEST_CHECK( label );
735
736   Stage::GetCurrent().Add( label );
737
738   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
739
740   char* pathNamePtr = get_current_dir_name();
741   const std::string pathName( pathNamePtr );
742   free( pathNamePtr );
743
744   TextAbstraction::FontDescription fontDescription;
745   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
746   fontDescription.family = "BreezeColorEmoji";
747   fontDescription.width = TextAbstraction::FontWidth::NONE;
748   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
749   fontDescription.slant = TextAbstraction::FontSlant::NONE;
750
751   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
752
753   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>";
754   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
755   label.SetProperty( TextLabel::Property::TEXT, emojis );
756
757   Property::Map shadowMap;
758   shadowMap.Insert( "color", "green" );
759   shadowMap.Insert( "offset", "2 2" );
760   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
761
762   application.SendNotification();
763   application.Render();
764
765   END_TEST;
766 }
767
768 int UtcDaliToolkitTextlabelScrollingP(void)
769 {
770   ToolkitTestApplication application;
771   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
772   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
773   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
774
775   DALI_TEST_CHECK( labelImmediate );
776   DALI_TEST_CHECK( labelFinished );
777   // Avoid a crash when core load gl resources.
778   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
779   Stage::GetCurrent().Add( labelImmediate );
780   // Turn on all the effects
781   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
782   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
783   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
784   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
785   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
786
787   Stage::GetCurrent().Add( labelFinished );
788   // Turn on all the effects
789   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
790   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
791   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
792   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
793   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
794
795
796
797   try
798   {
799     // Render some text with the shared atlas backend
800     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
801     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
802
803     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
804     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
805
806     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
807     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
808     application.SendNotification();
809     application.Render();
810
811     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
812     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
813     application.SendNotification();
814     application.Render();
815
816   }
817   catch( ... )
818   {
819     tet_result(TET_FAIL);
820   }
821
822   END_TEST;
823 }
824
825 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
826 {
827   ToolkitTestApplication application;
828   TextLabel labelShort = TextLabel::New("Some text to scroll");
829   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!");
830
831   DALI_TEST_CHECK( labelShort );
832   DALI_TEST_CHECK( labelLong );
833   // Avoid a crash when core load gl resources.
834   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
835   Stage::GetCurrent().Add( labelShort );
836   // Turn on all the effects
837   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
838   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
839   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
840   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
841   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
842   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
843
844   Stage::GetCurrent().Add( labelLong );
845   // Turn on all the effects
846   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
847   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
848   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
849   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
850   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
851   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
852
853   try
854   {
855     // Render some text with the shared atlas backend
856     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
857     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
858     application.SendNotification();
859     application.Render();
860
861     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
862     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
863     application.SendNotification();
864     application.Render();
865
866   }
867   catch( ... )
868   {
869     tet_result(TET_FAIL);
870   }
871
872   END_TEST;
873 }
874
875 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
876 {
877   ToolkitTestApplication application;
878   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
879   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
880
881   DALI_TEST_CHECK( labelShort );
882   DALI_TEST_CHECK( labelLong );
883   // Avoid a crash when core load gl resources.
884   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
885   Stage::GetCurrent().Add( labelShort );
886   // Turn on all the effects
887   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
888   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
889   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
890   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
891   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
892   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
893
894   Stage::GetCurrent().Add( labelLong );
895   // Turn on all the effects
896   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
897   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
898   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
899   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
900   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
901   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
902
903   try
904   {
905     // Render some text with the shared atlas backend
906     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
907     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
908     application.SendNotification();
909     application.Render();
910
911     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
912     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
913     application.SendNotification();
914     application.Render();
915
916   }
917   catch( ... )
918   {
919     tet_result(TET_FAIL);
920   }
921
922   END_TEST;
923 }
924
925 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
926 {
927   ToolkitTestApplication application;
928   TextLabel labelShort = TextLabel::New("Some text to scroll");
929   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!");
930
931   DALI_TEST_CHECK( labelShort );
932   DALI_TEST_CHECK( labelLong );
933   // Avoid a crash when core load gl resources.
934   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
935   Stage::GetCurrent().Add( labelShort );
936   // Turn on all the effects
937   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
938   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
939   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
940   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
941   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
942   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
943
944   Stage::GetCurrent().Add( labelLong );
945   // Turn on all the effects
946   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
947   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
948   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
949   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
950   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
951   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
952
953   try
954   {
955     // Render some text with the shared atlas backend
956     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
957     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
958     application.SendNotification();
959     application.Render();
960
961     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
962     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
963     application.SendNotification();
964     application.Render();
965
966   }
967   catch( ... )
968   {
969     tet_result(TET_FAIL);
970   }
971
972   END_TEST;
973 }
974
975 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
976 {
977   ToolkitTestApplication application;
978   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
979   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
980
981   DALI_TEST_CHECK( labelShort );
982   DALI_TEST_CHECK( labelLong );
983   // Avoid a crash when core load gl resources.
984   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
985   Stage::GetCurrent().Add( labelShort );
986   // Turn on all the effects
987   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
988   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
989   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
990   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
991   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
992   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
993
994   Stage::GetCurrent().Add( labelLong );
995   // Turn on all the effects
996   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
997   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
998   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
999   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1000   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1001   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1002
1003   try
1004   {
1005     // Render some text with the shared atlas backend
1006     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1007     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1008     application.SendNotification();
1009     application.Render();
1010
1011     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1012     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1013     application.SendNotification();
1014     application.Render();
1015
1016   }
1017   catch( ... )
1018   {
1019     tet_result(TET_FAIL);
1020   }
1021
1022   END_TEST;
1023 }
1024
1025 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1026 {
1027   ToolkitTestApplication application;
1028   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1029   TextLabel label = TextLabel::New("Some text to scroll");
1030   DALI_TEST_CHECK( label );
1031   // Avoid a crash when core load gl resources.
1032   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1033   Stage::GetCurrent().Add( label );
1034   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1035   // Turn on all the effects
1036   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1037   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1038   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1039   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1040
1041   // Render the text.
1042   application.SendNotification();
1043   application.Render();
1044
1045   unsigned int actorCount1 = label.GetChildCount();
1046   tet_printf("Initial actor count is(%d)\n", actorCount1 );
1047
1048   try
1049   {
1050     // Render some text with the shared atlas backend
1051     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1052     application.SendNotification();
1053     application.Render(2000);
1054
1055     unsigned int actorCount1 = label.GetChildCount();
1056     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1057
1058     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1059
1060     // Render the text.
1061     application.SendNotification();
1062     application.Render();
1063
1064     unsigned int actorCount2 = label.GetChildCount();
1065     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1066
1067     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1068
1069   }
1070   catch( ... )
1071   {
1072     tet_result(TET_FAIL);
1073   }
1074
1075   END_TEST;
1076 }
1077
1078 int UtcDaliToolkitTextlabelScrollingN(void)
1079 {
1080   ToolkitTestApplication application;
1081   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1082
1083   TextLabel label = TextLabel::New("Some text to scroll");
1084   DALI_TEST_CHECK( label );
1085
1086   Stage::GetCurrent().Add( label );
1087
1088   // Avoid a crash when core load gl resources.
1089   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1090
1091   // The text scrolling works only on single line text.
1092   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1093
1094   // Turn on all the effects.
1095   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1096   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1097   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1098
1099   // Enable the auto scrolling effect.
1100   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1101
1102   // The auto scrolling shouldn't be enabled.
1103   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1104   DALI_TEST_CHECK( !enabled );
1105
1106   END_TEST;
1107 }
1108
1109 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1110 {
1111   ToolkitTestApplication application;
1112   tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1113
1114   TextLabel label = TextLabel::New("Some text to scroll");
1115   DALI_TEST_CHECK( label );
1116
1117   Stage::GetCurrent().Add( label );
1118
1119   // Avoid a crash when core load gl resources.
1120   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1121
1122   // Turn on all the effects.
1123   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1124   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1125   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1126
1127   try
1128   {
1129     // Enable the auto scrolling effect.
1130     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1131     label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1132
1133     // Disable the ellipsis
1134     label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1135
1136     // Render the text.
1137     application.SendNotification();
1138     application.Render();
1139
1140     // Stop auto scrolling
1141     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1142
1143     // Check the ellipsis property
1144     DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1145   }
1146   catch( ... )
1147   {
1148     tet_result(TET_FAIL);
1149   }
1150
1151   END_TEST;
1152 }
1153
1154 int UtcDaliToolkitTextlabelEllipsis(void)
1155 {
1156   ToolkitTestApplication application;
1157   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1158
1159   TextLabel label = TextLabel::New("Hello world");
1160   DALI_TEST_CHECK( label );
1161
1162   // Avoid a crash when core load gl resources.
1163   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1164
1165   Stage::GetCurrent().Add( label );
1166
1167   // Turn on all the effects
1168   label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1169   label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1170   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1171
1172   try
1173   {
1174     // Render the text.
1175     application.SendNotification();
1176     application.Render();
1177   }
1178   catch( ... )
1179   {
1180     tet_result(TET_FAIL);
1181   }
1182
1183   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
1184   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1185   label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1186
1187   try
1188   {
1189     // Render the text.
1190     application.SendNotification();
1191     application.Render();
1192   }
1193   catch( ... )
1194   {
1195     tet_result(TET_FAIL);
1196   }
1197
1198
1199   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1200   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1201   label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1202
1203   try
1204   {
1205     // Render the text.
1206     application.SendNotification();
1207     application.Render();
1208   }
1209   catch( ... )
1210   {
1211     tet_result(TET_FAIL);
1212   }
1213
1214   END_TEST;
1215 }
1216
1217 int UtcDaliToolkitTextlabelTextWrapMode(void)
1218 {
1219   ToolkitTestApplication application;
1220   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1221
1222   int lineCount =0 ;
1223
1224   TextLabel label = TextLabel::New();
1225   label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1226   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1227   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1228
1229
1230
1231   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1232   Stage::GetCurrent().Add( label );
1233
1234   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1235   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1236
1237   application.SendNotification();
1238   application.Render();
1239
1240   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1241   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1242
1243   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1244   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1245
1246   application.SendNotification();
1247   application.Render();
1248
1249   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1250   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1251
1252   application.SendNotification();
1253   application.Render();
1254
1255   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1256   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1257
1258   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1259   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1260
1261   application.SendNotification();
1262   application.Render();
1263
1264   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1265   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1266
1267   tet_infoline( "Ensure invalid string does not change wrapping mode" );
1268   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1269   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1270
1271   END_TEST;
1272 }
1273
1274 int UtcDaliToolkitTextLabelColorComponents(void)
1275 {
1276   ToolkitTestApplication application;
1277
1278   TextLabel label = TextLabel::New();
1279   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1280   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1281   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1282   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1283   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1284
1285   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1286   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1287   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1288   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1289   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1290
1291   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1292   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1293   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1294   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
1295   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1296
1297   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1298   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1299   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1300
1301   // Test a transparent text - Rendering should be skipped.
1302   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1303   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1304
1305   Stage::GetCurrent().Add( label );
1306
1307   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1308   drawTrace.Enable( true );
1309
1310   application.SendNotification();
1311   application.Render();
1312
1313   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION );  // Should be rendered
1314
1315   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1316
1317   drawTrace.Reset();
1318
1319   application.SendNotification();
1320   application.Render();
1321
1322   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1323
1324   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1325
1326   drawTrace.Reset();
1327
1328   application.SendNotification();
1329   application.Render();
1330
1331   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1332
1333   END_TEST;
1334 }
1335
1336 int UtcDaliToolkitTextlabelTextStyle01(void)
1337 {
1338   ToolkitTestApplication application;
1339   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1340
1341   TextLabel label = TextLabel::New();
1342   label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1343   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1344   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1345   Stage::GetCurrent().Add( label );
1346
1347   Property::Map outlineMapSet;
1348   Property::Map outlineMapGet;
1349
1350   outlineMapSet["color"] = Color::BLUE;
1351   outlineMapSet["width"] = 2.0f;
1352   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1353
1354   application.SendNotification();
1355   application.Render();
1356
1357   Property::Map shadowMapSet;
1358   shadowMapSet.Insert( "color", "green" );
1359   shadowMapSet.Insert( "offset", "2 2" );
1360   shadowMapSet.Insert( "blurRadius", "3" );
1361   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1362
1363   outlineMapSet["color"] = Color::RED;
1364   outlineMapSet["width"] = 0.0f;
1365   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1366
1367   application.SendNotification();
1368   application.Render();
1369
1370   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1371
1372   Property::Value* colorValue = outlineMapGet.Find("color");
1373
1374   bool colorMatched( false );
1375
1376   if ( colorValue )
1377   {
1378      Property::Type valueType = colorValue->GetType();
1379
1380      if ( Property::STRING == valueType )
1381      {
1382        std::string stringValue;
1383        colorValue->Get( stringValue );
1384        if (  stringValue == "red" )
1385        {
1386          colorMatched = true;
1387        }
1388      }
1389      else if ( Property::VECTOR4 == valueType )
1390      {
1391        Vector4 colorVector4;
1392        colorValue->Get( colorVector4 );
1393        if (  colorVector4 == Color::RED )
1394        {
1395          colorMatched = true;
1396        }
1397      }
1398   }
1399
1400   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1401
1402   END_TEST;
1403 }
1404
1405 int UtcDaliToolkitTextlabelMultiline(void)
1406 {
1407   ToolkitTestApplication application;
1408   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1409
1410   TextLabel label = TextLabel::New();
1411   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1412   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1413   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1414   Stage::GetCurrent().Add( label );
1415
1416   application.SendNotification();
1417   application.Render();
1418
1419   int lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1420   DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1421
1422   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1423
1424   application.SendNotification();
1425   application.Render();
1426
1427   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1428   DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1429
1430
1431   END_TEST;
1432 }
1433
1434 int UtcDaliToolkitTextlabelTextDirection(void)
1435 {
1436   ToolkitTestApplication application;
1437   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1438
1439   TextLabel label = TextLabel::New();
1440   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1441
1442   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1443   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1444   Stage::GetCurrent().Add( label );
1445
1446   // Test LTR text
1447   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1448
1449   // Test RTL text
1450   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1451   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1452
1453   // Test RTL text starting with weak character
1454   label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1455   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1456
1457   // Test RTL text string with emoji and weak character
1458   label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1459   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1460
1461   END_TEST;
1462 }
1463
1464 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1465 {
1466   ToolkitTestApplication application;
1467   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1468
1469   TextLabel label = TextLabel::New();
1470
1471   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP  );
1472   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1473   label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1474   label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1475   Stage::GetCurrent().Add( label );
1476   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1477
1478   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE  );
1479   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1480
1481   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM  );
1482   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1483
1484   END_TEST;
1485 }
1486
1487 int UtcDaliToolkitTextLabelBitmapFont(void)
1488 {
1489   ToolkitTestApplication application;
1490   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1491
1492   DevelText::BitmapFontDescription fontDescription;
1493   fontDescription.name = "Digits";
1494   fontDescription.underlinePosition = 0.f;
1495   fontDescription.underlineThickness = 0.f;
1496
1497   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1498   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1499   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1500   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1501   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1502   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1503   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1504   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1505   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1506   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1507   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1508
1509   TextAbstraction::BitmapFont bitmapFont;
1510   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1511
1512   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1513   fontClient.GetFontId( bitmapFont );
1514
1515   TextLabel label = TextLabel::New();
1516
1517   label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1518   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1519
1520   // 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.
1521   DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1522
1523   Stage::GetCurrent().Add( label );
1524
1525   application.SendNotification();
1526   application.Render();
1527
1528   // The text has been rendered if the height of the text-label is the height of the line.
1529   DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1530
1531   END_TEST;
1532 }
1533
1534 int ConvertPointToPixel( float point )
1535 {
1536   unsigned int horizontalDpi = 0u;
1537   unsigned int verticalDpi = 0u;
1538   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1539   fontClient.GetDpi( horizontalDpi, verticalDpi );
1540
1541   return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1542 }
1543
1544 int UtcDaliToolkitTextlabelTextFit(void)
1545 {
1546   ToolkitTestApplication application;
1547   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1548   TextLabel label = TextLabel::New();
1549   Vector2 size( 460.0f, 100.0f );
1550   label.SetProperty( Actor::Property::SIZE, size );
1551   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1552
1553   // check point size
1554   Property::Map textFitMapSet;
1555   textFitMapSet["enable"] = true;
1556   textFitMapSet["minSize"] = 10.f;
1557   textFitMapSet["maxSize"] = 100.f;
1558   textFitMapSet["stepSize"] = -1.f;
1559   textFitMapSet["fontSizeType"] = "pointSize";
1560
1561   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1562   label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1563
1564   Stage::GetCurrent().Add( label );
1565
1566   application.SendNotification();
1567   application.Render();
1568
1569   const Vector3 EXPECTED_NATURAL_SIZE( 452.0f, 94.0f, 0.0f );
1570   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1571
1572   // check pixel size
1573   textFitMapSet.Clear();
1574   textFitMapSet["enable"] = true;
1575   textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1576   textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1577   textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1578   textFitMapSet["fontSizeType"] = "pixelSize";
1579
1580   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1581
1582   application.SendNotification();
1583   application.Render();
1584
1585   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1586
1587   END_TEST;
1588 }
1589
1590 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1591 {
1592   ToolkitTestApplication application;
1593   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1594
1595   DevelText::BitmapFontDescription fontDescription;
1596   fontDescription.name = "Digits";
1597   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1598
1599   TextAbstraction::BitmapFont bitmapFont;
1600   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1601
1602   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1603   fontClient.GetFontId( bitmapFont );
1604
1605   TextLabel label = TextLabel::New();
1606   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1607   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1608   label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1609   label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1610   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1611
1612   Property::Map underlineMapSet;
1613   underlineMapSet.Clear();
1614   underlineMapSet.Insert( "enable", true );
1615   underlineMapSet.Insert( "color", Color::RED );
1616   underlineMapSet.Insert( "height", 1 );
1617   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1618   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1619
1620   Stage::GetCurrent().Add( label );
1621
1622   application.SendNotification();
1623   application.Render();
1624
1625   const int maxTextureSize = Dali::GetMaxTextureSize();
1626   // Whether the rendered text is greater than maxTextureSize
1627   DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1628
1629   // Check if the number of renderers is greater than 1.
1630   DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1631
1632   END_TEST;
1633 }