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