d420979c0795404381a9bc00f7c08066f4b50645
[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 UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1109 {
1110   ToolkitTestApplication application;
1111   tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1112
1113   TextLabel label = TextLabel::New("Some text to scroll");
1114   DALI_TEST_CHECK( label );
1115
1116   Stage::GetCurrent().Add( label );
1117
1118   // Avoid a crash when core load gl resources.
1119   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1120
1121   // Turn on all the effects.
1122   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1123   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1124   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1125
1126   try
1127   {
1128     // Enable the auto scrolling effect.
1129     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1130     label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1131
1132     // Disable the ellipsis
1133     label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1134
1135     // Render the text.
1136     application.SendNotification();
1137     application.Render();
1138
1139     // Stop auto scrolling
1140     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1141
1142     // Check the ellipsis property
1143     DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1144   }
1145   catch( ... )
1146   {
1147     tet_result(TET_FAIL);
1148   }
1149
1150   END_TEST;
1151 }
1152
1153 int UtcDaliToolkitTextlabelEllipsis(void)
1154 {
1155   ToolkitTestApplication application;
1156   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1157
1158   TextLabel label = TextLabel::New("Hello world");
1159   DALI_TEST_CHECK( label );
1160
1161   // Avoid a crash when core load gl resources.
1162   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1163
1164   Stage::GetCurrent().Add( label );
1165
1166   // Turn on all the effects
1167   label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1168   label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1169   label.SetSize( 360.0f, 10.f );
1170
1171   try
1172   {
1173     // Render the text.
1174     application.SendNotification();
1175     application.Render();
1176   }
1177   catch( ... )
1178   {
1179     tet_result(TET_FAIL);
1180   }
1181
1182   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
1183   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1184   label.SetSize( 400.0f, 10.f );
1185
1186   try
1187   {
1188     // Render the text.
1189     application.SendNotification();
1190     application.Render();
1191   }
1192   catch( ... )
1193   {
1194     tet_result(TET_FAIL);
1195   }
1196
1197
1198   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1199   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1200   label.SetSize( 400.0f, 10.f );
1201
1202   try
1203   {
1204     // Render the text.
1205     application.SendNotification();
1206     application.Render();
1207   }
1208   catch( ... )
1209   {
1210     tet_result(TET_FAIL);
1211   }
1212
1213   END_TEST;
1214 }
1215
1216 int UtcDaliToolkitTextlabelTextWrapMode(void)
1217 {
1218   ToolkitTestApplication application;
1219   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1220
1221   int lineCount =0 ;
1222
1223   TextLabel label = TextLabel::New();
1224   label.SetSize( 300.0f, 300.f );
1225   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1226   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1227
1228
1229
1230   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1231   Stage::GetCurrent().Add( label );
1232
1233   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1234   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1235
1236   application.SendNotification();
1237   application.Render();
1238
1239   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1240   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1241
1242   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1243   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1244
1245   application.SendNotification();
1246   application.Render();
1247
1248   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1249   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1250
1251   application.SendNotification();
1252   application.Render();
1253
1254   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1255   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1256
1257   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1258   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1259
1260   application.SendNotification();
1261   application.Render();
1262
1263   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1264   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1265
1266   tet_infoline( "Ensure invalid string does not change wrapping mode" );
1267   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1268   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1269
1270   END_TEST;
1271 }
1272
1273 int UtcDaliToolkitTextLabelColorComponents(void)
1274 {
1275   ToolkitTestApplication application;
1276
1277   TextLabel label = TextLabel::New();
1278   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1279   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1280   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1281   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1282   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1283
1284   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1285   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1286   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1287   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1288   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1289
1290   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1291   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1292   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1293   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
1294   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1295
1296   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1297   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1298   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1299   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_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.SetSize( 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.SetSize( 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( 460.0f, 98.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 }