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