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