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