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