Extending Style - Adding Strikethrough
[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 #include "test-text-geometry-utils.h"
34
35 using namespace Dali;
36 using namespace Toolkit;
37
38 void dali_textlabel_startup(void)
39 {
40   test_return_value = TET_UNDEF;
41 }
42
43 void dali_textlabel_cleanup(void)
44 {
45   test_return_value = TET_PASS;
46 }
47
48 namespace
49 {
50
51 const char* const PROPERTY_NAME_RENDERING_BACKEND = "renderingBackend";
52 const char* const PROPERTY_NAME_TEXT = "text";
53 const char* const PROPERTY_NAME_FONT_FAMILY = "fontFamily";
54 const char* const PROPERTY_NAME_FONT_STYLE = "fontStyle";
55 const char* const PROPERTY_NAME_POINT_SIZE = "pointSize";
56 const char* const PROPERTY_NAME_MULTI_LINE =  "multiLine";
57 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT = "horizontalAlignment";
58 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT = "verticalAlignment";
59 const char* const PROPERTY_NAME_TEXT_COLOR = "textColor";
60 const char* const PROPERTY_NAME_ENABLE_MARKUP = "enableMarkup";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL = "enableAutoScroll";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
64 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP = "autoScrollGap";
65
66 const char* const PROPERTY_NAME_LINE_SPACING = "lineSpacing";
67 const char* const PROPERTY_NAME_UNDERLINE = "underline";
68 const char* const PROPERTY_NAME_SHADOW = "shadow";
69 const char* const PROPERTY_NAME_EMBOSS = "emboss";
70 const char* const PROPERTY_NAME_OUTLINE = "outline";
71 const char* const PROPERTY_NAME_BACKGROUND = "textBackground";
72 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
73
74 const char* const PROPERTY_NAME_PIXEL_SIZE = "pixelSize";
75 const char* const PROPERTY_NAME_ELLIPSIS = "ellipsis";
76 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
77 const char* const PROPERTY_NAME_FONT_SIZE_SCALE = "fontSizeScale";
78
79 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
80
81 const std::string DEFAULT_FONT_DIR( "/resources/fonts" );
82 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
83
84 static bool gAnchorClickedCallBackCalled;
85 static bool gAnchorClickedCallBackNotCalled;
86
87 static bool gTextFitChangedCallBackCalled;
88
89 struct CallbackFunctor
90 {
91   CallbackFunctor(bool* callbackFlag)
92   : mCallbackFlag( callbackFlag )
93   {
94   }
95
96   void operator()()
97   {
98     *mCallbackFlag = true;
99   }
100   bool* mCallbackFlag;
101 };
102
103 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
104 {
105   tet_infoline(" TestAnchorClickedCallback");
106
107   gAnchorClickedCallBackNotCalled = false;
108
109   if (!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
110   {
111     gAnchorClickedCallBackCalled = true;
112   }
113 }
114
115 static void TestTextFitChangedCallback(TextLabel control)
116 {
117   tet_infoline(" TestTextFitChangedCallback");
118   gTextFitChangedCallBackCalled = true;
119 }
120
121 bool DaliTestCheckMaps( const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>() )
122 {
123   const Property::Map::SizeType size = mapGet.Count();
124
125   if( size == mapSet.Count() )
126   {
127     for( unsigned int index = 0u; index < size; ++index )
128     {
129       const KeyValuePair& valueGet = mapGet.GetKeyValue( index );
130
131       // Find the keys of the 'get' map
132       Property::Index indexKey = valueGet.first.indexKey;
133       std::string stringKey = valueGet.first.stringKey;
134
135       if( !indexConversionTable.empty() )
136       {
137         if( stringKey.empty() )
138         {
139           stringKey = indexConversionTable[ indexKey ];
140         }
141
142         if( ( indexKey == Property::INVALID_INDEX ) && !stringKey.empty() )
143         {
144           Property::Index index = 0u;
145           for( auto key : indexConversionTable )
146           {
147             if( key == stringKey )
148             {
149               indexKey = index;
150               break;
151             }
152             ++index;
153           }
154         }
155       }
156
157       const Property::Value* const valueSet = mapSet.Find( indexKey, stringKey );
158
159       if( nullptr != valueSet )
160       {
161         if( ( valueSet->GetType() == Dali::Property::STRING ) && ( valueGet.second.Get<std::string>() != valueSet->Get<std::string>() ) )
162         {
163           tet_printf( "Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str() );
164           return false;
165         }
166         else if( ( valueSet->GetType() == Dali::Property::BOOLEAN ) && ( valueGet.second.Get<bool>() != valueSet->Get<bool>() ) )
167         {
168           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>() );
169           return false;
170         }
171         else if( ( valueSet->GetType() == Dali::Property::INTEGER ) && ( valueGet.second.Get<int>() != valueSet->Get<int>() ) )
172         {
173           tet_printf( "Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>() );
174           return false;
175         }
176         else if( ( valueSet->GetType() == Dali::Property::FLOAT ) && ( valueGet.second.Get<float>() != valueSet->Get<float>() ) )
177         {
178           tet_printf( "Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>() );
179           return false;
180         }
181         else if( ( valueSet->GetType() == Dali::Property::VECTOR2 ) && ( valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>() ) )
182         {
183           Vector2 vector2Get = valueGet.second.Get<Vector2>();
184           Vector2 vector2Set = valueSet->Get<Vector2>();
185           tet_printf( "Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y );
186           return false;
187         }
188         else if( ( valueSet->GetType() == Dali::Property::VECTOR4 ) && ( valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>() ) )
189         {
190           Vector4 vector4Get = valueGet.second.Get<Vector4>();
191           Vector4 vector4Set = valueSet->Get<Vector4>();
192           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 );
193           return false;
194         }
195       }
196       else
197       {
198         if ( valueGet.first.type == Property::Key::INDEX )
199         {
200           tet_printf( "  The key %d doesn't exist.", valueGet.first.indexKey );
201         }
202         else
203         {
204           tet_printf( "  The key %s doesn't exist.", valueGet.first.stringKey.c_str() );
205         }
206         return false;
207       }
208     }
209   }
210
211   return true;
212 }
213
214 } // namespace
215
216 int UtcDaliToolkitTextLabelConstructorP(void)
217 {
218   ToolkitTestApplication application;
219   tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
220   TextLabel textLabel;
221   DALI_TEST_CHECK( !textLabel );
222   END_TEST;
223 }
224
225 int UtcDaliToolkitTextLabelNewP(void)
226 {
227   ToolkitTestApplication application;
228   tet_infoline(" UtcDaliToolkitTextLabelNewP");
229   TextLabel textLabel = TextLabel::New( "Test Text" );
230   DALI_TEST_CHECK( textLabel );
231   END_TEST;
232 }
233
234 int UtcDaliToolkitTextLabelDownCastP(void)
235 {
236   ToolkitTestApplication application;
237   tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
238   TextLabel textLabel1 = TextLabel::New();
239   BaseHandle object( textLabel1 );
240
241   TextLabel textLabel2 = TextLabel::DownCast( object );
242   DALI_TEST_CHECK( textLabel2 );
243
244   TextLabel textLabel3 = DownCast< TextLabel >( object );
245   DALI_TEST_CHECK( textLabel3 );
246   END_TEST;
247 }
248
249 int UtcDaliToolkitTextLabelDownCastN(void)
250 {
251   ToolkitTestApplication application;
252   tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
253   BaseHandle uninitializedObject;
254   TextLabel textLabel1 = TextLabel::DownCast( uninitializedObject );
255   DALI_TEST_CHECK( !textLabel1 );
256
257   TextLabel textLabel2 = DownCast< TextLabel >( uninitializedObject );
258   DALI_TEST_CHECK( !textLabel2 );
259   END_TEST;
260 }
261
262 int UtcDaliToolkitTextLabelCopyConstructorP(void)
263 {
264   ToolkitTestApplication application;
265   tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
266   TextLabel textLabel = TextLabel::New();
267   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
268
269   TextLabel copy( textLabel );
270   DALI_TEST_CHECK( copy );
271   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
272   END_TEST;
273 }
274
275 int UtcDaliTextLabelMoveConstructor(void)
276 {
277   ToolkitTestApplication application;
278
279   TextLabel textLabel = TextLabel::New();
280   textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
281   DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
282
283   TextLabel moved = std::move( textLabel );
284   DALI_TEST_CHECK( moved );
285   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
286   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
287   DALI_TEST_CHECK( !textLabel );
288
289   END_TEST;
290 }
291
292 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
293 {
294   ToolkitTestApplication application;
295   tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
296   TextLabel textLabel = TextLabel::New();
297   textLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
298
299   TextLabel copy = textLabel;
300   DALI_TEST_CHECK( copy );
301   DALI_TEST_CHECK( copy.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) == textLabel.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ) );
302   END_TEST;
303 }
304
305 int UtcDaliTextLabelMoveAssignment(void)
306 {
307   ToolkitTestApplication application;
308
309   TextLabel textLabel = TextLabel::New();
310   textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
311   DALI_TEST_CHECK( textLabel.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
312
313   TextLabel moved;
314   moved = std::move( textLabel );
315   DALI_TEST_CHECK( moved );
316   DALI_TEST_EQUALS( 1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION );
317   DALI_TEST_CHECK( moved.GetProperty<std::string>( TextLabel::Property::TEXT ) == "Test" );
318   DALI_TEST_CHECK( !textLabel );
319
320   END_TEST;
321 }
322
323 // Positive test case for a method
324 int UtcDaliToolkitTextLabelGetPropertyP(void)
325 {
326   ToolkitTestApplication application;
327   tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
328   TextLabel label = TextLabel::New("Test Text");
329   DALI_TEST_CHECK( label );
330
331   // Check Property Indices are correct
332   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_RENDERING_BACKEND ) == DevelTextLabel::Property::RENDERING_BACKEND );
333   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT ) == TextLabel::Property::TEXT );
334   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_FAMILY ) == TextLabel::Property::FONT_FAMILY );
335   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_STYLE ) == TextLabel::Property::FONT_STYLE );
336   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_POINT_SIZE ) == TextLabel::Property::POINT_SIZE );
337   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_MULTI_LINE ) == TextLabel::Property::MULTI_LINE );
338   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_HORIZONTAL_ALIGNMENT ) == TextLabel::Property::HORIZONTAL_ALIGNMENT );
339   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_VERTICAL_ALIGNMENT ) == TextLabel::Property::VERTICAL_ALIGNMENT );
340   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_TEXT_COLOR ) == TextLabel::Property::TEXT_COLOR );
341   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP );
342   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL ) == TextLabel::Property::ENABLE_AUTO_SCROLL );
343   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED ) == TextLabel::Property::AUTO_SCROLL_SPEED );
344   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS ) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT );
345   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP ) == TextLabel::Property::AUTO_SCROLL_GAP );
346   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_LINE_SPACING ) == TextLabel::Property::LINE_SPACING );
347   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_UNDERLINE ) == TextLabel::Property::UNDERLINE );
348   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_SHADOW ) == TextLabel::Property::SHADOW );
349   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_EMBOSS ) == TextLabel::Property::EMBOSS );
350   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_OUTLINE ) == TextLabel::Property::OUTLINE );
351   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_BACKGROUND ) == DevelTextLabel::Property::BACKGROUND );
352   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_PIXEL_SIZE ) == TextLabel::Property::PIXEL_SIZE );
353   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS ) == TextLabel::Property::ELLIPSIS );
354   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY ) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY );
355   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_FONT_SIZE_SCALE ) == DevelTextLabel::Property::FONT_SIZE_SCALE );
356   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_ELLIPSIS_POSITION ) == DevelTextLabel::Property::ELLIPSIS_POSITION );
357   DALI_TEST_CHECK( label.GetPropertyIndex( PROPERTY_NAME_STRIKETHROUGH ) == DevelTextLabel::Property::STRIKETHROUGH );
358
359   END_TEST;
360 }
361
362 int UtcDaliToolkitTextLabelSetPropertyP(void)
363 {
364   ToolkitTestApplication application;
365   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
366   TextLabel label = TextLabel::New();
367   DALI_TEST_CHECK( label );
368
369   application.GetScene().Add( label );
370
371   // Note - we can't check the defaults since the stylesheets are platform-specific
372   label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
373   DALI_TEST_EQUALS( (DevelText::RenderingType)label.GetProperty<int>( DevelTextLabel::Property::RENDERING_BACKEND ), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION );
374
375   // Check that text can be correctly reset
376   label.SetProperty( TextLabel::Property::TEXT, "Setting Text" );
377   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("Setting Text"), TEST_LOCATION );
378
379   // Check font properties.
380   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Setting font family" );
381   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::FONT_FAMILY ), std::string("Setting font family"), TEST_LOCATION );
382
383   Property::Map fontStyleMapSet;
384   Property::Map fontStyleMapGet;
385
386   fontStyleMapSet.Insert( "weight", "bold" );
387   fontStyleMapSet.Insert( "width", "condensed" );
388   fontStyleMapSet.Insert( "slant", "italic" );
389   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
390
391   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
392   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
393   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
394
395   // Check the old font style format.
396   fontStyleMapSet.Clear();
397   fontStyleMapSet.Insert( "weight", "thin" );
398   fontStyleMapSet.Insert( "width", "expanded" );
399   fontStyleMapSet.Insert( "slant", "oblique" );
400   const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
401
402   label.SetProperty( TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}" );
403   std::string getFontStyle = label.GetProperty<std::string>( TextLabel::Property::FONT_STYLE );
404   DALI_TEST_EQUALS( getFontStyle, strFontStyle, TEST_LOCATION );
405
406   label.SetProperty( TextLabel::Property::POINT_SIZE, 10.f );
407   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::POINT_SIZE ), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
408
409   label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f );
410   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::FONT_SIZE_SCALE ), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
411   label.SetProperty( DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f );
412
413   // Reset font style.
414   fontStyleMapSet.Clear();
415   fontStyleMapSet.Insert( "weight", "normal" );
416   fontStyleMapSet.Insert( "slant", "oblique" );
417
418   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
419   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
420   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
421   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
422
423   fontStyleMapSet.Clear();
424   fontStyleMapSet.Insert( "slant", "roman" );
425
426   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
427   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
428   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
429
430   // Replace 'roman' for 'normal'.
431   Property::Value* slantValue = fontStyleMapGet.Find( "slant" );
432   if( NULL != slantValue )
433   {
434     if( "normal" == slantValue->Get<std::string>() )
435     {
436       fontStyleMapGet["slant"] = "roman";
437     }
438   }
439   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
440
441   fontStyleMapSet.Clear();
442
443   label.SetProperty( TextLabel::Property::FONT_STYLE, fontStyleMapSet );
444   fontStyleMapGet = label.GetProperty<Property::Map>( TextLabel::Property::FONT_STYLE );
445   DALI_TEST_EQUALS( fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION );
446   DALI_TEST_EQUALS( DaliTestCheckMaps( fontStyleMapGet, fontStyleMapSet ), true, TEST_LOCATION );
447
448   // Toggle multi-line
449   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
450   DALI_TEST_EQUALS( label.GetProperty<bool>( TextLabel::Property::MULTI_LINE ), true, TEST_LOCATION );
451
452   // Check that the Alignment properties can be correctly set
453   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
454   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::HORIZONTAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
455   label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
456   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::VERTICAL_ALIGNMENT ), "CENTER", TEST_LOCATION );
457
458   // Check that text color can be properly set
459   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
460   DALI_TEST_EQUALS( label.GetProperty<Vector4>( TextLabel::Property::TEXT_COLOR ), Color::BLUE, TEST_LOCATION );
461
462   Property::Map strikethroughMapSet;
463   Property::Map strikethroughMapGet;
464
465   strikethroughMapSet.Insert( "enable", false );
466   strikethroughMapSet.Insert( "color", Color::BLUE );
467   strikethroughMapSet.Insert( "height", 2.0f );
468
469   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
470
471   strikethroughMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::STRIKETHROUGH );
472   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
473   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
474
475   Property::Map underlineMapSet;
476   Property::Map underlineMapGet;
477
478   underlineMapSet.Insert( "enable", false );
479   underlineMapSet.Insert( "color", Color::BLUE );
480   underlineMapSet.Insert( "height", 0 );
481
482   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
483   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
484   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
485
486   TextLabel label2 = TextLabel::New( "New text" );
487   DALI_TEST_CHECK( label2 );
488   DALI_TEST_EQUALS( label2.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("New text"), TEST_LOCATION );
489
490   // Check the enable markup property.
491   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
492   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
493   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_MARKUP ) );
494
495   // Check the text property when markup is enabled
496   label.SetProperty( TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>" );
497   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
498
499   // Check for incomplete marks.
500   label.SetProperty( TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>" );
501   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), std::string("MarkupText"), TEST_LOCATION );
502   try
503   {
504     application.SendNotification();
505     application.Render();
506   }
507   catch( ... )
508   {
509     tet_result(TET_FAIL);
510   }
511
512   // Check autoscroll properties
513   const int SCROLL_SPEED = 80;
514   const int SCROLL_LOOPS = 4;
515   const float SCROLL_GAP = 50.0f;
516   const float SCROLL_LOOP_DELAY = 0.3f;
517   const std::string STOP_IMMEDIATE = std::string( "IMMEDIATE" );
518   const std::string STOP_FINISH_LOOP = std::string( "FINISH_LOOP" );
519
520   label.SetProperty( TextLabel::Property::MULTI_LINE, false ); // Autoscroll only supported in single line
521   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
522   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
523   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ENABLE_AUTO_SCROLL ) );
524   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED );
525   DALI_TEST_EQUALS( SCROLL_SPEED, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_SPEED ), TEST_LOCATION );
526   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS );
527   DALI_TEST_EQUALS( SCROLL_LOOPS, label.GetProperty<int>( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT ), TEST_LOCATION );
528   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP );
529   DALI_TEST_EQUALS( SCROLL_GAP, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_GAP ), TEST_LOCATION );
530   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY );
531   DALI_TEST_EQUALS( SCROLL_LOOP_DELAY, label.GetProperty<float>( TextLabel::Property::AUTO_SCROLL_LOOP_DELAY ), TEST_LOCATION );
532
533   //Check autoscroll stop type property
534   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
535   DALI_TEST_EQUALS( STOP_IMMEDIATE, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
536
537   label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
538   DALI_TEST_EQUALS( STOP_FINISH_LOOP, label.GetProperty<std::string>( TextLabel::Property::AUTO_SCROLL_STOP_MODE ), TEST_LOCATION );
539
540   // test natural size with multi-line and line spacing
541   {
542     TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
543     Vector3 oneLineNaturalSize = label3.GetNaturalSize();
544     label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
545     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
546     Vector3 multiLineNaturalSize = label3.GetNaturalSize();
547
548     // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
549     // The height of the text when multi-line is enabled will be larger
550     DALI_TEST_CHECK( oneLineNaturalSize.width > multiLineNaturalSize.width );
551     DALI_TEST_CHECK( oneLineNaturalSize.height < multiLineNaturalSize.height );
552
553     // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
554     // Everything else will remain the same
555     int lineSpacing = 20;
556     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
557     Vector3 expectedAfterLineSpacingApplied( multiLineNaturalSize );
558     expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
559     DALI_TEST_EQUALS( expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION );
560   }
561
562   // single line, line spacing must not affect natural size of the text, only add the spacing to the height
563   {
564     TextLabel label3 = TextLabel::New("Some text here end there end here");
565     label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
566     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
567     Vector3 textNaturalSize = label3.GetNaturalSize();
568     int lineSpacing = 20;
569     label3.SetProperty( TextLabel::Property::LINE_SPACING, lineSpacing );
570     Vector3 expectedNaturalSizeWithLineSpacing( textNaturalSize );
571     expectedNaturalSizeWithLineSpacing.height += lineSpacing;
572     DALI_TEST_EQUALS( expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION );
573   }
574   // Check the line spacing property
575   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
576   label.SetProperty( TextLabel::Property::LINE_SPACING, 10.f );
577   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::LINE_SPACING ), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
578
579   // Check the strikethrough property
580   strikethroughMapSet.Clear();
581   strikethroughMapSet.Insert( "enable", true );
582   strikethroughMapSet.Insert( "color", Color::RED );
583   strikethroughMapSet.Insert( "height", 2.0f );
584
585   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
586
587   application.SendNotification();
588   application.Render();
589
590   strikethroughMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::STRIKETHROUGH );
591   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
592   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
593
594   strikethroughMapSet.Clear();
595   strikethroughMapSet.Insert( Toolkit::DevelText::Strikethrough::Property::ENABLE, true );
596   strikethroughMapSet.Insert( Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED );
597   strikethroughMapSet.Insert( Toolkit::DevelText::Strikethrough::Property::HEIGHT, 2.0f );
598
599   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
600
601   application.SendNotification();
602   application.Render();
603
604   strikethroughMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::STRIKETHROUGH );
605   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
606   std::vector<std::string> strikethroughIndicesConversionTable = { "enable", "color","height"};
607   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet, strikethroughIndicesConversionTable ), true, TEST_LOCATION );
608
609   strikethroughMapSet.Clear();
610
611   Property::Map strikethroughDisabledMapGet;
612   strikethroughDisabledMapGet.Insert( "enable", false );
613   strikethroughDisabledMapGet.Insert( "color", Color::RED );
614   strikethroughDisabledMapGet.Insert( "height", 2.0f );
615
616   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
617
618   application.SendNotification();
619   application.Render();
620
621   strikethroughMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::STRIKETHROUGH );
622   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughDisabledMapGet.Count(), TEST_LOCATION );
623   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughDisabledMapGet ), true, TEST_LOCATION );
624
625   // Check the underline property
626   underlineMapSet.Clear();
627   underlineMapSet.Insert( "enable", true );
628   underlineMapSet.Insert( "color", Color::RED );
629   underlineMapSet.Insert( "height", 1 );
630
631   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
632
633   application.SendNotification();
634   application.Render();
635
636   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
637   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
638   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet ), true, TEST_LOCATION );
639
640   underlineMapSet.Clear();
641   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::ENABLE, true );
642   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN );
643   underlineMapSet.Insert( Toolkit::DevelText::Underline::Property::HEIGHT, 2 );
644
645   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
646
647   application.SendNotification();
648   application.Render();
649
650   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
651   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION );
652   std::vector<std::string> underlineIndicesConversionTable = { "enable", "color", "height" };
653   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineMapSet, underlineIndicesConversionTable ), true, TEST_LOCATION );
654
655   underlineMapSet.Clear();
656
657   Property::Map underlineDisabledMapGet;
658   underlineDisabledMapGet.Insert( "enable", false );
659   underlineDisabledMapGet.Insert( "color", Color::GREEN );
660   underlineDisabledMapGet.Insert( "height", 2 );
661
662   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
663
664   application.SendNotification();
665   application.Render();
666
667   underlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::UNDERLINE );
668   DALI_TEST_EQUALS( underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION );
669   DALI_TEST_EQUALS( DaliTestCheckMaps( underlineMapGet, underlineDisabledMapGet ), true, TEST_LOCATION );
670
671   // Check the shadow property
672
673   Property::Map shadowMapSet;
674   Property::Map shadowMapGet;
675
676   shadowMapSet.Insert( "color", Color::GREEN );
677   shadowMapSet.Insert( "offset", Vector2(2.0f, 2.0f) );
678   shadowMapSet.Insert( "blurRadius", 5.0f );
679
680   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
681
682   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
683   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
684   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet ), true, TEST_LOCATION );
685
686   shadowMapSet.Clear();
687
688   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
689   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0" );
690   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
691
692   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
693
694   // Replace the offset (string) by a vector2
695   shadowMapSet.Clear();
696   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE );
697   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::OFFSET, Vector2( 3.0, 3.0 ) );
698   shadowMapSet.Insert( Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f );
699
700   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
701   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION );
702   std::vector<std::string> shadowIndicesConversionTable = { "color", "offset", "blurRadius" };
703   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowMapSet, shadowIndicesConversionTable ), true, TEST_LOCATION );
704
705   shadowMapSet.Clear();
706   Property::Map shadowDisabledMapGet;
707   shadowDisabledMapGet.Insert( "color", Color::BLUE );
708   shadowDisabledMapGet.Insert( "offset", Vector2(0.0f, 0.0f) );
709   shadowDisabledMapGet.Insert( "blurRadius", 3.0f );
710
711   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
712
713   shadowMapGet = label.GetProperty<Property::Map>( TextLabel::Property::SHADOW );
714   DALI_TEST_EQUALS( shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION );
715   DALI_TEST_EQUALS( DaliTestCheckMaps( shadowMapGet, shadowDisabledMapGet ), true, TEST_LOCATION );
716
717   // Check the emboss property
718   label.SetProperty( TextLabel::Property::EMBOSS, "Emboss properties" );
719   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::EMBOSS ), std::string("Emboss properties"), TEST_LOCATION );
720
721   // Check the outline property
722
723   // Test string type first
724   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
725   label.SetProperty( TextLabel::Property::OUTLINE, "Outline properties" );
726   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::OUTLINE ), std::string("Outline properties"), TEST_LOCATION );
727
728   // Then test the property map type
729   Property::Map outlineMapSet;
730   Property::Map outlineMapGet;
731
732   outlineMapSet["color"] = Color::RED;
733   outlineMapSet["width"] = 2.0f;
734   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
735
736   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
737   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
738   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet ), true, TEST_LOCATION );
739
740   outlineMapSet.Clear();
741   outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
742   outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
743   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
744
745   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
746   DALI_TEST_EQUALS( outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION );
747   std::vector<std::string> outlineIndicesConversionTable = { "color", "width" };
748   DALI_TEST_EQUALS( DaliTestCheckMaps( outlineMapGet, outlineMapSet, outlineIndicesConversionTable ), true, TEST_LOCATION );
749
750   // Check the background property
751   Property::Map backgroundMapSet;
752   Property::Map backgroundMapGet;
753
754   backgroundMapSet["enable"] = true;
755   backgroundMapSet["color"] = Color::RED;
756   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
757
758   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
759   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
760   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet ), true, TEST_LOCATION );
761
762   backgroundMapSet.Clear();
763   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
764   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
765   label.SetProperty( DevelTextLabel::Property::BACKGROUND, backgroundMapSet );
766
767   backgroundMapGet = label.GetProperty<Property::Map>( DevelTextLabel::Property::BACKGROUND );
768   DALI_TEST_EQUALS( backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION );
769   std::vector<std::string> backgroundIndicesConversionTable = { "enable", "color" };
770   DALI_TEST_EQUALS( DaliTestCheckMaps( backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable ), true, TEST_LOCATION );
771
772   // Check the pixel size of font
773   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 20.f );
774   DALI_TEST_EQUALS( label.GetProperty<float>( TextLabel::Property::PIXEL_SIZE ), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
775
776   // Check the ellipsis property
777   DALI_TEST_CHECK( label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
778   label.SetProperty( TextLabel::Property::ELLIPSIS, false );
779   DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
780
781   // Check the layout direction property
782   label.SetProperty( Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT );
783   DALI_TEST_EQUALS( label.GetProperty< int >( Actor::Property::LAYOUT_DIRECTION ), static_cast< int >( LayoutDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
784
785   // Check the line size property
786   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
787   label.SetProperty( DevelTextLabel::Property::MIN_LINE_SIZE, 50.f );
788   DALI_TEST_EQUALS( label.GetProperty<float>( DevelTextLabel::Property::MIN_LINE_SIZE ), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
789
790   application.SendNotification();
791   application.Render();
792
793   END_TEST;
794 }
795
796 int UtcDaliToolkitTextlabelAtlasRenderP(void)
797 {
798   ToolkitTestApplication application;
799   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
800   TextLabel label = TextLabel::New("Test Text");
801   DALI_TEST_CHECK( label );
802
803   // Avoid a crash when core load gl resources.
804   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
805
806   application.GetScene().Add( label );
807
808   // Turn on all the effects
809   label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
810   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
811
812   Property::Map underlineMap;
813   underlineMap.Insert( "enable", true );
814   underlineMap.Insert( "color", Color::RED );
815   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMap );
816
817   Property::Map shadowMap;
818   shadowMap.Insert( "color", Color::BLUE );
819   shadowMap.Insert( "offset", Vector2( 1.0f, 1.0f ) );
820   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
821
822   Property::Map strikethroughMap;
823   strikethroughMap.Insert( "enable", true );
824   strikethroughMap.Insert( "color", Color::GREEN );
825   strikethroughMap.Insert( "height", 2.0f );
826   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap );
827
828   try
829   {
830     // Render some text with the shared atlas backend
831     label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS );
832     application.SendNotification();
833     application.Render();
834   }
835   catch( ... )
836   {
837     tet_result(TET_FAIL);
838   }
839
840   try
841   {
842     // Render some text with the shared atlas backend
843     label.SetProperty( DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED );
844     application.SendNotification();
845     application.Render();
846   }
847   catch( ... )
848   {
849     tet_result(TET_FAIL);
850   }
851   END_TEST;
852 }
853
854 int UtcDaliToolkitTextLabelLanguagesP(void)
855 {
856   ToolkitTestApplication application;
857   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
858   TextLabel label = TextLabel::New();
859   DALI_TEST_CHECK( label );
860
861   application.GetScene().Add( label );
862
863   const std::string scripts( " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
864                              "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
865                              "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
866                              "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
867                              "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
868                              "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84." ); // these characters on the last line are emojis.
869
870   label.SetProperty( TextLabel::Property::TEXT, scripts );
871   DALI_TEST_EQUALS( label.GetProperty<std::string>( TextLabel::Property::TEXT ), scripts, TEST_LOCATION );
872
873   application.SendNotification();
874   application.Render();
875
876   END_TEST;
877 }
878
879 int UtcDaliToolkitTextLabelEmojisP(void)
880 {
881   ToolkitTestApplication application;
882   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
883   TextLabel label = TextLabel::New();
884   DALI_TEST_CHECK( label );
885
886   application.GetScene().Add( label );
887
888   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
889
890   char* pathNamePtr = get_current_dir_name();
891   const std::string pathName( pathNamePtr );
892   free( pathNamePtr );
893
894   TextAbstraction::FontDescription fontDescription;
895   fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
896   fontDescription.family = "BreezeColorEmoji";
897   fontDescription.width = TextAbstraction::FontWidth::NONE;
898   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
899   fontDescription.slant = TextAbstraction::FontSlant::NONE;
900
901   fontClient.GetFontId( fontDescription, EMOJI_FONT_SIZE );
902
903   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>";
904   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
905   label.SetProperty( TextLabel::Property::TEXT, emojis );
906
907   Property::Map shadowMap;
908   shadowMap.Insert( "color", "green" );
909   shadowMap.Insert( "offset", "2 2" );
910   label.SetProperty( TextLabel::Property::SHADOW, shadowMap );
911
912   application.SendNotification();
913   application.Render();
914
915   // EMOJI + ZWJ + EMOJI case for coverage.
916   const std::string emojiWithZWJ = "&#x1f469;&#x200d;&#x1f52c;";
917   label.SetProperty( TextLabel::Property::TEXT, emojiWithZWJ );
918
919   application.SendNotification();
920   application.Render();
921
922   // EMOJI Sequences case for coverage.
923   std::string emojiSequences =
924        "Text VS15 &#x262a;&#xfe0e;\n"                                                         //text presentation sequence and selector
925       "Color VS16 &#x262a;&#xfe0f;\n"                                                        //emoji presentation sequence and selector
926       "Default &#x262a; \n"                                                                  //default presentation
927       "FamilyManWomanGirlBoy &#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;\n" // emoji multi zwj sequence
928       "WomanScientist &#x1f469;&#x200d;&#x1f52c;\n"                                          // emoji zwj sequence
929       "WomanScientistLightSkinTone&#x1F469;&#x1F3FB;&#x200D;&#x1F52C; \n"                    //emoji modifier sequence: skin tone & JWZ
930       "LeftRightArrowText&#x2194;&#xfe0e;\n"                                                 //text presentation sequence and selector
931       "LeftRightArrowEmoji&#x2194;&#xfe0f;\n"                                                //emoji presentation sequence and selector
932       "SouthKoreaFlag&#x1f1f0;&#x1f1f7;\n"                                                   //emoji flag sequence
933       "JordanFlag&#x1f1ef;&#x1f1f4;\n"                                                       // emoji flag sequence
934       "EnglandFlag&#x1F3F4;&#xE0067;&#xE0062;&#xE0065;&#xE006E;&#xE0067;&#xE007F;\n"         //emoji tag sequence like England flag
935       "Runner &#x1f3c3;&#x200d;&#x27a1;&#xfe0f; \n"
936       "VictoryHandMediumLightSkinTone:&#x270C;&#xFE0F;&#x1F3FC;\n"               //emoji modifier sequence: skin tone
937       "RainbowFlag:&#x1F3F3;&#xFE0F;&#x200D;&#x1F308; \n"                        //emoji zwj sequence: Rainbow Flag
938       "keycap# &#x0023;&#xFE0F;&#x20E3; \n"                                      // fully-qualified  emoji keycap sequence
939       "keycap#_text &#x0023;&#x20E3; \n"                                         // unqualified emoji keycap sequence
940       "keycap3 &#x0033;&#xfe0f;&#x20e3; \n"                                      // fully-qualified  emoji keycap sequence
941       "keycap3_text &#x0033;&#x20e3; \n"                                         // unqualified emoji keycap sequence
942       "two adjacent glyphs &#x262a;&#xfe0f;&#xfe0f;&#xfe0f;&#x262a;&#xfe0f;\n"   //This line should be rendered as two adjacent glyphs
943       "Digit 8&#xfe0f; 8&#xfe0e; 8\n"                                            // should be rendered according to selector
944       "Surfing Medium Skin Female:  &#x1f3c4;&#x1f3fc;&#x200d;&#x2640;&#xfe0f;"; // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
945
946   label.SetProperty( TextLabel::Property::TEXT, emojiSequences );
947   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
948   label.SetProperty( TextLabel::Property::MULTI_LINE, true);
949   label.SetProperty( TextLabel::Property::ELLIPSIS, false);
950
951   application.SendNotification();
952   application.Render();
953   END_TEST;
954 }
955
956 int UtcDaliToolkitTextlabelScrollingP(void)
957 {
958   ToolkitTestApplication application;
959   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
960   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
961   TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
962
963   DALI_TEST_CHECK( labelImmediate );
964   DALI_TEST_CHECK( labelFinished );
965   // Avoid a crash when core load gl resources.
966   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
967   application.GetScene().Add( labelImmediate );
968   // Turn on all the effects
969   labelImmediate.SetProperty( TextLabel::Property::MULTI_LINE, false );
970   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
971   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
972   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
973   labelImmediate.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
974
975   application.GetScene().Add( labelFinished );
976   // Turn on all the effects
977   labelFinished.SetProperty( TextLabel::Property::MULTI_LINE, false );
978   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
979   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
980   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
981   labelFinished.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
982
983
984
985   try
986   {
987     // Render some text with the shared atlas backend
988     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
989     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
990
991     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
992     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
993
994     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
995     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
996     application.SendNotification();
997     application.Render();
998
999     labelImmediate.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1000     labelFinished.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1001     application.SendNotification();
1002     application.Render();
1003
1004   }
1005   catch( ... )
1006   {
1007     tet_result(TET_FAIL);
1008   }
1009
1010   END_TEST;
1011 }
1012
1013 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1014 {
1015   ToolkitTestApplication application;
1016   TextLabel labelShort = TextLabel::New("Some text to scroll");
1017   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!");
1018
1019   DALI_TEST_CHECK( labelShort );
1020   DALI_TEST_CHECK( labelLong );
1021   // Avoid a crash when core load gl resources.
1022   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1023   application.GetScene().Add( labelShort );
1024   // Turn on all the effects
1025   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1026   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1027   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1028   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1029   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1030   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1031
1032   application.GetScene().Add( labelLong );
1033   // Turn on all the effects
1034   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1035   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1036   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1037   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1038   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1039   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1040
1041   try
1042   {
1043     // Render some text with the shared atlas backend
1044     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1045     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1046     application.SendNotification();
1047     application.Render();
1048
1049     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1050     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1051     application.SendNotification();
1052     application.Render();
1053
1054   }
1055   catch( ... )
1056   {
1057     tet_result(TET_FAIL);
1058   }
1059
1060   END_TEST;
1061 }
1062
1063 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1064 {
1065   ToolkitTestApplication application;
1066   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1067   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1068
1069   DALI_TEST_CHECK( labelShort );
1070   DALI_TEST_CHECK( labelLong );
1071   // Avoid a crash when core load gl resources.
1072   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1073   application.GetScene().Add( labelShort );
1074   // Turn on all the effects
1075   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1076   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1077   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1078   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1079   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1080   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1081
1082   application.GetScene().Add( labelLong );
1083   // Turn on all the effects
1084   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1085   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
1086   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1087   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1088   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1089   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1090
1091   try
1092   {
1093     // Render some text with the shared atlas backend
1094     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1095     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1096     application.SendNotification();
1097     application.Render();
1098
1099     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1100     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1101     application.SendNotification();
1102     application.Render();
1103
1104   }
1105   catch( ... )
1106   {
1107     tet_result(TET_FAIL);
1108   }
1109
1110   END_TEST;
1111 }
1112
1113 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1114 {
1115   ToolkitTestApplication application;
1116   TextLabel labelShort = TextLabel::New("Some text to scroll");
1117   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!");
1118
1119   DALI_TEST_CHECK( labelShort );
1120   DALI_TEST_CHECK( labelLong );
1121   // Avoid a crash when core load gl resources.
1122   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1123   application.GetScene().Add( labelShort );
1124   // Turn on all the effects
1125   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1126   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1127   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1128   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1129   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1130   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1131
1132   application.GetScene().Add( labelLong );
1133   // Turn on all the effects
1134   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1135   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1136   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1137   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1138   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1139   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1140
1141   try
1142   {
1143     // Render some text with the shared atlas backend
1144     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1145     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1146     application.SendNotification();
1147     application.Render();
1148
1149     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1150     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1151     application.SendNotification();
1152     application.Render();
1153
1154   }
1155   catch( ... )
1156   {
1157     tet_result(TET_FAIL);
1158   }
1159
1160   END_TEST;
1161 }
1162
1163 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1164 {
1165   ToolkitTestApplication application;
1166   TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1167   TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1168
1169   DALI_TEST_CHECK( labelShort );
1170   DALI_TEST_CHECK( labelLong );
1171   // Avoid a crash when core load gl resources.
1172   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1173   application.GetScene().Add( labelShort );
1174   // Turn on all the effects
1175   labelShort.SetProperty( TextLabel::Property::MULTI_LINE, false );
1176   labelShort.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1177   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1178   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1179   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1180   labelShort.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1181
1182   application.GetScene().Add( labelLong );
1183   // Turn on all the effects
1184   labelLong.SetProperty( TextLabel::Property::MULTI_LINE, false );
1185   labelLong.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "END" );
1186   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1187   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1188   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1189   labelLong.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP );
1190
1191   try
1192   {
1193     // Render some text with the shared atlas backend
1194     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1195     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1196     application.SendNotification();
1197     application.Render();
1198
1199     labelShort.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1200     labelLong.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1201     application.SendNotification();
1202     application.Render();
1203
1204   }
1205   catch( ... )
1206   {
1207     tet_result(TET_FAIL);
1208   }
1209
1210   END_TEST;
1211 }
1212
1213 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1214 {
1215   ToolkitTestApplication application;
1216   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1217   TextLabel label = TextLabel::New("Some text to scroll");
1218   DALI_TEST_CHECK( label );
1219   // Avoid a crash when core load gl resources.
1220   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1221   application.GetScene().Add( label );
1222   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 20.f ) );
1223   // Turn on all the effects
1224   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1225   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1226   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1227   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1228
1229   // Render the text.
1230   application.SendNotification();
1231   application.Render();
1232
1233   unsigned int actorCount1 = label.GetChildCount();
1234   tet_printf("Initial actor count is(%d)\n", actorCount1 );
1235
1236   try
1237   {
1238     // Render some text with the shared atlas backend
1239     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1240     application.SendNotification();
1241     application.Render(2000);
1242
1243     unsigned int actorCount1 = label.GetChildCount();
1244     tet_printf("Actor count after scrolling is(%d)\n", actorCount1 );
1245
1246     label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1247
1248     // Render the text.
1249     application.SendNotification();
1250     application.Render();
1251
1252     unsigned int actorCount2 = label.GetChildCount();
1253     tet_printf("After changing color the actor count is(%d)\n", actorCount2 );
1254
1255     DALI_TEST_EQUALS( actorCount1, actorCount2, TEST_LOCATION );
1256
1257   }
1258   catch( ... )
1259   {
1260     tet_result(TET_FAIL);
1261   }
1262
1263   END_TEST;
1264 }
1265
1266 int UtcDaliToolkitTextlabelScrollingN(void)
1267 {
1268   ToolkitTestApplication application;
1269   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1270
1271   TextLabel label = TextLabel::New("Some text to scroll");
1272   DALI_TEST_CHECK( label );
1273
1274   application.GetScene().Add( label );
1275
1276   // Avoid a crash when core load gl resources.
1277   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1278
1279   // The text scrolling works only on single line text.
1280   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1281
1282   // Turn on all the effects.
1283   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1284   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1285   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1286
1287   // Enable the auto scrolling effect.
1288   label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1289
1290   // The auto scrolling shouldn't be enabled.
1291   const bool enabled = label.GetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL ).Get<bool>();
1292   DALI_TEST_CHECK( !enabled );
1293
1294   END_TEST;
1295 }
1296
1297 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1298 {
1299   ToolkitTestApplication application;
1300   tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1301
1302   TextLabel label = TextLabel::New("Some text to scroll");
1303   DALI_TEST_CHECK( label );
1304
1305   application.GetScene().Add( label );
1306
1307   // Avoid a crash when core load gl resources.
1308   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1309
1310   // Turn on all the effects.
1311   label.SetProperty( TextLabel::Property::AUTO_SCROLL_GAP, 50.0f );
1312   label.SetProperty( TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3 );
1313   label.SetProperty( TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f );
1314
1315   try
1316   {
1317     // Enable the auto scrolling effect.
1318     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, true );
1319     label.SetProperty( TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE );
1320
1321     // Disable the ellipsis
1322     label.SetProperty( TextLabel::Property::ELLIPSIS, false );
1323
1324     // Render the text.
1325     application.SendNotification();
1326     application.Render();
1327
1328     // Stop auto scrolling
1329     label.SetProperty( TextLabel::Property::ENABLE_AUTO_SCROLL, false );
1330
1331     // Check the ellipsis property
1332     DALI_TEST_CHECK( !label.GetProperty<bool>( TextLabel::Property::ELLIPSIS ) );
1333   }
1334   catch( ... )
1335   {
1336     tet_result(TET_FAIL);
1337   }
1338
1339   END_TEST;
1340 }
1341
1342 int UtcDaliToolkitTextlabelEllipsis(void)
1343 {
1344   ToolkitTestApplication application;
1345   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1346
1347   TextLabel label = TextLabel::New("Hello world");
1348   DALI_TEST_CHECK( label );
1349
1350   // Avoid a crash when core load gl resources.
1351   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
1352
1353   application.GetScene().Add( label );
1354
1355   // Turn on all the effects
1356   label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
1357   label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
1358   label.SetProperty( Actor::Property::SIZE, Vector2( 360.0f, 10.f ) );
1359
1360   try
1361   {
1362     // Render the text.
1363     application.SendNotification();
1364     application.Render();
1365   }
1366   catch( ... )
1367   {
1368     tet_result(TET_FAIL);
1369   }
1370
1371   label.SetProperty( TextLabel::Property::TEXT, "Hello world                                        " );
1372   label.SetProperty( DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false );
1373   label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1374
1375   try
1376   {
1377     // Render the text.
1378     application.SendNotification();
1379     application.Render();
1380   }
1381   catch( ... )
1382   {
1383     tet_result(TET_FAIL);
1384   }
1385
1386
1387   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1388   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true );
1389   label.SetProperty( Actor::Property::SIZE, Vector2( 400.0f, 10.f ) );
1390
1391   try
1392   {
1393     // Render the text.
1394     application.SendNotification();
1395     application.Render();
1396   }
1397   catch( ... )
1398   {
1399     tet_result(TET_FAIL);
1400   }
1401
1402   END_TEST;
1403 }
1404
1405 int UtcDaliToolkitTextlabelTextWrapMode(void)
1406 {
1407   ToolkitTestApplication application;
1408   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1409
1410   int lineCount =0 ;
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::MULTI_LINE, true );
1416
1417
1418
1419   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1420   application.GetScene().Add( label );
1421
1422   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "WORD" );
1423   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1424
1425   application.SendNotification();
1426   application.Render();
1427
1428   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1429   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1430
1431   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "CHARACTER" );
1432   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1433
1434   application.SendNotification();
1435   application.Render();
1436
1437   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD );
1438   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::WORD ), TEST_LOCATION );
1439
1440   application.SendNotification();
1441   application.Render();
1442
1443   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1444   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1445
1446   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER );
1447   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1448
1449   application.SendNotification();
1450   application.Render();
1451
1452   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1453   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
1454
1455   tet_infoline( "Ensure invalid string does not change wrapping mode" );
1456   label.SetProperty( TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode" );
1457   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( Text::LineWrap::CHARACTER ), TEST_LOCATION );
1458
1459   END_TEST;
1460 }
1461
1462 int UtcDaliToolkitTextLabelColorComponents(void)
1463 {
1464   ToolkitTestApplication application;
1465
1466   TextLabel label = TextLabel::New();
1467   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1468   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   1.0f, TEST_LOCATION );
1469   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1470   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1471   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1472
1473   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::GREEN );
1474   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1475   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 1.0f, TEST_LOCATION );
1476   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  0.0f, TEST_LOCATION );
1477   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1478
1479   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1480   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_RED ),   0.0f, TEST_LOCATION );
1481   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_GREEN ), 0.0f, TEST_LOCATION );
1482   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_BLUE ),  1.0f, TEST_LOCATION );
1483   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 1.0f, TEST_LOCATION );
1484
1485   label.SetProperty( TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f );
1486   DALI_TEST_EQUALS( label.GetProperty< float >( TextLabel::Property::TEXT_COLOR_ALPHA ), 0.6f, TEST_LOCATION );
1487   DALI_TEST_EQUALS( label.GetProperty< Vector4 >( TextLabel::Property::TEXT_COLOR ), Vector4( 0.0f, 0.0f, 1.0f, 0.6f ), TEST_LOCATION );
1488
1489   // Test a transparent text - Rendering should be skipped.
1490   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1491   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::BLUE );
1492
1493   application.GetScene().Add( label );
1494
1495   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1496   drawTrace.Enable( true );
1497
1498   application.SendNotification();
1499   application.Render();
1500
1501   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION );  // Should be rendered
1502
1503   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT );
1504
1505   drawTrace.Reset();
1506
1507   application.SendNotification();
1508   application.Render();
1509
1510   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), false, TEST_LOCATION ); // Rendering should be skipped
1511
1512   label.SetProperty( TextLabel::Property::TEXT_COLOR, Color::RED );
1513
1514   drawTrace.Reset();
1515
1516   application.SendNotification();
1517   application.Render();
1518
1519   DALI_TEST_EQUALS( drawTrace.FindMethod( "DrawArrays" ), true, TEST_LOCATION ); // Should be rendered again
1520
1521   END_TEST;
1522 }
1523
1524 int UtcDaliToolkitTextlabelTextStyle01(void)
1525 {
1526   ToolkitTestApplication application;
1527   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1528
1529   TextLabel label = TextLabel::New();
1530   label.SetProperty( Actor::Property::SIZE, Vector2( 300.0f, 300.f ) );
1531   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world" );
1532   label.SetProperty( TextLabel::Property::POINT_SIZE, 12 );
1533   application.GetScene().Add( label );
1534
1535   Property::Map outlineMapSet;
1536   Property::Map outlineMapGet;
1537
1538   outlineMapSet["color"] = Color::BLUE;
1539   outlineMapSet["width"] = 2.0f;
1540   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1541
1542   application.SendNotification();
1543   application.Render();
1544
1545   Property::Map shadowMapSet;
1546   shadowMapSet.Insert( "color", "green" );
1547   shadowMapSet.Insert( "offset", "2 2" );
1548   shadowMapSet.Insert( "blurRadius", "3" );
1549   label.SetProperty( TextLabel::Property::SHADOW, shadowMapSet );
1550
1551   outlineMapSet["color"] = Color::RED;
1552   outlineMapSet["width"] = 0.0f;
1553   label.SetProperty( TextLabel::Property::OUTLINE, outlineMapSet );
1554
1555   application.SendNotification();
1556   application.Render();
1557
1558   outlineMapGet = label.GetProperty<Property::Map>( TextLabel::Property::OUTLINE );
1559
1560   Property::Value* colorValue = outlineMapGet.Find("color");
1561
1562   bool colorMatched( false );
1563
1564   if ( colorValue )
1565   {
1566      Property::Type valueType = colorValue->GetType();
1567
1568      if ( Property::STRING == valueType )
1569      {
1570        std::string stringValue;
1571        colorValue->Get( stringValue );
1572        if (  stringValue == "red" )
1573        {
1574          colorMatched = true;
1575        }
1576      }
1577      else if ( Property::VECTOR4 == valueType )
1578      {
1579        Vector4 colorVector4;
1580        colorValue->Get( colorVector4 );
1581        if (  colorVector4 == Color::RED )
1582        {
1583          colorMatched = true;
1584        }
1585      }
1586   }
1587
1588   DALI_TEST_EQUALS( colorMatched, true, TEST_LOCATION );
1589
1590   END_TEST;
1591 }
1592
1593 int UtcDaliToolkitTextlabelMultiline(void)
1594 {
1595   ToolkitTestApplication application;
1596   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1597
1598   TextLabel label = TextLabel::New();
1599   label.SetProperty( TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world" );
1600   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1601   label.SetProperty( TextLabel::Property::MULTI_LINE, false );
1602   application.GetScene().Add( label );
1603
1604   application.SendNotification();
1605   application.Render();
1606
1607   int lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1608   DALI_TEST_EQUALS( lineCount, 1, TEST_LOCATION );
1609
1610   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1611
1612   application.SendNotification();
1613   application.Render();
1614
1615   lineCount =  label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
1616   DALI_TEST_EQUALS( true, (lineCount > 1) , TEST_LOCATION );
1617
1618
1619   END_TEST;
1620 }
1621
1622 int UtcDaliToolkitTextlabelTextDirection(void)
1623 {
1624   ToolkitTestApplication application;
1625   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1626
1627   TextLabel label = TextLabel::New();
1628   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1629
1630   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1631   label.SetProperty( TextLabel::Property::POINT_SIZE, 20 );
1632   label.SetProperty( DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false );
1633   application.GetScene().Add( label );
1634
1635   // Test LTR text
1636   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT ), TEST_LOCATION );
1637
1638   // Test RTL text
1639   label.SetProperty( TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1640   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1641
1642   // Test RTL text starting with weak character
1643   label.SetProperty( TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1644   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1645
1646   // Test RTL text string with emoji and weak character
1647   label.SetProperty( TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ" );
1648   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::TEXT_DIRECTION ), static_cast< int >( Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT ), TEST_LOCATION );
1649
1650   END_TEST;
1651 }
1652
1653 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1654 {
1655   ToolkitTestApplication application;
1656   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1657
1658   TextLabel label = TextLabel::New();
1659
1660   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP  );
1661   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1662   label.SetProperty( TextLabel::Property::POINT_SIZE, 15 );
1663   label.SetProperty( TextLabel::Property::LINE_SPACING, 12 );
1664   application.GetScene().Add( label );
1665   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::TOP ), TEST_LOCATION );
1666
1667   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE  );
1668   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::MIDDLE ), TEST_LOCATION );
1669
1670   label.SetProperty( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM  );
1671   DALI_TEST_EQUALS( label.GetProperty< int >( DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT ), static_cast< int >( Toolkit::DevelText::VerticalLineAlignment::BOTTOM ), TEST_LOCATION );
1672
1673   END_TEST;
1674 }
1675
1676 int UtcDaliToolkitTextLabelBitmapFont(void)
1677 {
1678   ToolkitTestApplication application;
1679   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1680
1681   DevelText::BitmapFontDescription fontDescription;
1682   fontDescription.name = "Digits";
1683   fontDescription.underlinePosition = 0.f;
1684   fontDescription.underlineThickness = 0.f;
1685
1686   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f } );
1687   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f } );
1688   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f } );
1689   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f } );
1690   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f } );
1691   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f } );
1692   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f } );
1693   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f } );
1694   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f } );
1695   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f } );
1696   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f } );
1697
1698   TextAbstraction::BitmapFont bitmapFont;
1699   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1700
1701   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1702   fontClient.GetFontId( bitmapFont );
1703
1704   TextLabel label = TextLabel::New();
1705
1706   label.SetProperty( TextLabel::Property::TEXT, "0123456789:" );
1707   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1708
1709   // 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.
1710   DALI_TEST_EQUALS( label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1711
1712   application.GetScene().Add( label );
1713
1714   application.SendNotification();
1715   application.Render();
1716
1717   // The text has been rendered if the height of the text-label is the height of the line.
1718   DALI_TEST_EQUALS( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION );
1719
1720   END_TEST;
1721 }
1722
1723 int ConvertPointToPixel( float point )
1724 {
1725   unsigned int horizontalDpi = 0u;
1726   unsigned int verticalDpi = 0u;
1727   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1728   fontClient.GetDpi( horizontalDpi, verticalDpi );
1729
1730   return ( point * 72.f ) / static_cast< float >( horizontalDpi );
1731 }
1732
1733 int UtcDaliToolkitTextlabelTextFit(void)
1734 {
1735   ToolkitTestApplication application;
1736   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1737   TextLabel label = TextLabel::New();
1738   Vector2 size( 460.0f, 100.0f );
1739   label.SetProperty( Actor::Property::SIZE, size );
1740   label.SetProperty( TextLabel::Property::TEXT, "Hello world" );
1741
1742    // connect to the text git changed signal.
1743   ConnectionTracker* testTracker = new ConnectionTracker();
1744   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1745   bool textFitChangedSignal = false;
1746   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1747   gTextFitChangedCallBackCalled = false;
1748
1749   // check point size
1750   Property::Map textFitMapSet;
1751   textFitMapSet["enable"] = true;
1752   textFitMapSet["minSize"] = 10.f;
1753   textFitMapSet["maxSize"] = 100.f;
1754   textFitMapSet["stepSize"] = -1.f;
1755   textFitMapSet["fontSizeType"] = "pointSize";
1756
1757   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1758   label.SetProperty( TextLabel::Property::POINT_SIZE, 120.f);
1759
1760   application.GetScene().Add( label );
1761
1762   application.SendNotification();
1763   application.Render();
1764
1765   const Vector3 EXPECTED_NATURAL_SIZE( 450.0f, 96.0f, 0.0f );
1766   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1767
1768   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
1769   DALI_TEST_CHECK(textFitChangedSignal);
1770
1771   // check pixel size
1772   textFitMapSet.Clear();
1773   textFitMapSet["enable"] = true;
1774   textFitMapSet["minSize"] = ConvertPointToPixel( 10.f );
1775   textFitMapSet["maxSize"] = ConvertPointToPixel( 100.f );
1776   textFitMapSet["stepSize"] = ConvertPointToPixel ( 1.f );
1777   textFitMapSet["fontSizeType"] = "pixelSize";
1778
1779   label.SetProperty( Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet );
1780
1781   application.SendNotification();
1782   application.Render();
1783
1784   DALI_TEST_EQUALS( EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION );
1785
1786   END_TEST;
1787 }
1788
1789 int UtcDaliToolkitTextlabelMaxTextureSet(void)
1790 {
1791   ToolkitTestApplication application;
1792   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
1793
1794   DevelText::BitmapFontDescription fontDescription;
1795   fontDescription.name = "Digits";
1796   fontDescription.glyphs.push_back( { TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f } );
1797
1798   TextAbstraction::BitmapFont bitmapFont;
1799   DevelText::CreateBitmapFont( fontDescription, bitmapFont );
1800
1801   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1802   fontClient.GetFontId( bitmapFont );
1803
1804   TextLabel label = TextLabel::New();
1805   label.SetProperty( TextLabel::Property::FONT_FAMILY, "Digits" );
1806   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
1807   label.SetProperty( TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded." );
1808   label.SetProperty( TextLabel::Property::POINT_SIZE, 200.f );
1809   label.SetProperty( TextLabel::Property::MULTI_LINE, true );
1810
1811   Property::Map underlineMapSet;
1812   underlineMapSet.Clear();
1813   underlineMapSet.Insert( "enable", true );
1814   underlineMapSet.Insert( "color", Color::RED );
1815   underlineMapSet.Insert( "height", 1 );
1816   label.SetProperty( TextLabel::Property::UNDERLINE, underlineMapSet );
1817   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1818
1819   Property::Map strikethroughMapSet;
1820   strikethroughMapSet.Clear();
1821   strikethroughMapSet.Insert( "enable", true );
1822   strikethroughMapSet.Insert( "color", Color::RED );
1823   strikethroughMapSet.Insert( "height", 2.0f );
1824   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
1825   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1826
1827   application.GetScene().Add( label );
1828
1829   application.SendNotification();
1830   application.Render();
1831
1832   const int maxTextureSize = Dali::GetMaxTextureSize();
1833   // Whether the rendered text is greater than maxTextureSize
1834   DALI_TEST_CHECK( label.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).height > maxTextureSize );
1835
1836   // Check if the number of renderers is greater than 1.
1837   DALI_TEST_CHECK( label.GetRendererCount() > 1u );
1838
1839   END_TEST;
1840 }
1841
1842 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
1843 {
1844   ToolkitTestApplication application;
1845   tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
1846
1847   TextLabel label = TextLabel::New();
1848   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1849   label.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1850
1851   //Exeeding BufferWidth
1852   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
1853   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
1854   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
1855
1856   application.GetScene().Add( label );
1857   application.SendNotification();
1858   application.Render();
1859
1860   Property::Map strikethroughMapSet;
1861   strikethroughMapSet.Clear();
1862   strikethroughMapSet.Insert( "enable", true );
1863   strikethroughMapSet.Insert( "color", Color::BLUE);
1864   strikethroughMapSet.Insert( "height", 2.0f);
1865   label.SetProperty( TextLabel::Property::TEXT, "Test1" );
1866   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
1867   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1868   application.GetScene().Add( label );
1869   application.SendNotification();
1870   application.Render();
1871   // Check if the number of renderers is 1.
1872   DALI_TEST_EQUALS( 1, label.GetRendererCount(), TEST_LOCATION);
1873
1874
1875   label = TextLabel::New();
1876   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1877   label.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
1878
1879   //Exeeding BufferHeight
1880   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
1881   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
1882   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
1883
1884   application.GetScene().Add( label );
1885   application.SendNotification();
1886   application.Render();
1887
1888   strikethroughMapSet.Clear();
1889   strikethroughMapSet.Insert( "enable", true );
1890   strikethroughMapSet.Insert( "color", Color::BLUE);
1891   strikethroughMapSet.Insert( "height", 2.0f);
1892   label.SetProperty( TextLabel::Property::TEXT, "Test2" );
1893   label.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
1894   label.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE );
1895   application.GetScene().Add( label );
1896   application.SendNotification();
1897   application.Render();
1898   // Check if the number of renderers is 1.
1899   DALI_TEST_EQUALS( 1, label.GetRendererCount(), TEST_LOCATION);
1900
1901   END_TEST;
1902 }
1903
1904 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
1905 {
1906   ToolkitTestApplication application;
1907   tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
1908
1909   Vector2 size( 300.0f, 100.0f );
1910
1911   Dali::Toolkit::DevelText::RendererParameters textParameters;
1912   textParameters.text = "This is a sample text to get the last index.";
1913   textParameters.layout = "multiLine";
1914   textParameters.fontSize = 20.f;
1915   textParameters.textWidth = 300u;
1916   textParameters.textHeight = 100u;
1917   textParameters.ellipsisEnabled = true;
1918   Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex( textParameters );
1919
1920   DALI_TEST_CHECK( !indexArray.Empty() );
1921   DALI_TEST_EQUALS( indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION );
1922
1923   END_TEST;
1924 }
1925
1926 int UtcDaliToolkitTextlabelFontSizeScale(void)
1927 {
1928   ToolkitTestApplication application;
1929   tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
1930
1931   TextLabel label = TextLabel::New();
1932   label.SetProperty( TextLabel::Property::POINT_SIZE, 30.f );
1933   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1934   Vector3 nonScaledSize = label.GetNaturalSize();
1935
1936   TextLabel labelScaled = TextLabel::New();
1937   labelScaled.SetProperty( TextLabel::Property::POINT_SIZE, 15.f );
1938   labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1939   labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1940   Vector3 scaledSize = labelScaled.GetNaturalSize();
1941
1942   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1943
1944   label.SetProperty( TextLabel::Property::PIXEL_SIZE, 30.f );
1945   label.SetProperty( TextLabel::Property::TEXT, "Test" );
1946   nonScaledSize = label.GetNaturalSize();
1947
1948   labelScaled.SetProperty( TextLabel::Property::PIXEL_SIZE, 15.f );
1949   labelScaled.SetProperty( Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f );
1950   labelScaled.SetProperty( TextLabel::Property::TEXT, "Test" );
1951   scaledSize = labelScaled.GetNaturalSize();
1952
1953   DALI_TEST_EQUALS( nonScaledSize, scaledSize, TEST_LOCATION );
1954
1955   END_TEST;
1956 }
1957
1958 // Positive test for the anchorClicked signal.
1959 int UtcDaliToolkitTextlabelAnchorClicked(void)
1960 {
1961   ToolkitTestApplication application;
1962   tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
1963   TextLabel label = TextLabel::New();
1964   DALI_TEST_CHECK(label);
1965
1966   application.GetScene().Add(label);
1967
1968   // connect to the anchor clicked signal.
1969   ConnectionTracker* testTracker = new ConnectionTracker();
1970   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
1971   bool anchorClickedSignal = false;
1972   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
1973
1974   gAnchorClickedCallBackCalled = false;
1975   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
1976   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1977   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
1978   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
1979   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
1980
1981   application.SendNotification();
1982   application.Render();
1983
1984   // Create a tap event to touch the text label.
1985   TestGenerateTap(application, 5.0f, 25.0f, 100);
1986   application.SendNotification();
1987   application.Render();
1988
1989   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
1990   DALI_TEST_CHECK(anchorClickedSignal);
1991
1992   // reset
1993   gAnchorClickedCallBackCalled = false;
1994   anchorClickedSignal = false;
1995   label.SetProperty(TextLabel::Property::TEXT, "");
1996   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
1997
1998   application.SendNotification();
1999   application.Render();
2000
2001   // sets anchor text
2002   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2003   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2004   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2005   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2006   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2007
2008   application.SendNotification();
2009   application.Render();
2010
2011   // Create a tap event to touch the text label.
2012   TestGenerateTap(application, 5.0f, 25.0f, 200);
2013   application.SendNotification();
2014   application.Render();
2015
2016   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2017   DALI_TEST_CHECK(anchorClickedSignal);
2018
2019
2020   gAnchorClickedCallBackNotCalled = true;
2021   // Tap the outside of anchor, callback should not be called.
2022   TestGenerateTap(application, 150.f, 100.f, 300);
2023   application.SendNotification();
2024   application.Render();
2025
2026   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2027
2028   END_TEST;
2029 }
2030
2031 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2032 {
2033   ToolkitTestApplication application;
2034   tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2035
2036   //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2037
2038   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2039   const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2040   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2041
2042   // Create a text editor
2043   TextLabel textLabel = TextLabel::New();
2044   //Set size to avoid automatic eliding
2045   textLabel.SetProperty( Actor::Property::SIZE, Vector2(1025, 1025));
2046   //Set very large font-size using point-size
2047   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 1000);
2048   //Specify font-family
2049   textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2050   //Set text to check if appear or not
2051   textLabel.SetProperty( TextLabel::Property::TEXT, "A");
2052
2053   application.GetScene().Add( textLabel );
2054
2055   application.SendNotification();
2056   application.Render();
2057   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2058   Vector3 naturalSize = textLabel.GetNaturalSize();
2059
2060   DALI_TEST_GREATER( lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION );
2061   DALI_TEST_GREATER( lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION );
2062
2063   END_TEST;
2064 }
2065
2066 int UtcDaliTextLabelHyphenWrapMode(void)
2067 {
2068   ToolkitTestApplication application;
2069   tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2070
2071   int lineCount =0;
2072   TextLabel label = TextLabel::New();
2073   label.SetProperty( Actor::Property::SIZE, Vector2( 150.0f, 300.f ));
2074   label.SetProperty( TextLabel::Property::POINT_SIZE, 12.f );
2075   label.SetProperty( TextLabel::Property::MULTI_LINE, true);
2076   application.GetScene().Add( label );
2077   application.SendNotification();
2078   application.Render();
2079
2080   label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
2081   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::HYPHENATION);
2082   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::HYPHENATION ), TEST_LOCATION );
2083
2084   application.SendNotification();
2085   application.Render();
2086
2087   lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2088   /*
2089     text will be :
2090     Hi Exp-
2091     erimen
2092   */
2093   DALI_TEST_EQUALS( lineCount, 2, TEST_LOCATION );
2094
2095   label.SetProperty( TextLabel::Property::TEXT, "Hi Experimen" );
2096   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE,DevelText::LineWrap::MIXED);
2097   DALI_TEST_EQUALS( label.GetProperty< int >( TextLabel::Property::LINE_WRAP_MODE ), static_cast< int >( DevelText::LineWrap::MIXED ), TEST_LOCATION );
2098
2099   application.SendNotification();
2100   application.Render();
2101
2102   lineCount = label.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2103   /*
2104     text will be :
2105     Hi
2106     Experi-
2107     men
2108   */
2109   DALI_TEST_EQUALS( lineCount, 3, TEST_LOCATION );
2110
2111   END_TEST;
2112 }
2113
2114 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2115 {
2116   ToolkitTestApplication application;
2117
2118   tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2119
2120   int lineCountBefore =0 ;
2121   int lineCountAfter =0 ;
2122
2123   // Create a text editor
2124   TextLabel textLabel = TextLabel::New();
2125   //Set very large font-size using point-size
2126   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
2127   //Specify font-family
2128   textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2129   //Specify size
2130   textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 100.f ) );
2131   //Set text longer than width of textLabel
2132   textLabel.SetProperty( TextLabel::Property::TEXT, "Short text");
2133   //Set line wrap mode Character
2134   textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2135   textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2136
2137   application.GetScene().Add( textLabel );
2138
2139   application.SendNotification();
2140   application.Render();
2141
2142
2143   lineCountBefore =  textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2144
2145   textLabel.SetProperty( TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2146   lineCountAfter =  textLabel.GetProperty<int>( TextLabel::Property::LINE_COUNT );
2147
2148   // When the text changed, the Line-count should be updated according to new text.
2149   // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2150   DALI_TEST_EQUALS( lineCountBefore ,1, TEST_LOCATION );
2151   DALI_TEST_GREATER( lineCountAfter,1, TEST_LOCATION );
2152
2153
2154   END_TEST;
2155 }
2156
2157 int utcDaliTextLabelGeometryRTL(void)
2158 {
2159   ToolkitTestApplication application;
2160   tet_infoline(" utcDaliTextLabelGeometryRTL");
2161
2162   TextLabel label = TextLabel::New();
2163   DALI_TEST_CHECK( label );
2164
2165   application.GetScene().Add( label );
2166
2167   label.SetProperty( TextLabel::Property::POINT_SIZE, 7.f );
2168   label.SetProperty( Actor::Property::SIZE, Vector2( 150.f, 100.f ) );
2169   label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2170   label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2171   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
2172   label.SetProperty( TextLabel::Property::MULTI_LINE, true);
2173   label.SetProperty( TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر" );
2174
2175   // Avoid a crash when core load gl resources.
2176   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2177
2178   // Render and notify
2179   application.SendNotification();
2180   application.Render();
2181
2182   unsigned int expectedCount = 4;
2183   unsigned int startIndex = 3;
2184   unsigned int endIndex = 24;
2185
2186   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2187   Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2188
2189   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2190   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2191
2192   Vector<Vector2> expectedSizes;
2193   Vector<Vector2> expectedPositions;
2194
2195   expectedPositions.PushBack(Vector2(24, 0));
2196   expectedSizes.PushBack(Vector2(33, 25));
2197
2198   expectedPositions.PushBack(Vector2(-1, 25));
2199   expectedSizes.PushBack(Vector2(52, 25));
2200
2201   expectedPositions.PushBack(Vector2(-1, 50));
2202   expectedSizes.PushBack(Vector2(59, 25));
2203
2204   expectedPositions.PushBack(Vector2(73, 75));
2205   expectedSizes.PushBack(Vector2(37, 25));
2206
2207   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2208
2209   END_TEST;
2210 }
2211
2212 int utcDaliTextLabelGeometryGlyphMiddle(void)
2213 {
2214   ToolkitTestApplication application;
2215   tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2216
2217   TextLabel label = TextLabel::New();
2218   DALI_TEST_CHECK( label );
2219
2220   application.GetScene().Add( label );
2221
2222   label.SetProperty( TextLabel::Property::POINT_SIZE, 7.f );
2223   label.SetProperty( Actor::Property::SIZE, Vector2( 200.f, 200.f ) );
2224   label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
2225   label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
2226   label.SetProperty( TextLabel::Property::ENABLE_MARKUP, true );
2227   label.SetProperty( TextLabel::Property::TEXT, "لا تحتوي على لا" );
2228
2229   // Avoid a crash when core load gl resources.
2230   application.GetGlAbstraction().SetCheckFramebufferStatusResult( GL_FRAMEBUFFER_COMPLETE );
2231
2232   // Render and notify
2233   application.SendNotification();
2234   application.Render();
2235
2236   unsigned int expectedCount = 1;
2237   unsigned int startIndex = 1;
2238   unsigned int endIndex = 13;
2239
2240   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2241   Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2242
2243   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2244   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2245
2246   Vector<Vector2> expectedSizes;
2247   Vector<Vector2> expectedPositions;
2248
2249   expectedPositions.PushBack(Vector2(12, 0));
2250   expectedSizes.PushBack(Vector2(118, 25));
2251
2252   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2253
2254   END_TEST;
2255 }
2256
2257 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2258 {
2259   ToolkitTestApplication application;
2260   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2261   TextLabel textLabel = TextLabel::New();
2262
2263   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2264   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2265
2266   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2267   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2268   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2269
2270   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2271   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2272   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2273
2274   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2275   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2276   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2277
2278   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2279   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2280   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2281
2282   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2283   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2284   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2285
2286   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2287   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2288   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2289
2290   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2291   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2292   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2293
2294   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2295   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2296   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2297
2298   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2299   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2300   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2301
2302   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2303   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2304   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::START ), TEST_LOCATION );
2305
2306   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2307   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2308   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::MIDDLE ), TEST_LOCATION );
2309
2310   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2311   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2312   DALI_TEST_EQUALS( textLabel.GetProperty< int >( DevelTextLabel::Property::ELLIPSIS_POSITION ), static_cast< int >( Toolkit::DevelText::EllipsisPosition::END ), TEST_LOCATION );
2313
2314
2315   END_TEST;
2316 }
2317
2318 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
2319 {
2320   ToolkitTestApplication application;
2321   tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
2322
2323   TextLabel textLabel = TextLabel::New();
2324   textLabel.SetProperty( TextLabel::Property::TEXT, "Test" );
2325   textLabel.SetProperty( Actor::Property::SIZE, Vector2( 200.0f, 100.f ) );
2326   textLabel.SetProperty( TextLabel::Property::POINT_SIZE, 10) ;
2327   textLabel.SetProperty( TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2328
2329   application.GetScene().Add( textLabel );
2330   application.SendNotification();
2331   application.Render();
2332
2333   Property::Map strikethroughMapSet;
2334   Property::Map strikethroughMapGet;
2335
2336   strikethroughMapSet.Insert( "enable", true );
2337   strikethroughMapSet.Insert( "color", Color::RED );
2338   strikethroughMapSet.Insert( "height", 2.0f );
2339
2340   // Check the strikethrough property
2341   textLabel.SetProperty( DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet );
2342   strikethroughMapGet = textLabel.GetProperty<Property::Map>( DevelTextLabel::Property::STRIKETHROUGH );
2343   textLabel.SetProperty( TextLabel::Property::TEXT, "Test1" );
2344   DALI_TEST_EQUALS( strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION );
2345   DALI_TEST_EQUALS( DaliTestCheckMaps( strikethroughMapGet, strikethroughMapSet ), true, TEST_LOCATION );
2346
2347   // Render and notify
2348   application.SendNotification();
2349   application.Render();
2350
2351   strikethroughMapSet.Clear();
2352   strikethroughMapGet.Clear();
2353
2354   END_TEST;
2355 }