Merge "DALi Version 1.9.9" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2019 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/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
27 #include <dali/devel-api/text-abstraction/bitmap-font.h>
28 #include <dali/devel-api/text-abstraction/font-client.h>
29 #include <dali/devel-api/adaptor-framework/image-loading.h>
30 #include <dali-toolkit/devel-api/text/bitmap-font.h>
31
32 using namespace Dali;
33 using namespace Toolkit;
34
35 void dali_textlabel_startup(void)
36 {
37   test_return_value = TET_UNDEF;
38 }
39
40 void dali_textlabel_cleanup(void)
41 {
42   test_return_value = TET_PASS;
43 }
44
45 namespace
46 {
47
48 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
49 const char* const PROPERTY_NAME_TEXT = "text";
50 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
51 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
52 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
53 const char* const PROPERTY_NAME_MULTI_LINE =  "multiLine";
54 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
55 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
56 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
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 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
69
70 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
71 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
72 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
73
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& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
78 {
79   const Property::Map::SizeType size = mapGet.Count();
80
81   if( size == mapSet.Count() )
82   {
83     for( unsigned int index = 0u; index < size; ++index )
84     {
85       const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
86
87       // Find the keys of the 'get' map
88       Property::Index indexKey = valueGet.first.indexKey;
89       std::string stringKey = valueGet.first.stringKey;
90
91       if( !indexConversionTable.empty() )
92       {
93         if( stringKey.empty() )
94         {
95           stringKey = indexConversionTable[ indexKey ];
96         }
97
98         if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
99         {
100           Property::Index index = 0u;
101           for( auto key : indexConversionTable )
102           {
103             if( key == stringKey )
104             {
105               indexKey = index;
106               break;
107             }
108             ++index;
109           }
110         }
111       }
112
113       const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
114
115       if( nullptr != valueSet )
116       {
117         if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
118         {
119           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
120           return false;
121         }
122         else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
123         {
124           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
125           return false;
126         }
127         else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
128         {
129           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
130           return false;
131         }
132         else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
133         {
134           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
135           return false;
136         }
137         else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
138         {
139           Vector2 vector2Get = valueGet.second.Get<Vector2>();
140           Vector2 vector2Set = valueSet->Get<Vector2>();
141           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
142           return false;
143         }
144         else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
145         {
146           Vector4 vector4Get = valueGet.second.Get<Vector4>();
147           Vector4 vector4Set = valueSet->Get<Vector4>();
148           tet_printf( "Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a );
149           return false;
150         }
151       }
152       else
153       {
154         if ( valueGet.first.type == Property::Key::INDEX )
155         {
156           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
157         }
158         else
159         {
160           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
161         }
162         return false;
163       }
164     }
165   }
166
167   return true;
168 }
169
170 } // namespace
171
172 int UtcDaliToolkitTextLabelConstructorP(void)
173 {
174   ToolkitTestApplication application;
175   tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
176   TextLabel textLabel;
177   DALI_TEST_CHECK( !textLabel );
178   END_TEST;
179 }
180
181 int UtcDaliToolkitTextLabelNewP(void)
182 {
183   ToolkitTestApplication application;
184   tet_infoline(" UtcDaliToolkitTextLabelNewP");
185   TextLabel textLabel = TextLabel::New( "Test Text" );
186   DALI_TEST_CHECK( textLabel );
187   END_TEST;
188 }
189
190 int UtcDaliToolkitTextLabelDownCastP(void)
191 {
192   ToolkitTestApplication application;
193   tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
194   TextLabel textLabel1 = TextLabel::New();
195   BaseHandle object( textLabel1 );
196
197   TextLabel textLabel2 = TextLabel::DownCast( object );
198   DALI_TEST_CHECK( textLabel2 );
199
200   TextLabel textLabel3 = DownCast< TextLabel >( object );
201   DALI_TEST_CHECK( textLabel3 );
202   END_TEST;
203 }
204
205 int UtcDaliToolkitTextLabelDownCastN(void)
206 {
207   ToolkitTestApplication application;
208   tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
209   BaseHandle uninitializedObject;
210   TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
211   DALI_TEST_CHECK( !textLabel1 );
212
213   TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
214   DALI_TEST_CHECK( !textLabel2 );
215   END_TEST;
216 }
217
218 int UtcDaliToolkitTextLabelCopyConstructorP(void)
219 {
220   ToolkitTestApplication application;
221   tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
222   TextLabel textLabel = TextLabel::New();
223   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
224
225   TextLabel copy( textLabel );
226   DALI_TEST_CHECK( copy );
227   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
228   END_TEST;
229 }
230
231 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
232 {
233   ToolkitTestApplication application;
234   tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
235   TextLabel textLabel = TextLabel::New();
236   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
237
238   TextLabel copy = textLabel;
239   DALI_TEST_CHECK( copy );
240   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
241   END_TEST;
242 }
243
244 // Positive test case for a method
245 int UtcDaliToolkitTextLabelGetPropertyP(void)
246 {
247   ToolkitTestApplication application;
248   tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
249   TextLabel label = TextLabel::New("Test Text");
250   DALI_TEST_CHECK( label );
251
252   // Check Property Indices are correct
253   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == TextLabel::Property::RENDERING_BACKEND );
254   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
255   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
256   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
257   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
258   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
259   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
260   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
261   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
262   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
263   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
264   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
265   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
266   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
267   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
268   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
269   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
270   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
271   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
272   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
273   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
274   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
275   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
276
277   END_TEST;
278 }
279
280 int UtcDaliToolkitTextLabelSetPropertyP(void)
281 {
282   ToolkitTestApplication application;
283   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
284   TextLabel label = TextLabel::New();
285   DALI_TEST_CHECK( label );
286
287   Stage::GetCurrent().Add( label );
288
289   // Note - we can't check the defaults since the stylesheets are platform-specific
290   label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
291   DALI_TEST_EQUALS( (Text::RenderingType)label.GetProperty<int>( TextLabel::Property::RENDERING_BACKEND ), Text::RENDERING_SHARED_ATLAS, TEST_LOCATION );
292
293   // Check that text can be correctly reset
294   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
295   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
296
297   // Check font properties.
298   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
299   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
300
301   Property::Map fontStyleMapSet;
302   Property::Map fontStyleMapGet;
303
304   fontStyleMapSet.Insert( "weight", "bold" );
305   fontStyleMapSet.Insert( "width", "condensed" );
306   fontStyleMapSet.Insert( "slant", "italic" );
307   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
308
309   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
310   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
311   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
312
313   // Check the old font style format.
314   fontStyleMapSet.Clear();
315   fontStyleMapSet.Insert( "weight", "thin" );
316   fontStyleMapSet.Insert( "width", "expanded" );
317   fontStyleMapSet.Insert( "slant", "oblique" );
318   const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
319
320   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
321   std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
322   DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
323
324   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
325   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
326
327   // Reset font style.
328   fontStyleMapSet.Clear();
329   fontStyleMapSet.Insert( "weight", "normal" );
330   fontStyleMapSet.Insert( "slant", "oblique" );
331
332   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
333   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
334   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
335   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
336
337   fontStyleMapSet.Clear();
338   fontStyleMapSet.Insert( "slant", "roman" );
339
340   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
341   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
342   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
343
344   // Replace 'roman' for 'normal'.
345   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
346   if( NULL != slantValue )
347   {
348     if( "normal" == slantValue->Get<std::string>() )
349     {
350       fontStyleMapGet["slant"] = "roman";
351     }
352   }
353   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
354
355   fontStyleMapSet.Clear();
356
357   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
358   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
359   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
360   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
361
362   // Toggle multi-line
363   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
364   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
365
366   // Check that the Alignment properties can be correctly set
367   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
368   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
369   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
370   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
371
372   // Check that text color can be properly set
373   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
374   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
375
376   Property::Map underlineMapSet;
377   Property::Map underlineMapGet;
378
379   underlineMapSet.Insert( "enable", false );
380   underlineMapSet.Insert( "color", Color::BLUE );
381   underlineMapSet.Insert( "height", 0 );
382
383   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
384   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
385   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
386
387   TextLabel label2 = TextLabel::New( "New text" );
388   DALI_TEST_CHECK( label2 );
389   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
390
391   // Check the enable markup property.
392   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
393   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
394   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
395
396   // Check the text property when markup is enabled
397   label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
398   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
399
400   // Check for incomplete marks.
401   label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
402   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
403   try
404   {
405     application.SendNotification();
406     application.Render();
407   }
408   catch( ... )
409   {
410     tet_result(TET_FAIL);
411   }
412
413   // Check autoscroll properties
414   const int SCROLL_SPEED = 80;
415   const int SCROLL_LOOPS = 4;
416   const float SCROLL_GAP = 50.0f;
417   const float SCROLL_LOOP_DELAY = 0.3f;
418   const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
419   const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
420
421   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
422   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
423   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
424   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
425   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
426   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
427   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
428   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
429   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
430   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
431   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
432   DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
433
434   //Check autoscroll stop type property
435   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
436   DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
437
438   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
439   DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
440
441   // test natural size with multi-line and line spacing
442   {
443     TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
444     Vector3 oneLineNaturalSize = label3.GetNaturalSize();
445     label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
446     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
447     Vector3 multiLineNaturalSize = label3.GetNaturalSize();
448
449     // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
450     // The height of the text when multi-line is enabled will be larger
451     DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
452     DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
453
454     // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
455     // Everything else will remain the same
456     int lineSpacing = 20;
457     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
458     Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
459     expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
460     DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
461   }
462
463   // single line, line spacing must not affect natural size of the text, only add the spacing to the height
464   {
465     TextLabel label3 = TextLabel::New("Some text here end there end here");
466     label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
467     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
468     Vector3 textNaturalSize = label3.GetNaturalSize();
469     int lineSpacing = 20;
470     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
471     Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
472     expectedNaturalSizeWithLineSpacing.height += lineSpacing;
473     DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
474   }
475   // Check the line spacing property
476   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
477   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
478   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
479
480   // Check the underline property
481   underlineMapSet.Clear();
482   underlineMapSet.Insert( "enable", true );
483   underlineMapSet.Insert( "color", Color::RED );
484   underlineMapSet.Insert( "height", 1 );
485
486   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
487
488   application.SendNotification();
489   application.Render();
490
491   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
492   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
493   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
494
495   underlineMapSet.Clear();
496   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
497   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
498   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
499
500   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
501
502   application.SendNotification();
503   application.Render();
504
505   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
506   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
507   std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
508   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
509
510   underlineMapSet.Clear();
511
512   Property::Map underlineDisabledMapGet;
513   underlineDisabledMapGet.Insert( "enable", false );
514   underlineDisabledMapGet.Insert( "color", Color::GREEN );
515   underlineDisabledMapGet.Insert( "height", 2 );
516
517   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
518
519   application.SendNotification();
520   application.Render();
521
522   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
523   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
524   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
525
526   // Check the shadow property
527
528   Property::Map shadowMapSet;
529   Property::Map shadowMapGet;
530
531   shadowMapSet.Insert( "color", Color::GREEN );
532   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
533   shadowMapSet.Insert( "blurRadius", 5.0f );
534
535   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
536
537   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
538   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
539   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
540
541   shadowMapSet.Clear();
542
543   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
544   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
545   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
546
547   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
548
549   // Replace the offset (string) by a vector2
550   shadowMapSet.Clear();
551   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
552   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
553   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
554
555   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
556   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
557   std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
558   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
559
560   shadowMapSet.Clear();
561   Property::Map shadowDisabledMapGet;
562   shadowDisabledMapGet.Insert( "color", Color::BLUE );
563   shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
564   shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
565
566   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
567
568   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
569   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
570   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
571
572   // Check the emboss property
573   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
574   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
575
576   // Check the outline property
577
578   // Test string type first
579   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
580   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
581   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
582
583   // Then test the property map type
584   Property::Map outlineMapSet;
585   Property::Map outlineMapGet;
586
587   outlineMapSet["color"] = Color::RED;
588   outlineMapSet["width"] = 2.0f;
589   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
590
591   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
592   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
593   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
594
595   outlineMapSet.Clear();
596   outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
597   outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
598   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
599
600   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
601   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
602   std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
603   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
604
605   // Check the background property
606   Property::Map backgroundMapSet;
607   Property::Map backgroundMapGet;
608
609   backgroundMapSet["enable"] = true;
610   backgroundMapSet["color"] = Color::RED;
611   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
612
613   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
614   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
615   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
616
617   backgroundMapSet.Clear();
618   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
619   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
620   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
621
622   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
623   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
624   std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
625   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
626
627   // Check the pixel size of font
628   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
629   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
630
631   // Check the ellipsis property
632   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
633   label.SetProperty( TextLabel::Property::ELLIPSIS, false );
634   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
635
636   // Check the layout direction property
637   label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
638   DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
639
640   application.SendNotification();
641   application.Render();
642
643   END_TEST;
644 }
645
646 int UtcDaliToolkitTextlabelAtlasRenderP(void)
647 {
648   ToolkitTestApplication application;
649   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
650   TextLabel label = TextLabel::New("Test Text");
651   DALI_TEST_CHECK( label );
652
653   // Avoid a crash when core load gl resources.
654   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
655
656   Stage::GetCurrent().Add( label );
657
658   // Turn on all the effects
659   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
660   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
661
662   Property::Map underlineMap;
663   underlineMap.Insert( "enable", true );
664   underlineMap.Insert( "color", Color::RED );
665   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
666
667   Property::Map shadowMap;
668   shadowMap.Insert( "color", Color::BLUE );
669   shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
670   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
671
672   try
673   {
674     // Render some text with the shared atlas backend
675     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_SHARED_ATLAS );
676     application.SendNotification();
677     application.Render();
678   }
679   catch( ... )
680   {
681     tet_result(TET_FAIL);
682   }
683
684   try
685   {
686     // Render some text with the shared atlas backend
687     label.SetProperty( TextLabel::Property::RENDERING_BACKEND, Text::RENDERING_VECTOR_BASED );
688     application.SendNotification();
689     application.Render();
690   }
691   catch( ... )
692   {
693     tet_result(TET_FAIL);
694   }
695   END_TEST;
696 }
697
698 int UtcDaliToolkitTextLabelLanguagesP(void)
699 {
700   ToolkitTestApplication application;
701   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
702   TextLabel label = TextLabel::New();
703   DALI_TEST_CHECK( label );
704
705   Stage::GetCurrent().Add( label );
706
707   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
708                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
709                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
710                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
711                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
712                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
713
714   label.SetProperty( TextLabel::Property::TEXT, scripts );
715   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
716
717   application.SendNotification();
718   application.Render();
719
720   END_TEST;
721 }
722
723 int UtcDaliToolkitTextLabelEmojisP(void)
724 {
725   ToolkitTestApplication application;
726   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
727   TextLabel label = TextLabel::New();
728   DALI_TEST_CHECK( label );
729
730   Stage::GetCurrent().Add( label );
731
732   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
733
734   char* pathNamePtr = get_current_dir_name();
735   const std::string pathName( pathNamePtr );
736   free( pathNamePtr );
737
738   TextAbstraction::FontDescription fontDescription;
739   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
740   fontDescription.family = "BreezeColorEmoji";
741   fontDescription.width = TextAbstraction::FontWidth::NONE;
742   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
743   fontDescription.slant = TextAbstraction::FontSlant::NONE;
744
745   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
746
747   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>";
748   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
749   label.SetProperty( TextLabel::Property::TEXT, emojis );
750
751   Property::Map shadowMap;
752   shadowMap.Insert( "color", "green" );
753   shadowMap.Insert( "offset", "2 2" );
754   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
755
756   application.SendNotification();
757   application.Render();
758
759   END_TEST;
760 }
761
762 int UtcDaliToolkitTextlabelScrollingP(void)
763 {
764   ToolkitTestApplication application;
765   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
766   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
767   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
768
769   DALI_TEST_CHECK( labelImmediate );
770   DALI_TEST_CHECK( labelFinished );
771   // Avoid a crash when core load gl resources.
772   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
773   Stage::GetCurrent().Add( labelImmediate );
774   // Turn on all the effects
775   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
776   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
777   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
778   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
779   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
780
781   Stage::GetCurrent().Add( labelFinished );
782   // Turn on all the effects
783   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
784   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
785   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
786   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
787   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
788
789
790
791   try
792   {
793     // Render some text with the shared atlas backend
794     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
795     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
796
797     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
798     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
799
800     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
801     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
802     application.SendNotification();
803     application.Render();
804
805     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
806     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
807     application.SendNotification();
808     application.Render();
809
810   }
811   catch( ... )
812   {
813     tet_result(TET_FAIL);
814   }
815
816   END_TEST;
817 }
818
819 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
820 {
821   ToolkitTestApplication application;
822   TextLabel labelShort = TextLabel::New("Some text to scroll");
823   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!");
824
825   DALI_TEST_CHECK( labelShort );
826   DALI_TEST_CHECK( labelLong );
827   // Avoid a crash when core load gl resources.
828   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
829   Stage::GetCurrent().Add( labelShort );
830   // Turn on all the effects
831   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
832   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
833   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
834   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
835   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
836   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
837
838   Stage::GetCurrent().Add( labelLong );
839   // Turn on all the effects
840   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
841   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
842   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
843   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
844   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
845   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
846
847   try
848   {
849     // Render some text with the shared atlas backend
850     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
851     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
852     application.SendNotification();
853     application.Render();
854
855     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
856     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
857     application.SendNotification();
858     application.Render();
859
860   }
861   catch( ... )
862   {
863     tet_result(TET_FAIL);
864   }
865
866   END_TEST;
867 }
868
869 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
870 {
871   ToolkitTestApplication application;
872   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
873   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
874
875   DALI_TEST_CHECK( labelShort );
876   DALI_TEST_CHECK( labelLong );
877   // Avoid a crash when core load gl resources.
878   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
879   Stage::GetCurrent().Add( labelShort );
880   // Turn on all the effects
881   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
882   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
883   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
884   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
885   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
886   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
887
888   Stage::GetCurrent().Add( labelLong );
889   // Turn on all the effects
890   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
891   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
892   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
893   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
894   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
895   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
896
897   try
898   {
899     // Render some text with the shared atlas backend
900     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
901     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
902     application.SendNotification();
903     application.Render();
904
905     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
906     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
907     application.SendNotification();
908     application.Render();
909
910   }
911   catch( ... )
912   {
913     tet_result(TET_FAIL);
914   }
915
916   END_TEST;
917 }
918
919 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
920 {
921   ToolkitTestApplication application;
922   TextLabel labelShort = TextLabel::New("Some text to scroll");
923   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!");
924
925   DALI_TEST_CHECK( labelShort );
926   DALI_TEST_CHECK( labelLong );
927   // Avoid a crash when core load gl resources.
928   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
929   Stage::GetCurrent().Add( labelShort );
930   // Turn on all the effects
931   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
932   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
933   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
934   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
935   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
936   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
937
938   Stage::GetCurrent().Add( labelLong );
939   // Turn on all the effects
940   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
941   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
942   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
943   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
944   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
945   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
946
947   try
948   {
949     // Render some text with the shared atlas backend
950     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
951     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
952     application.SendNotification();
953     application.Render();
954
955     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
956     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
957     application.SendNotification();
958     application.Render();
959
960   }
961   catch( ... )
962   {
963     tet_result(TET_FAIL);
964   }
965
966   END_TEST;
967 }
968
969 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
970 {
971   ToolkitTestApplication application;
972   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
973   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
974
975   DALI_TEST_CHECK( labelShort );
976   DALI_TEST_CHECK( labelLong );
977   // Avoid a crash when core load gl resources.
978   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
979   Stage::GetCurrent().Add( labelShort );
980   // Turn on all the effects
981   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
982   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
983   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
984   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
985   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
986   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
987
988   Stage::GetCurrent().Add( labelLong );
989   // Turn on all the effects
990   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
991   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
992   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
993   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
994   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
995   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
996
997   try
998   {
999     // Render some text with the shared atlas backend
1000     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1001     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1002     application.SendNotification();
1003     application.Render();
1004
1005     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1006     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1007     application.SendNotification();
1008     application.Render();
1009
1010   }
1011   catch( ... )
1012   {
1013     tet_result(TET_FAIL);
1014   }
1015
1016   END_TEST;
1017 }
1018
1019 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1020 {
1021   ToolkitTestApplication application;
1022   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1023   TextLabel label = TextLabel::New("Some text to scroll");
1024   DALI_TEST_CHECK( label );
1025   // Avoid a crash when core load gl resources.
1026   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1027   Stage::GetCurrent().Add( label );
1028   label.SetSize( 360.0f, 20.f );
1029   // Turn on all the effects
1030   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1031   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1032   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1033   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1034
1035   // Render the text.
1036   application.SendNotification();
1037   application.Render();
1038
1039   unsigned int actorCount1 = label.GetChildCount();
1040   tet_printf("Initial actor count is(%d)\n", actorCount1 );
1041
1042   try
1043   {
1044     // Render some text with the shared atlas backend
1045     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1046     application.SendNotification();
1047     application.Render(2000);
1048
1049     unsigned int actorCount1 = label.GetChildCount();
1050     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1051
1052     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1053
1054     // Render the text.
1055     application.SendNotification();
1056     application.Render();
1057
1058     unsigned int actorCount2 = label.GetChildCount();
1059     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1060
1061     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1062
1063   }
1064   catch( ... )
1065   {
1066     tet_result(TET_FAIL);
1067   }
1068
1069   END_TEST;
1070 }
1071
1072 int UtcDaliToolkitTextlabelScrollingN(void)
1073 {
1074   ToolkitTestApplication application;
1075   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1076
1077   TextLabel label = TextLabel::New("Some text to scroll");
1078   DALI_TEST_CHECK( label );
1079
1080   Stage::GetCurrent().Add( label );
1081
1082   // Avoid a crash when core load gl resources.
1083   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1084
1085   // The text scrolling works only on single line text.
1086   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1087
1088   // Turn on all the effects.
1089   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1090   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1091   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1092
1093   // Enable the auto scrolling effect.
1094   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1095
1096   // The auto scrolling shouldn't be enabled.
1097   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1098   DALI_TEST_CHECK( !enabled );
1099
1100   END_TEST;
1101 }
1102
1103 int UtcDaliToolkitTextlabelEllipsis(void)
1104 {
1105   ToolkitTestApplication application;
1106   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1107
1108   TextLabel label = TextLabel::New("Hello world");
1109   DALI_TEST_CHECK( label );
1110
1111   // Avoid a crash when core load gl resources.
1112   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1113
1114   Stage::GetCurrent().Add( label );
1115
1116   // Turn on all the effects
1117   label.SetAnchorPoint( AnchorPoint::CENTER );
1118   label.SetParentOrigin( ParentOrigin::CENTER );
1119   label.SetSize( 360.0f, 10.f );
1120
1121   try
1122   {
1123     // Render the text.
1124     application.SendNotification();
1125     application.Render();
1126   }
1127   catch( ... )
1128   {
1129     tet_result(TET_FAIL);
1130   }
1131
1132   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
1133   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1134   label.SetSize( 400.0f, 10.f );
1135
1136   try
1137   {
1138     // Render the text.
1139     application.SendNotification();
1140     application.Render();
1141   }
1142   catch( ... )
1143   {
1144     tet_result(TET_FAIL);
1145   }
1146
1147
1148   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1149   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1150   label.SetSize( 400.0f, 10.f );
1151
1152   try
1153   {
1154     // Render the text.
1155     application.SendNotification();
1156     application.Render();
1157   }
1158   catch( ... )
1159   {
1160     tet_result(TET_FAIL);
1161   }
1162
1163   END_TEST;
1164 }
1165
1166 int UtcDaliToolkitTextlabelTextWrapMode(void)
1167 {
1168   ToolkitTestApplication application;
1169   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1170
1171   int lineCount =0 ;
1172
1173   TextLabel label = TextLabel::New();
1174   label.SetSize( 300.0f, 300.f );
1175   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1176   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1177
1178
1179
1180   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1181   Stage::GetCurrent().Add( label );
1182
1183   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1184   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1185
1186   application.SendNotification();
1187   application.Render();
1188
1189   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1190   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1191
1192   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1193   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1194
1195   application.SendNotification();
1196   application.Render();
1197
1198   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1199   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1200
1201   application.SendNotification();
1202   application.Render();
1203
1204   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1205   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1206
1207   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1208   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1209
1210   application.SendNotification();
1211   application.Render();
1212
1213   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1214   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1215
1216   tet_infoline( "Ensure invalid string does not change wrapping mode" );
1217   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1218   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1219
1220   END_TEST;
1221 }
1222
1223 int UtcDaliToolkitTextLabelColorComponents(void)
1224 {
1225   ToolkitTestApplication application;
1226
1227   TextLabel label = TextLabel::New();
1228   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1229   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1230   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1231   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1232   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1233
1234   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1235   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1236   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1237   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1238   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1239
1240   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1241   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1242   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1243   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
1244   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1245
1246   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1247   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1248   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1249   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::UNUSED_PROPERTY_TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1250
1251   // Test a transparent text - Rendering should be skipped.
1252   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1253   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1254
1255   Stage::GetCurrent().Add( label );
1256
1257   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1258   drawTrace.Enable( true );
1259
1260   application.SendNotification();
1261   application.Render();
1262
1263   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION );  // Should be rendered
1264
1265   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1266
1267   drawTrace.Reset();
1268
1269   application.SendNotification();
1270   application.Render();
1271
1272   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1273
1274   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1275
1276   drawTrace.Reset();
1277
1278   application.SendNotification();
1279   application.Render();
1280
1281   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1282
1283   END_TEST;
1284 }
1285
1286 int UtcDaliToolkitTextlabelTextStyle01(void)
1287 {
1288   ToolkitTestApplication application;
1289   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1290
1291   TextLabel label = TextLabel::New();
1292   label.SetSize( 300.0f, 300.f );
1293   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1294   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1295   Stage::GetCurrent().Add( label );
1296
1297   Property::Map outlineMapSet;
1298   Property::Map outlineMapGet;
1299
1300   outlineMapSet["color"] = Color::BLUE;
1301   outlineMapSet["width"] = 2.0f;
1302   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1303
1304   application.SendNotification();
1305   application.Render();
1306
1307   Property::Map shadowMapSet;
1308   shadowMapSet.Insert( "color", "green" );
1309   shadowMapSet.Insert( "offset", "2 2" );
1310   shadowMapSet.Insert( "blurRadius", "3" );
1311   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1312
1313   outlineMapSet["color"] = Color::RED;
1314   outlineMapSet["width"] = 0.0f;
1315   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1316
1317   application.SendNotification();
1318   application.Render();
1319
1320   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1321
1322   Property::Value* colorValue = outlineMapGet.Find("color");
1323
1324   bool colorMatched( false );
1325
1326   if ( colorValue )
1327   {
1328      Property::Type valueType = colorValue->GetType();
1329
1330      if ( Property::STRING == valueType )
1331      {
1332        std::string stringValue;
1333        colorValue->Get( stringValue );
1334        if (  stringValue == "red" )
1335        {
1336          colorMatched = true;
1337        }
1338      }
1339      else if ( Property::VECTOR4 == valueType )
1340      {
1341        Vector4 colorVector4;
1342        colorValue->Get( colorVector4 );
1343        if (  colorVector4 == Color::RED )
1344        {
1345          colorMatched = true;
1346        }
1347      }
1348   }
1349
1350   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1351
1352   END_TEST;
1353 }
1354
1355 int UtcDaliToolkitTextlabelMultiline(void)
1356 {
1357   ToolkitTestApplication application;
1358   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1359
1360   TextLabel label = TextLabel::New();
1361   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1362   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1363   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1364   Stage::GetCurrent().Add( label );
1365
1366   application.SendNotification();
1367   application.Render();
1368
1369   int lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1370   DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1371
1372   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1373
1374   application.SendNotification();
1375   application.Render();
1376
1377   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1378   DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1379
1380
1381   END_TEST;
1382 }
1383
1384 int UtcDaliToolkitTextlabelTextDirection(void)
1385 {
1386   ToolkitTestApplication application;
1387   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1388
1389   TextLabel label = TextLabel::New();
1390   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1391
1392   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1393   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1394   Stage::GetCurrent().Add( label );
1395
1396   // Test LTR text
1397   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1398
1399   // Test RTL text
1400   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1401   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1402
1403   // Test RTL text starting with weak character
1404   label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1405   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1406
1407   // Test RTL text string with emoji and weak character
1408   label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1409   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1410
1411   END_TEST;
1412 }
1413
1414 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1415 {
1416   ToolkitTestApplication application;
1417   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1418
1419   TextLabel label = TextLabel::New();
1420
1421   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP  );
1422   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1423   label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1424   label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1425   Stage::GetCurrent().Add( label );
1426   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1427
1428   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE  );
1429   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1430
1431   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM  );
1432   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1433
1434   END_TEST;
1435 }
1436
1437 int UtcDaliToolkitTextLabelBitmapFont(void)
1438 {
1439   ToolkitTestApplication application;
1440   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1441
1442   DevelText::BitmapFontDescription fontDescription;
1443   fontDescription.name = "Digits";
1444   fontDescription.underlinePosition = 0.f;
1445   fontDescription.underlineThickness = 0.f;
1446
1447   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1448   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1449   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1450   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1451   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1452   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1453   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1454   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1455   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1456   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1457   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1458
1459   TextAbstraction::BitmapFont bitmapFont;
1460   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1461
1462   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1463   fontClient.GetFontId( bitmapFont );
1464
1465   TextLabel label = TextLabel::New();
1466
1467   label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1468   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1469
1470   // The text has been laid out with the bitmap font if the natural size is the sum of all the width (322) and 34 height.
1471   DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1472
1473   Stage::GetCurrent().Add( label );
1474
1475   application.SendNotification();
1476   application.Render();
1477
1478   // The text has been rendered if the height of the text-label is the height of the line.
1479   DALI_TEST_EQUALS( label.GetCurrentSize().height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1480
1481   END_TEST;
1482 }
1483
1484 int ConvertPointToPixel( float point )
1485 {
1486   unsigned int horizontalDpi = 0u;
1487   unsigned int verticalDpi = 0u;
1488   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1489   fontClient.GetDpi( horizontalDpi, verticalDpi );
1490
1491   return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1492 }
1493
1494 int UtcDaliToolkitTextlabelTextFit(void)
1495 {
1496   ToolkitTestApplication application;
1497   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1498   TextLabel label = TextLabel::New();
1499   Vector2 size( 460.0f, 100.0f );
1500   label.SetSize( size );
1501   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1502
1503   // check point size
1504   Property::Map textFitMapSet;
1505   textFitMapSet["enable"] = true;
1506   textFitMapSet["minSize"] = 10.f;
1507   textFitMapSet["maxSize"] = 100.f;
1508   textFitMapSet["stepSize"] = -1.f;
1509   textFitMapSet["fontSizeType"] = "pointSize";
1510
1511   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1512   label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1513
1514   Stage::GetCurrent().Add( label );
1515
1516   application.SendNotification();
1517   application.Render();
1518
1519   const Vector3 EXPECTED_NATURAL_SIZE( 460.0f, 98.0f, 0.0f );
1520   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1521
1522   // check pixel size
1523   textFitMapSet.Clear();
1524   textFitMapSet["enable"] = true;
1525   textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1526   textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1527   textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1528   textFitMapSet["fontSizeType"] = "pixelSize";
1529
1530   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1531
1532   application.SendNotification();
1533   application.Render();
1534
1535   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1536
1537   END_TEST;
1538 }
1539
1540 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1541 {
1542   ToolkitTestApplication application;
1543   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1544
1545   DevelText::BitmapFontDescription fontDescription;
1546   fontDescription.name = "Digits";
1547   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1548
1549   TextAbstraction::BitmapFont bitmapFont;
1550   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1551
1552   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1553   fontClient.GetFontId( bitmapFont );
1554
1555   TextLabel label = TextLabel::New();
1556   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1557   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1558   label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1559   label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1560   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1561
1562   Property::Map underlineMapSet;
1563   underlineMapSet.Clear();
1564   underlineMapSet.Insert( "enable", true );
1565   underlineMapSet.Insert( "color", Color::RED );
1566   underlineMapSet.Insert( "height", 1 );
1567   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1568   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1569
1570   Stage::GetCurrent().Add( label );
1571
1572   application.SendNotification();
1573   application.Render();
1574
1575   const int maxTextureSize = Dali::GetMaxTextureSize();
1576   // Whether the rendered text is greater than maxTextureSize
1577   DALI_TEST_CHECK( label.GetCurrentSize().height > maxTextureSize );
1578
1579   // Check if the number of renderers is greater than 1.
1580   DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1581
1582   END_TEST;
1583 }