Merge "Text - Fix for placement actor." 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
25 using namespace Dali;
26 using namespace Toolkit;
27
28 void dali_textlabel_startup(void)
29 {
30   test_return_value = TET_UNDEF;
31 }
32
33 void dali_textlabel_cleanup(void)
34 {
35   test_return_value = TET_PASS;
36 }
37
38 namespace
39 {
40
41 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
42 const char* const PROPERTY_NAME_TEXT = "text";
43 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
44 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
45 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
46 const char* const PROPERTY_NAME_MULTI_LINE =  "multiLine";
47 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
48 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
49 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
50 const char* const PROPERTY_NAME_SHADOW_OFFSET = "shadowOffset";
51 const char* const PROPERTY_NAME_SHADOW_COLOR = "shadowColor";
52 const char* const PROPERTY_NAME_UNDERLINE_ENABLED = "underlineEnabled";
53 const char* const PROPERTY_NAME_UNDERLINE_COLOR = "underlineColor";
54 const char* const PROPERTY_NAME_UNDERLINE_HEIGHT = "underlineHeight";
55 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
56 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
57 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
58 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
59 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
60
61 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
62 const char* const PROPERTY_NAME_UNDERLINE = "underline";
63 const char* const PROPERTY_NAME_SHADOW = "shadow";
64 const char* const PROPERTY_NAME_EMBOSS = "emboss";
65 const char* const PROPERTY_NAME_OUTLINE = "outline";
66
67 const int DEFAULT_RENDERING_BACKEND = Dali::Toolkit::Text::DEFAULT_RENDERING_BACKEND;
68 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
69 const unsigned int EMOJI_FONT_SIZE = 3968u;
70
71 bool DaliTestCheckMaps( const Property::Map& fontStyleMapGet, const Property::Map& fontStyleMapSet )
72 {
73   if( fontStyleMapGet.Count() == fontStyleMapSet.Count() )
74   {
75     for( unsigned int index = 0u; index < fontStyleMapGet.Count(); ++index )
76     {
77       const KeyValuePair& valueGet = fontStyleMapGet.GetKeyValue( index );
78
79       Property::Value* valueSet = fontStyleMapSet.Find( valueGet.first.stringKey );
80       if( NULL != valueSet )
81       {
82         if( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() )
83         {
84           tet_printf( "  Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
85           return false;
86         }
87       }
88       else
89       {
90         tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
91         return false;
92       }
93     }
94   }
95
96   return true;
97 }
98
99 } // namespace
100
101 int UtcDaliToolkitTextLabelConstructorP(void)
102 {
103   ToolkitTestApplication application;
104   tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
105   TextLabel textLabel;
106   DALI_TEST_CHECK( !textLabel );
107   END_TEST;
108 }
109
110 int UtcDaliToolkitTextLabelNewP(void)
111 {
112   ToolkitTestApplication application;
113   tet_infoline(" UtcDaliToolkitTextLabelNewP");
114   TextLabel textLabel = TextLabel::New( "Test Text" );
115   DALI_TEST_CHECK( textLabel );
116   END_TEST;
117 }
118
119 int UtcDaliToolkitTextLabelDownCastP(void)
120 {
121   ToolkitTestApplication application;
122   tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
123   TextLabel textLabel1 = TextLabel::New();
124   BaseHandle object( textLabel1 );
125
126   TextLabel textLabel2 = TextLabel::DownCast( object );
127   DALI_TEST_CHECK( textLabel2 );
128
129   TextLabel textLabel3 = DownCast< TextLabel >( object );
130   DALI_TEST_CHECK( textLabel3 );
131   END_TEST;
132 }
133
134 int UtcDaliToolkitTextLabelDownCastN(void)
135 {
136   ToolkitTestApplication application;
137   tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
138   BaseHandle uninitializedObject;
139   TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
140   DALI_TEST_CHECK( !textLabel1 );
141
142   TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
143   DALI_TEST_CHECK( !textLabel2 );
144   END_TEST;
145 }
146
147 int UtcDaliToolkitTextLabelCopyConstructorP(void)
148 {
149   ToolkitTestApplication application;
150   tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
151   TextLabel textLabel = TextLabel::New();
152   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
153
154   TextLabel copy( textLabel );
155   DALI_TEST_CHECK( copy );
156   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
157   END_TEST;
158 }
159
160 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
161 {
162   ToolkitTestApplication application;
163   tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
164   TextLabel textLabel = TextLabel::New();
165   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
166
167   TextLabel copy = textLabel;
168   DALI_TEST_CHECK( copy );
169   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
170   END_TEST;
171 }
172
173 // Positive test case for a method
174 int UtcDaliToolkitTextLabelGetPropertyP(void)
175 {
176   ToolkitTestApplication application;
177   tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
178   TextLabel label = TextLabel::New("Test Text");
179   DALI_TEST_CHECK( label );
180
181   // Check Property Indices are correct
182   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
183   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
184   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
185   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
186   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
187   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
188   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
189   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
190   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
191   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_OFFSET ) == TextLabel::Property::SHADOW_OFFSET );
192   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW_COLOR ) == TextLabel::Property::SHADOW_COLOR );
193   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_ENABLED ) == TextLabel::Property::UNDERLINE_ENABLED );
194   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_COLOR ) == TextLabel::Property::UNDERLINE_COLOR );
195   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE_HEIGHT) == TextLabel::Property::UNDERLINE_HEIGHT );
196   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
197   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
198   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
199   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
200   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
201   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
202   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
203   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
204   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
205   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
206
207   END_TEST;
208 }
209
210 int UtcDaliToolkitTextLabelSetPropertyP(void)
211 {
212   ToolkitTestApplication application;
213   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
214   TextLabel label = TextLabel::New();
215   DALI_TEST_CHECK( label );
216
217   // Note - we can't check the defaults since the stylesheets are platform-specific
218   label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
219   DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
220
221   // Check that text can be correctly reset
222   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
223   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
224
225   // Check font properties.
226   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
227   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
228
229   Property::Map fontStyleMapSet;
230   Property::Map fontStyleMapGet;
231
232   fontStyleMapSet.Insert( "weight", "bold" );
233   fontStyleMapSet.Insert( "width", "condensed" );
234   fontStyleMapSet.Insert( "slant", "italic" );
235   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
236
237   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
238   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
239   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
240
241   // Check the old font style format.
242   fontStyleMapSet.Clear();
243   fontStyleMapSet.Insert( "weight", "thin" );
244   fontStyleMapSet.Insert( "width", "expanded" );
245   fontStyleMapSet.Insert( "slant", "oblique" );
246
247   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
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   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
253   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
254
255   // Reset font style.
256   fontStyleMapSet.Clear();
257   fontStyleMapSet.Insert( "weight", "normal" );
258   fontStyleMapSet.Insert( "slant", "oblique" );
259
260   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
261   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
262   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
263   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
264
265   fontStyleMapSet.Clear();
266   fontStyleMapSet.Insert( "slant", "roman" );
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
272   // Replace 'roman' for 'normal'.
273   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
274   if( NULL != slantValue )
275   {
276     if( "normal" == slantValue->Get<std::string>() )
277     {
278       fontStyleMapGet["slant"] = "roman";
279     }
280   }
281   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
282
283   fontStyleMapSet.Clear();
284
285   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
286   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
287   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
288   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
289
290   // Toggle multi-line
291   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
292   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
293
294   // Check that the Alignment properties can be correctly set
295   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
296   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
297   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
298   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
299
300   // Check that text color can be properly set
301   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
302   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
303   // The underline color is changed as well.
304   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::BLUE, TEST_LOCATION );
305
306   Property::Map underlineMapSet;
307   Property::Map underlineMapGet;
308
309   underlineMapSet.Insert( "enable", "false" );
310   underlineMapSet.Insert( "color", "blue" );
311   underlineMapSet.Insert( "height", "0" );
312
313   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
314   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
315   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
316
317   // Check that shadow parameters can be correctly set
318   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 3.0f, 3.0f ) );
319   DALI_TEST_EQUALS( label.GetProperty<Vector2>( TextLabel::Property::SHADOW_OFFSET ), Vector2( 3.0f, 3.0f ), TEST_LOCATION );
320   label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
321   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::SHADOW_COLOR ), Color::BLUE, TEST_LOCATION );
322
323   // Check that underline parameters can be correctly set
324   label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
325   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::UNDERLINE_ENABLED ), true, TEST_LOCATION );
326   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
327   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::UNDERLINE_COLOR ), Color::RED, TEST_LOCATION );
328   label.SetProperty( TextLabel::Property::UNDERLINE_HEIGHT, 1.0f );
329   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::UNDERLINE_HEIGHT ), 1.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
330
331   TextLabel label2 = TextLabel::New( "New text" );
332   DALI_TEST_CHECK( label2 );
333   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
334
335   // Check the enable markup property.
336   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
337   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
338   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
339
340   // Check autoscroll properties
341   const int SCROLL_SPEED = 80;
342   const int SCROLL_LOOPS = 4;
343   const float SCROLL_GAP = 50.0f;
344   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
345   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
346   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
347   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
348   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
349   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
350   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
351   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
352   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
353   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
354
355   // Check the line spacing property
356   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
357   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
358   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
359
360   // Check the underline property
361
362   underlineMapSet.Clear();
363   underlineMapSet.Insert( "enable", "true" );
364   underlineMapSet.Insert( "color", "red" );
365   underlineMapSet.Insert( "height", "1" );
366
367   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
368
369   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
370   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
371   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
372
373   underlineMapSet.Clear();
374
375   Property::Map underlineDisabledMapGet;
376   underlineDisabledMapGet.Insert( "enable", "false" );
377   underlineDisabledMapGet.Insert( "color", "red" );
378   underlineDisabledMapGet.Insert( "height", "1" );
379
380   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
381   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
382   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
383   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
384
385   // Check the shadow property
386
387   Property::Map shadowMapSet;
388   Property::Map shadowMapGet;
389
390   shadowMapSet.Insert( "color", "green" );
391   shadowMapSet.Insert( "offset", "2 2" );
392
393   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
394
395   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
396   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
397   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
398
399   shadowMapSet.Clear();
400   Property::Map shadowDisabledMapGet;
401   shadowDisabledMapGet.Insert( "color", "green" );
402   shadowDisabledMapGet.Insert( "offset", "0 0" );
403
404   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
405
406   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
407   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
408   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
409
410   // Check the emboss property
411   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
412   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
413
414   // Check the outline property
415   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
416   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
417
418   END_TEST;
419 }
420
421 int UtcDaliToolkitTextlabelAtlasRenderP(void)
422 {
423   ToolkitTestApplication application;
424   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
425   TextLabel label = TextLabel::New("Test Text");
426   DALI_TEST_CHECK( label );
427
428   // Avoid a crash when core load gl resources.
429   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
430
431   Stage::GetCurrent().Add( label );
432
433   // Turn on all the effects
434   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
435   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
436   label.SetProperty( TextLabel::Property::UNDERLINE_ENABLED, true );
437   label.SetProperty( TextLabel::Property::UNDERLINE_COLOR, Color::RED );
438   label.SetProperty( TextLabel::Property::SHADOW_OFFSET, Vector2( 1.0f, 1.0f ) );
439   label.SetProperty( TextLabel::Property::SHADOW_COLOR, Color::BLUE );
440
441   try
442   {
443     // Render some text with the shared atlas backend
444     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
445     application.SendNotification();
446     application.Render();
447   }
448   catch( ... )
449   {
450     tet_result(TET_FAIL);
451   }
452
453   try
454   {
455     // Render some text with the shared atlas backend
456     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
457     application.SendNotification();
458     application.Render();
459   }
460   catch( ... )
461   {
462     tet_result(TET_FAIL);
463   }
464   END_TEST;
465 }
466
467 int UtcDaliToolkitTextLabelLanguagesP(void)
468 {
469   ToolkitTestApplication application;
470   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
471   TextLabel label = TextLabel::New();
472   DALI_TEST_CHECK( label );
473
474   Stage::GetCurrent().Add( label );
475
476   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
477                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
478                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
479                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
480                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
481                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
482
483   label.SetProperty( TextLabel::Property::TEXT, scripts );
484   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
485
486   application.SendNotification();
487   application.Render();
488
489   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
490
491   char* pathNamePtr = get_current_dir_name();
492   const std::string pathName( pathNamePtr );
493   free( pathNamePtr );
494
495   fontClient.GetFontId( pathName + DEFAULT_FONT_DIR + "/tizen/TizenColorEmoji.ttf", EMOJI_FONT_SIZE );
496
497   const std::string emojis = "<font family='TizenColorEmoji'>\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84</font>";
498   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
499   label.SetProperty( TextLabel::Property::TEXT, emojis );
500
501   application.SendNotification();
502   application.Render();
503
504   END_TEST;
505 }
506
507 int UtcDaliToolkitTextlabelScrollingP(void)
508 {
509   ToolkitTestApplication application;
510   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
511   TextLabel label = TextLabel::New("Some text to scroll");
512   DALI_TEST_CHECK( label );
513   // Avoid a crash when core load gl resources.
514   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
515   Stage::GetCurrent().Add( label );
516   // Turn on all the effects
517   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
518   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
519   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
520   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
521
522   try
523   {
524     // Render some text with the shared atlas backend
525     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
526     application.SendNotification();
527     application.Render();
528   }
529   catch( ... )
530   {
531     tet_result(TET_FAIL);
532   }
533
534   END_TEST;
535 }
536
537 int UtcDaliToolkitTextlabelScrollingN(void)
538 {
539   ToolkitTestApplication application;
540   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
541
542   TextLabel label = TextLabel::New("Some text to scroll");
543   DALI_TEST_CHECK( label );
544
545   Stage::GetCurrent().Add( label );
546
547   // Avoid a crash when core load gl resources.
548   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
549
550   // The text scrolling works only on single line text.
551   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
552
553   // Turn on all the effects.
554   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
555   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
556   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
557
558   // Enable the auto scrolling effect.
559   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
560
561   // The auto scrolling shouldn't be enabled.
562   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
563   DALI_TEST_CHECK( !enabled );
564
565   END_TEST;
566 }
567
568 int UtcDaliToolkitTextlabelEllipsis(void)
569 {
570   ToolkitTestApplication application;
571   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
572
573   TextLabel label = TextLabel::New("Hello world");
574   DALI_TEST_CHECK( label );
575
576   // Avoid a crash when core load gl resources.
577   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
578
579   Stage::GetCurrent().Add( label );
580
581   // Turn on all the effects
582   label.SetAnchorPoint( AnchorPoint::CENTER );
583   label.SetParentOrigin( ParentOrigin::CENTER );
584   label.SetSize( 360.0f, 10.f );
585
586   try
587   {
588     // Render the text.
589     application.SendNotification();
590     application.Render();
591   }
592   catch( ... )
593   {
594     tet_result(TET_FAIL);
595   }
596
597   END_TEST;
598 }