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