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