Merge "DALi Version 1.2.39" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2016 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   // Note - we can't check the defaults since the stylesheets are platform-specific
226   label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
227   DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
228
229   // Check that text can be correctly reset
230   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
231   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
232
233   // Check font properties.
234   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
235   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
236
237   Property::Map fontStyleMapSet;
238   Property::Map fontStyleMapGet;
239
240   fontStyleMapSet.Insert( "weight", "bold" );
241   fontStyleMapSet.Insert( "width", "condensed" );
242   fontStyleMapSet.Insert( "slant", "italic" );
243   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
244
245   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
246   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
247   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
248
249   // Check the old font style format.
250   fontStyleMapSet.Clear();
251   fontStyleMapSet.Insert( "weight", "thin" );
252   fontStyleMapSet.Insert( "width", "expanded" );
253   fontStyleMapSet.Insert( "slant", "oblique" );
254
255   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
256   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
257   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
258   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
259
260   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
261   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
262
263   // Reset font style.
264   fontStyleMapSet.Clear();
265   fontStyleMapSet.Insert( "weight", "normal" );
266   fontStyleMapSet.Insert( "slant", "oblique" );
267
268   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
269   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
270   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
271   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
272
273   fontStyleMapSet.Clear();
274   fontStyleMapSet.Insert( "slant", "roman" );
275
276   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
277   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
278   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
279
280   // Replace 'roman' for 'normal'.
281   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
282   if( NULL != slantValue )
283   {
284     if( "normal" == slantValue->Get<std::string>() )
285     {
286       fontStyleMapGet["slant"] = "roman";
287     }
288   }
289   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
290
291   fontStyleMapSet.Clear();
292
293   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
294   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
295   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
296   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
297
298   // Toggle multi-line
299   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
300   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
301
302   // Check that the Alignment properties can be correctly set
303   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
304   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
305   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
306   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
307
308   // Check that text color can be properly set
309   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
310   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
311   // The underline color is changed as well.
312   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
313
314   Property::Map underlineMapSet;
315   Property::Map underlineMapGet;
316
317   underlineMapSet.Insert( "enable", "false" );
318   underlineMapSet.Insert( "color", "blue" );
319   underlineMapSet.Insert( "height", "0" );
320
321   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
322   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
323   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
324
325   // Check that shadow parameters can be correctly set
326   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
327   DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
328   label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
329   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
330
331   // Check that underline parameters can be correctly set
332   label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
333   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
334   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
335   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
336   label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
337   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
338
339   TextLabel label2 = TextLabel::New( "New text" );
340   DALI_TEST_CHECK( label2 );
341   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
342
343   // Check the enable markup property.
344   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
345   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
346   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
347
348   // Check autoscroll properties
349   const int SCROLL_SPEED = 80;
350   const int SCROLL_LOOPS = 4;
351   const float SCROLL_GAP = 50.0f;
352   const float SCROLL_LOOP_DELAY = 0.3f;
353   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
354   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
355   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
356   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
357   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
358   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
359   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
360   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
361   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
362   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
363   label.SetProperty(DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
364   DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( DevelTextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
365
366   // Check the line spacing property
367   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
368   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
369   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
370
371   // Check the underline property
372
373   underlineMapSet.Clear();
374   underlineMapSet.Insert( "enable", "true" );
375   underlineMapSet.Insert( "color", "red" );
376   underlineMapSet.Insert( "height", "1" );
377
378   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
379
380   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
381   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
382   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
383
384   underlineMapSet.Clear();
385
386   Property::Map underlineDisabledMapGet;
387   underlineDisabledMapGet.Insert( "enable", "false" );
388   underlineDisabledMapGet.Insert( "color", "red" );
389   underlineDisabledMapGet.Insert( "height", "1" );
390
391   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
392   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
393   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
394   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
395
396   // Check the shadow property
397
398   Property::Map shadowMapSet;
399   Property::Map shadowMapGet;
400
401   shadowMapSet.Insert( "color", "green" );
402   shadowMapSet.Insert( "offset", "2 2" );
403
404   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
405
406   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
407   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
408   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
409
410   shadowMapSet.Clear();
411   Property::Map shadowDisabledMapGet;
412   shadowDisabledMapGet.Insert( "color", "green" );
413   shadowDisabledMapGet.Insert( "offset", "0 0" );
414
415   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
416
417   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
418   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
419   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
420
421   // Check the emboss property
422   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
423   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
424
425   // Check the outline property
426   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
427   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
428
429   // Check the pixel size of font
430   label.SetProperty( DevelTextLabel::Property::PIXEL_SIZE, 20.f );
431   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
432
433   // Check the ellipsis property
434   DALI_TEST_CHECK( !label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
435   label.SetProperty( DevelTextLabel::Property::ELLIPSIS, true );
436   DALI_TEST_CHECK( label.GetProperty<bool>( DevelTextLabel::Property::ELLIPSIS ) );
437
438   END_TEST;
439 }
440
441 int UtcDaliToolkitTextlabelAtlasRenderP(void)
442 {
443   ToolkitTestApplication application;
444   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
445   TextLabel label = TextLabel::New("Test Text");
446   DALI_TEST_CHECK( label );
447
448   // Avoid a crash when core load gl resources.
449   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
450
451   Stage::GetCurrent().Add( label );
452
453   // Turn on all the effects
454   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
455   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
456   label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
457   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
458   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
459   label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
460
461   try
462   {
463     // Render some text with the shared atlas backend
464     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
465     application.SendNotification();
466     application.Render();
467   }
468   catch( ... )
469   {
470     tet_result(TET_FAIL);
471   }
472
473   try
474   {
475     // Render some text with the shared atlas backend
476     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
477     application.SendNotification();
478     application.Render();
479   }
480   catch( ... )
481   {
482     tet_result(TET_FAIL);
483   }
484   END_TEST;
485 }
486
487 int UtcDaliToolkitTextLabelLanguagesP(void)
488 {
489   ToolkitTestApplication application;
490   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
491   TextLabel label = TextLabel::New();
492   DALI_TEST_CHECK( label );
493
494   Stage::GetCurrent().Add( label );
495
496   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
497                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
498                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
499                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
500                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
501                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
502
503   label.SetProperty( TextLabel::Property::TEXT, scripts );
504   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
505
506   application.SendNotification();
507   application.Render();
508
509   END_TEST;
510 }
511
512 int UtcDaliToolkitTextLabelEmojisP(void)
513 {
514   ToolkitTestApplication application;
515   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
516   TextLabel label = TextLabel::New();
517   DALI_TEST_CHECK( label );
518
519   Stage::GetCurrent().Add( label );
520
521   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
522
523   char* pathNamePtr = get_current_dir_name();
524   const std::string pathName( pathNamePtr );
525   free( pathNamePtr );
526
527   TextAbstraction::FontDescription fontDescription;
528   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
529   fontDescription.family = "BreezeColorEmoji";
530   fontDescription.width = TextAbstraction::FontWidth::NONE;
531   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
532   fontDescription.slant = TextAbstraction::FontSlant::NONE;
533
534   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
535
536   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>";
537   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
538   label.SetProperty( TextLabel::Property::TEXT, emojis );
539
540   application.SendNotification();
541   application.Render();
542
543   END_TEST;
544 }
545
546 int UtcDaliToolkitTextlabelScrollingP(void)
547 {
548   ToolkitTestApplication application;
549   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
550   TextLabel label = TextLabel::New("Some text to scroll");
551   DALI_TEST_CHECK( label );
552   // Avoid a crash when core load gl resources.
553   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
554   Stage::GetCurrent().Add( label );
555   // Turn on all the effects
556   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
557   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
558   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
559   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
560
561   try
562   {
563     // Render some text with the shared atlas backend
564     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
565     application.SendNotification();
566     application.Render();
567   }
568   catch( ... )
569   {
570     tet_result(TET_FAIL);
571   }
572
573   END_TEST;
574 }
575
576 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
577 {
578   ToolkitTestApplication application;
579   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
580   TextLabel label = TextLabel::New("Some text to scroll");
581   DALI_TEST_CHECK( label );
582   // Avoid a crash when core load gl resources.
583   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
584   Stage::GetCurrent().Add( label );
585   label.SetSize( 360.0f, 20.f );
586   // Turn on all the effects
587   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
588   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
589   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
590   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
591
592   // Render the text.
593   application.SendNotification();
594   application.Render();
595
596   unsigned int actorCount1 = label.GetChildCount();
597   tet_printf("Initial actor count is(%d)\n", actorCount1 );
598
599   try
600   {
601     // Render some text with the shared atlas backend
602     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
603     application.SendNotification();
604     application.Render(2000);
605
606     unsigned int actorCount1 = label.GetChildCount();
607     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
608
609     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
610
611     // Render the text.
612     application.SendNotification();
613     application.Render();
614
615     unsigned int actorCount2 = label.GetChildCount();
616     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
617
618     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
619
620   }
621   catch( ... )
622   {
623     tet_result(TET_FAIL);
624   }
625
626   END_TEST;
627 }
628
629 int UtcDaliToolkitTextlabelScrollingN(void)
630 {
631   ToolkitTestApplication application;
632   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
633
634   TextLabel label = TextLabel::New("Some text to scroll");
635   DALI_TEST_CHECK( label );
636
637   Stage::GetCurrent().Add( label );
638
639   // Avoid a crash when core load gl resources.
640   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
641
642   // The text scrolling works only on single line text.
643   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
644
645   // Turn on all the effects.
646   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
647   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
648   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
649
650   // Enable the auto scrolling effect.
651   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
652
653   // The auto scrolling shouldn't be enabled.
654   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
655   DALI_TEST_CHECK( !enabled );
656
657   END_TEST;
658 }
659
660 int UtcDaliToolkitTextlabelEllipsis(void)
661 {
662   ToolkitTestApplication application;
663   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
664
665   TextLabel label = TextLabel::New("Hello world");
666   DALI_TEST_CHECK( label );
667
668   // Avoid a crash when core load gl resources.
669   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
670
671   Stage::GetCurrent().Add( label );
672
673   // Turn on all the effects
674   label.SetAnchorPoint( AnchorPoint::CENTER );
675   label.SetParentOrigin( ParentOrigin::CENTER );
676   label.SetSize( 360.0f, 10.f );
677
678   try
679   {
680     // Render the text.
681     application.SendNotification();
682     application.Render();
683   }
684   catch( ... )
685   {
686     tet_result(TET_FAIL);
687   }
688
689   END_TEST;
690 }