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