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