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