Merge "Fix text outline property related native TCT" into devel/master
[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", "green" );
424   shadowMapSet.Insert( "offset", "2 2" );
425
426   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
427
428   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
429   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
430   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
431
432   shadowMapSet.Clear();
433   Property::Map shadowDisabledMapGet;
434   shadowDisabledMapGet.Insert( "color", "green" );
435   shadowDisabledMapGet.Insert( "offset", "0 0" );
436
437   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
438
439   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
440   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
441   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
442
443   // Check the emboss property
444   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
445   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
446
447   // Check the outline property
448
449   // Test string type first
450   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
451   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
452   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
453
454   // Then test the property map type
455   Property::Map outlineMapSet;
456   Property::Map outlineMapGet;
457
458   outlineMapSet["color"] = Color::RED;
459   outlineMapSet["width"] = 2.0f;
460   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
461
462   outlineMapSet["color"] = "red";
463   outlineMapSet["width"] = "2";
464   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
465   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
466   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
467
468   // Check the pixel size of font
469   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
470   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
471
472   // Check the ellipsis property
473   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
474   label.SetProperty( TextLabel::Property::ELLIPSIS, true );
475   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
476
477   END_TEST;
478 }
479
480 int UtcDaliToolkitTextlabelAtlasRenderP(void)
481 {
482   ToolkitTestApplication application;
483   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
484   TextLabel label = TextLabel::New("Test Text");
485   DALI_TEST_CHECK( label );
486
487   // Avoid a crash when core load gl resources.
488   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
489
490   Stage::GetCurrent().Add( label );
491
492   // Turn on all the effects
493   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
494   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
495   label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
496   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
497   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
498   label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
499
500   try
501   {
502     // Render some text with the shared atlas backend
503     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
504     application.SendNotification();
505     application.Render();
506   }
507   catch( ... )
508   {
509     tet_result(TET_FAIL);
510   }
511
512   try
513   {
514     // Render some text with the shared atlas backend
515     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
516     application.SendNotification();
517     application.Render();
518   }
519   catch( ... )
520   {
521     tet_result(TET_FAIL);
522   }
523   END_TEST;
524 }
525
526 int UtcDaliToolkitTextLabelLanguagesP(void)
527 {
528   ToolkitTestApplication application;
529   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
530   TextLabel label = TextLabel::New();
531   DALI_TEST_CHECK( label );
532
533   Stage::GetCurrent().Add( label );
534
535   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
536                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
537                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
538                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
539                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
540                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
541
542   label.SetProperty( TextLabel::Property::TEXT, scripts );
543   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
544
545   application.SendNotification();
546   application.Render();
547
548   END_TEST;
549 }
550
551 int UtcDaliToolkitTextLabelEmojisP(void)
552 {
553   ToolkitTestApplication application;
554   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
555   TextLabel label = TextLabel::New();
556   DALI_TEST_CHECK( label );
557
558   Stage::GetCurrent().Add( label );
559
560   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
561
562   char* pathNamePtr = get_current_dir_name();
563   const std::string pathName( pathNamePtr );
564   free( pathNamePtr );
565
566   TextAbstraction::FontDescription fontDescription;
567   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
568   fontDescription.family = "BreezeColorEmoji";
569   fontDescription.width = TextAbstraction::FontWidth::NONE;
570   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
571   fontDescription.slant = TextAbstraction::FontSlant::NONE;
572
573   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
574
575   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>";
576   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
577   label.SetProperty( TextLabel::Property::TEXT, emojis );
578
579   Property::Map shadowMap;
580   shadowMap.Insert( "color", "green" );
581   shadowMap.Insert( "offset", "2 2" );
582   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
583
584   application.SendNotification();
585   application.Render();
586
587   END_TEST;
588 }
589
590 int UtcDaliToolkitTextlabelScrollingP(void)
591 {
592   ToolkitTestApplication application;
593   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
594   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
595   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
596
597   DALI_TEST_CHECK( labelImmediate );
598   DALI_TEST_CHECK( labelFinished );
599   // Avoid a crash when core load gl resources.
600   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
601   Stage::GetCurrent().Add( labelImmediate );
602   // Turn on all the effects
603   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
604   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
605   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
606   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
607   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
608
609   Stage::GetCurrent().Add( labelFinished );
610   // Turn on all the effects
611   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
612   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
613   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
614   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
615   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
616
617
618
619   try
620   {
621     // Render some text with the shared atlas backend
622     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
623     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
624     application.SendNotification();
625     application.Render();
626
627     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
628     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
629     application.SendNotification();
630     application.Render();
631
632   }
633   catch( ... )
634   {
635     tet_result(TET_FAIL);
636   }
637
638   END_TEST;
639 }
640
641 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
642 {
643   ToolkitTestApplication application;
644   TextLabel labelShort = TextLabel::New("Some text to scroll");
645   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!");
646
647   DALI_TEST_CHECK( labelShort );
648   DALI_TEST_CHECK( labelLong );
649   // Avoid a crash when core load gl resources.
650   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
651   Stage::GetCurrent().Add( labelShort );
652   // Turn on all the effects
653   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
654   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
655   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
656   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
657   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
658   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
659
660   Stage::GetCurrent().Add( labelLong );
661   // Turn on all the effects
662   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
663   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
664   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
665   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
666   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
667   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
668
669   try
670   {
671     // Render some text with the shared atlas backend
672     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
673     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
674     application.SendNotification();
675     application.Render();
676
677     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
678     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
679     application.SendNotification();
680     application.Render();
681
682   }
683   catch( ... )
684   {
685     tet_result(TET_FAIL);
686   }
687
688   END_TEST;
689 }
690
691 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
692 {
693   ToolkitTestApplication application;
694   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
695   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
696
697   DALI_TEST_CHECK( labelShort );
698   DALI_TEST_CHECK( labelLong );
699   // Avoid a crash when core load gl resources.
700   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
701   Stage::GetCurrent().Add( labelShort );
702   // Turn on all the effects
703   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
704   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
705   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
706   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
707   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
708   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
709
710   Stage::GetCurrent().Add( labelLong );
711   // Turn on all the effects
712   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
713   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
714   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
715   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
716   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
717   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
718
719   try
720   {
721     // Render some text with the shared atlas backend
722     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
723     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
724     application.SendNotification();
725     application.Render();
726
727     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
728     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
729     application.SendNotification();
730     application.Render();
731
732   }
733   catch( ... )
734   {
735     tet_result(TET_FAIL);
736   }
737
738   END_TEST;
739 }
740
741 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
742 {
743   ToolkitTestApplication application;
744   TextLabel labelShort = TextLabel::New("Some text to scroll");
745   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!");
746
747   DALI_TEST_CHECK( labelShort );
748   DALI_TEST_CHECK( labelLong );
749   // Avoid a crash when core load gl resources.
750   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
751   Stage::GetCurrent().Add( labelShort );
752   // Turn on all the effects
753   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
754   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
755   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
756   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
757   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
758   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
759
760   Stage::GetCurrent().Add( labelLong );
761   // Turn on all the effects
762   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
763   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
764   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
765   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
766   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
767   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
768
769   try
770   {
771     // Render some text with the shared atlas backend
772     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
773     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
774     application.SendNotification();
775     application.Render();
776
777     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
778     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
779     application.SendNotification();
780     application.Render();
781
782   }
783   catch( ... )
784   {
785     tet_result(TET_FAIL);
786   }
787
788   END_TEST;
789 }
790
791 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
792 {
793   ToolkitTestApplication application;
794   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
795   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
796
797   DALI_TEST_CHECK( labelShort );
798   DALI_TEST_CHECK( labelLong );
799   // Avoid a crash when core load gl resources.
800   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
801   Stage::GetCurrent().Add( labelShort );
802   // Turn on all the effects
803   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
804   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
805   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
806   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
807   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
808   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
809
810   Stage::GetCurrent().Add( labelLong );
811   // Turn on all the effects
812   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
813   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
814   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
815   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
816   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
817   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
818
819   try
820   {
821     // Render some text with the shared atlas backend
822     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
823     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
824     application.SendNotification();
825     application.Render();
826
827     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
828     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
829     application.SendNotification();
830     application.Render();
831
832   }
833   catch( ... )
834   {
835     tet_result(TET_FAIL);
836   }
837
838   END_TEST;
839 }
840
841 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
842 {
843   ToolkitTestApplication application;
844   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
845   TextLabel label = TextLabel::New("Some text to scroll");
846   DALI_TEST_CHECK( label );
847   // Avoid a crash when core load gl resources.
848   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
849   Stage::GetCurrent().Add( label );
850   label.SetSize( 360.0f, 20.f );
851   // Turn on all the effects
852   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
853   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
854   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
855   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
856
857   // Render the text.
858   application.SendNotification();
859   application.Render();
860
861   unsigned int actorCount1 = label.GetChildCount();
862   tet_printf("Initial actor count is(%d)\n", actorCount1 );
863
864   try
865   {
866     // Render some text with the shared atlas backend
867     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
868     application.SendNotification();
869     application.Render(2000);
870
871     unsigned int actorCount1 = label.GetChildCount();
872     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
873
874     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
875
876     // Render the text.
877     application.SendNotification();
878     application.Render();
879
880     unsigned int actorCount2 = label.GetChildCount();
881     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
882
883     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
884
885   }
886   catch( ... )
887   {
888     tet_result(TET_FAIL);
889   }
890
891   END_TEST;
892 }
893
894 int UtcDaliToolkitTextlabelScrollingN(void)
895 {
896   ToolkitTestApplication application;
897   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
898
899   TextLabel label = TextLabel::New("Some text to scroll");
900   DALI_TEST_CHECK( label );
901
902   Stage::GetCurrent().Add( label );
903
904   // Avoid a crash when core load gl resources.
905   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
906
907   // The text scrolling works only on single line text.
908   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
909
910   // Turn on all the effects.
911   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
912   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
913   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
914
915   // Enable the auto scrolling effect.
916   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
917
918   // The auto scrolling shouldn't be enabled.
919   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
920   DALI_TEST_CHECK( !enabled );
921
922   END_TEST;
923 }
924
925 int UtcDaliToolkitTextlabelEllipsis(void)
926 {
927   ToolkitTestApplication application;
928   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
929
930   TextLabel label = TextLabel::New("Hello world");
931   DALI_TEST_CHECK( label );
932
933   // Avoid a crash when core load gl resources.
934   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
935
936   Stage::GetCurrent().Add( label );
937
938   // Turn on all the effects
939   label.SetAnchorPoint( AnchorPoint::CENTER );
940   label.SetParentOrigin( ParentOrigin::CENTER );
941   label.SetSize( 360.0f, 10.f );
942
943   try
944   {
945     // Render the text.
946     application.SendNotification();
947     application.Render();
948   }
949   catch( ... )
950   {
951     tet_result(TET_FAIL);
952   }
953
954   END_TEST;
955 }
956
957 int UtcDaliToolkitTextlabelTextWarpMode(void)
958 {
959   ToolkitTestApplication application;
960   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
961
962   int lineCount =0 ;
963
964   TextLabel label = TextLabel::New();
965   label.SetSize( 300.0f, 300.f );
966   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
967   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
968
969
970
971   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
972   Stage::GetCurrent().Add( label );
973
974   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_WORD" );
975
976   application.SendNotification();
977   application.Render();
978
979   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
980   DALI_TEST_EQUALS( lineCount, 4, TEST_LOCATION );
981
982
983
984   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WRAP_MODE_CHARACTER" );
985
986   application.SendNotification();
987   application.Render();
988
989
990   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
991   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
992
993   END_TEST;
994 }
995
996 int UtcDaliToolkitTextLabelColorComponents(void)
997 {
998   ToolkitTestApplication application;
999
1000   TextLabel label = TextLabel::New();
1001   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1002   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1003   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1004   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1005   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1006
1007   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1008   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1009   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1010   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1011   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1012
1013   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1014   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1015   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1016   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
1017   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1018
1019   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1020   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1021   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1022   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1023
1024   END_TEST;
1025 }
1026
1027 int UtcDaliToolkitTextlabelTextStyle01(void)
1028 {
1029   ToolkitTestApplication application;
1030   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1031
1032   TextLabel label = TextLabel::New();
1033   label.SetSize( 300.0f, 300.f );
1034   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1035   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1036   Stage::GetCurrent().Add( label );
1037
1038   Property::Map outlineMapSet;
1039   Property::Map outlineMapGet;
1040
1041   outlineMapSet["color"] = Color::BLUE;
1042   outlineMapSet["width"] = 2.0f;
1043   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1044
1045   application.SendNotification();
1046   application.Render();
1047
1048   Property::Map shadowMapSet;
1049   shadowMapSet.Insert( "color", "green" );
1050   shadowMapSet.Insert( "offset", "2 2" );
1051   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1052
1053   outlineMapSet["color"] = Color::RED;
1054   outlineMapSet["width"] = 0.0f;
1055   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1056
1057   application.SendNotification();
1058   application.Render();
1059
1060   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1061
1062   Property::Value* colorValue = outlineMapGet.Find("color");
1063
1064   bool colorMatched( false );
1065
1066   if ( colorValue )
1067   {
1068      Property::Type valueType = colorValue->GetType();
1069
1070      if ( Property::STRING == valueType )
1071      {
1072        std::string stringValue;
1073        colorValue->Get( stringValue );
1074        if (  stringValue == "red" )
1075        {
1076          colorMatched = true;
1077        }
1078      }
1079      else if ( Property::VECTOR4 == valueType )
1080      {
1081        Vector4 colorVector4;
1082        colorValue->Get( colorVector4 );
1083        if (  colorVector4 == Color::RED )
1084        {
1085          colorMatched = true;
1086        }
1087      }
1088   }
1089
1090   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1091
1092   END_TEST;
1093 }