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