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