Merge "Destroy removal visuals after idler" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2022 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 <stdlib.h>
19 #include <unistd.h>
20 #include <iostream>
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/bitmap-font.h>
27 #include <dali-toolkit/devel-api/text/rendering-backend.h>
28 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
29 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
30 #include <dali/devel-api/adaptor-framework/image-loading.h>
31 #include <dali/devel-api/text-abstraction/bitmap-font.h>
32 #include <dali/devel-api/text-abstraction/font-client.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 const char* const PROPERTY_NAME_RENDERING_BACKEND        = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT                     = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY              = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE               = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE               = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE               = "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT     = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT       = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR               = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP            = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL       = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP   = "autoScrollGap";
64
65 const char* const PROPERTY_NAME_LINE_SPACING  = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE     = "underline";
67 const char* const PROPERTY_NAME_SHADOW        = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS        = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE       = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND    = "textBackground";
71 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
72
73 const char* const PROPERTY_NAME_PIXEL_SIZE             = "pixelSize";
74 const char* const PROPERTY_NAME_ELLIPSIS               = "ellipsis";
75 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
76 const char* const PROPERTY_NAME_FONT_SIZE_SCALE        = "fontSizeScale";
77 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
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_ENABLE_FONT_SIZE_SCALE) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE);
357   DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS_POSITION) == DevelTextLabel::Property::ELLIPSIS_POSITION);
358   DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextLabel::Property::STRIKETHROUGH);
359
360   END_TEST;
361 }
362
363 int UtcDaliToolkitTextLabelSetPropertyP(void)
364 {
365   ToolkitTestApplication application;
366   tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
367   TextLabel label = TextLabel::New();
368   DALI_TEST_CHECK(label);
369
370   application.GetScene().Add(label);
371
372   // Note - we can't check the defaults since the stylesheets are platform-specific
373   label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
374   DALI_TEST_EQUALS((DevelText::RenderingType)label.GetProperty<int>(DevelTextLabel::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
375
376   // Check that text can be correctly reset
377   label.SetProperty(TextLabel::Property::TEXT, "Setting Text");
378   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
379
380   // Check font properties.
381   label.SetProperty(TextLabel::Property::FONT_FAMILY, "Setting font family");
382   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
383
384   Property::Map fontStyleMapSet;
385   Property::Map fontStyleMapGet;
386
387   fontStyleMapSet.Insert("weight", "bold");
388   fontStyleMapSet.Insert("width", "condensed");
389   fontStyleMapSet.Insert("slant", "italic");
390   label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
391
392   fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
393   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
394   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
395
396   // Check the old font style format.
397   fontStyleMapSet.Clear();
398   fontStyleMapSet.Insert("weight", "thin");
399   fontStyleMapSet.Insert("width", "expanded");
400   fontStyleMapSet.Insert("slant", "oblique");
401   const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
402
403   label.SetProperty(TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}");
404   std::string getFontStyle = label.GetProperty<std::string>(TextLabel::Property::FONT_STYLE);
405   DALI_TEST_EQUALS(getFontStyle, strFontStyle, TEST_LOCATION);
406
407   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
408   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
409
410   label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f);
411   DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
412   label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f);
413
414   label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, false);
415   DALI_TEST_EQUALS(label.GetProperty<bool>(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
416   label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, true);
417
418   // Reset font style.
419   fontStyleMapSet.Clear();
420   fontStyleMapSet.Insert("weight", "normal");
421   fontStyleMapSet.Insert("slant", "oblique");
422
423   label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
424   fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
425   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
426   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
427
428   fontStyleMapSet.Clear();
429   fontStyleMapSet.Insert("slant", "roman");
430
431   label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
432   fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
433   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
434
435   // Replace 'roman' for 'normal'.
436   Property::Value* slantValue = fontStyleMapGet.Find("slant");
437   if(NULL != slantValue)
438   {
439     if("normal" == slantValue->Get<std::string>())
440     {
441       fontStyleMapGet["slant"] = "roman";
442     }
443   }
444   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
445
446   fontStyleMapSet.Clear();
447
448   label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
449   fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
450   DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
451   DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
452
453   // Toggle multi-line
454   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
455   DALI_TEST_EQUALS(label.GetProperty<bool>(TextLabel::Property::MULTI_LINE), true, TEST_LOCATION);
456
457   // Check that the Alignment properties can be correctly set
458   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
459   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::HORIZONTAL_ALIGNMENT), "CENTER", TEST_LOCATION);
460   label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
461   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
462
463   // Check that text color can be properly set
464   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
465   DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Color::BLUE, TEST_LOCATION);
466
467   Property::Map strikethroughMapSet;
468   Property::Map strikethroughMapGet;
469
470   strikethroughMapSet.Insert("enable", false);
471   strikethroughMapSet.Insert("color", Color::BLUE);
472   strikethroughMapSet.Insert("height", 2.0f);
473
474   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
475
476   strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
477   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
478   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
479
480   Property::Map underlineMapSet;
481   Property::Map underlineMapGet;
482
483   underlineMapSet.Insert("enable", false);
484   underlineMapSet.Insert("color", Color::BLUE);
485   underlineMapSet.Insert("height", 0);
486   underlineMapSet.Insert("type", Text::Underline::SOLID);
487   underlineMapSet.Insert("dashWidth", 2);
488   underlineMapSet.Insert("dashGap", 1);
489
490   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
491
492   application.SendNotification();
493   application.Render();
494
495   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
496   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
497   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
498
499   //DASHED Underline
500   underlineMapSet.Clear();
501   underlineMapGet.Clear();
502
503   underlineMapSet.Insert("enable", false);
504   underlineMapSet.Insert("color", Color::BLUE);
505   underlineMapSet.Insert("height", 0);
506   underlineMapSet.Insert("type", Text::Underline::DASHED);
507   underlineMapSet.Insert("dashWidth", 2);
508   underlineMapSet.Insert("dashGap", 1);
509
510   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
511
512   application.SendNotification();
513   application.Render();
514
515   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
516   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
517   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
518
519   //DOUBLE Underline
520   underlineMapSet.Clear();
521   underlineMapGet.Clear();
522
523   underlineMapSet.Insert("enable", false);
524   underlineMapSet.Insert("color", Color::BLUE);
525   underlineMapSet.Insert("height", 0);
526   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
527   underlineMapSet.Insert("dashWidth", 2);
528   underlineMapSet.Insert("dashGap", 1);
529
530   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
531
532   application.SendNotification();
533   application.Render();
534
535   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
536   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
537   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
538
539   TextLabel label2 = TextLabel::New("New text");
540   DALI_TEST_CHECK(label2);
541   DALI_TEST_EQUALS(label2.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("New text"), TEST_LOCATION);
542
543   // Check the enable markup property.
544   DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
545   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
546   DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
547
548   // Check the text property when markup is enabled
549   label.SetProperty(TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>");
550   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
551
552   // Check for incomplete marks.
553   label.SetProperty(TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>");
554   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
555   try
556   {
557     application.SendNotification();
558     application.Render();
559   }
560   catch(...)
561   {
562     tet_result(TET_FAIL);
563   }
564
565   // Check autoscroll properties
566   const int         SCROLL_SPEED      = 80;
567   const int         SCROLL_LOOPS      = 4;
568   const float       SCROLL_GAP        = 50.0f;
569   const float       SCROLL_LOOP_DELAY = 0.3f;
570   const std::string STOP_IMMEDIATE    = std::string("IMMEDIATE");
571   const std::string STOP_FINISH_LOOP  = std::string("FINISH_LOOP");
572
573   label.SetProperty(TextLabel::Property::MULTI_LINE, false); // Autoscroll only supported in single line
574   DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
575   label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
576   DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
577   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED);
578   DALI_TEST_EQUALS(SCROLL_SPEED, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_SPEED), TEST_LOCATION);
579   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS);
580   DALI_TEST_EQUALS(SCROLL_LOOPS, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT), TEST_LOCATION);
581   label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP);
582   DALI_TEST_EQUALS(SCROLL_GAP, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_GAP), TEST_LOCATION);
583   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY);
584   DALI_TEST_EQUALS(SCROLL_LOOP_DELAY, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY), TEST_LOCATION);
585
586   //Check autoscroll stop type property
587   label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
588   DALI_TEST_EQUALS(STOP_IMMEDIATE, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
589
590   label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
591   DALI_TEST_EQUALS(STOP_FINISH_LOOP, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
592
593   // test natural size with multi-line and line spacing
594   {
595     TextLabel label3             = TextLabel::New("Some text here\nend there\nend here");
596     Vector3   oneLineNaturalSize = label3.GetNaturalSize();
597     label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
598     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
599     Vector3 multiLineNaturalSize = label3.GetNaturalSize();
600
601     // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
602     // The height of the text when multi-line is enabled will be larger
603     DALI_TEST_CHECK(oneLineNaturalSize.width > multiLineNaturalSize.width);
604     DALI_TEST_CHECK(oneLineNaturalSize.height < multiLineNaturalSize.height);
605
606     // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
607     // Everything else will remain the same
608     int lineSpacing = 20;
609     label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
610     Vector3 expectedAfterLineSpacingApplied(multiLineNaturalSize);
611     expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
612     DALI_TEST_EQUALS(expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION);
613   }
614
615   // single line, line spacing must not affect natural size of the text, only add the spacing to the height
616   {
617     TextLabel label3 = TextLabel::New("Some text here end there end here");
618     label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
619     label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
620     Vector3 textNaturalSize = label3.GetNaturalSize();
621     int     lineSpacing     = 20;
622     label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
623     Vector3 expectedNaturalSizeWithLineSpacing(textNaturalSize);
624     expectedNaturalSizeWithLineSpacing.height += lineSpacing;
625     DALI_TEST_EQUALS(expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION);
626   }
627   // Check the line spacing property
628   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
629   label.SetProperty(TextLabel::Property::LINE_SPACING, 10.f);
630   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
631
632   // Check the strikethrough property
633   strikethroughMapSet.Clear();
634   strikethroughMapSet.Insert("enable", true);
635   strikethroughMapSet.Insert("color", Color::RED);
636   strikethroughMapSet.Insert("height", 2.0f);
637
638   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
639
640   application.SendNotification();
641   application.Render();
642
643   strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
644   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
645   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
646
647   // Check the transparent strikethrough property for coverage.
648   strikethroughMapSet.Clear();
649   strikethroughMapSet.Insert("enable", true);
650   strikethroughMapSet.Insert("color", Color::TRANSPARENT);
651   strikethroughMapSet.Insert("height", 2.0f);
652
653   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
654
655   application.SendNotification();
656   application.Render();
657
658   strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
659   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
660   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
661
662   strikethroughMapSet.Clear();
663   strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::ENABLE, true);
664   strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED);
665   strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::HEIGHT, 2.0f);
666
667   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
668
669   application.SendNotification();
670   application.Render();
671
672   strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
673   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
674   std::vector<std::string> strikethroughIndicesConversionTable = {"enable", "color", "height"};
675   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet, strikethroughIndicesConversionTable), true, TEST_LOCATION);
676
677   strikethroughMapSet.Clear();
678
679   Property::Map strikethroughDisabledMapGet;
680   strikethroughDisabledMapGet.Insert("enable", false);
681   strikethroughDisabledMapGet.Insert("color", Color::RED);
682   strikethroughDisabledMapGet.Insert("height", 2.0f);
683
684   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
685
686   application.SendNotification();
687   application.Render();
688
689   strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
690   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughDisabledMapGet.Count(), TEST_LOCATION);
691   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughDisabledMapGet), true, TEST_LOCATION);
692
693   // Check the underline property
694   underlineMapSet.Clear();
695   underlineMapSet.Insert("enable", true);
696   underlineMapSet.Insert("color", Color::RED);
697   underlineMapSet.Insert("height", 1);
698   underlineMapSet.Insert("type", Text::Underline::SOLID);
699   underlineMapSet.Insert("dashWidth", 2);
700   underlineMapSet.Insert("dashGap", 1);
701
702   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
703
704   application.SendNotification();
705   application.Render();
706
707   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
708   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
709   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
710
711   underlineMapSet.Clear();
712   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
713   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
714   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
715   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
716   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
717   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
718
719   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
720
721   application.SendNotification();
722   application.Render();
723
724   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
725   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
726   std::vector<std::string> underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
727   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
728
729   underlineMapSet.Clear();
730
731   Property::Map underlineDisabledMapGet;
732   underlineDisabledMapGet.Insert("enable", false);
733   underlineDisabledMapGet.Insert("color", Color::GREEN);
734   underlineDisabledMapGet.Insert("height", 2);
735   underlineDisabledMapGet.Insert("type", Text::Underline::SOLID);
736   underlineDisabledMapGet.Insert("dashWidth", 2);
737   underlineDisabledMapGet.Insert("dashGap", 1);
738
739   label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
740
741   application.SendNotification();
742   application.Render();
743
744   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
745   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
746   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
747
748   // Check the dashed underline property
749   underlineMapSet.Clear();
750   underlineMapSet.Insert("enable", true);
751   underlineMapSet.Insert("color", Color::RED);
752   underlineMapSet.Insert("height", 1);
753   underlineMapSet.Insert("type", Text::Underline::DASHED);
754   underlineMapSet.Insert("dashWidth", 2);
755   underlineMapSet.Insert("dashGap", 1);
756
757   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
758
759   application.SendNotification();
760   application.Render();
761
762   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
763   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
764   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
765
766   underlineMapSet.Clear();
767   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
768   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
769   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
770   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
771   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
772   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
773
774   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
775
776   application.SendNotification();
777   application.Render();
778
779   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
780   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
781   underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
782   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
783
784   underlineMapSet.Clear();
785
786   underlineDisabledMapGet.Clear();
787   underlineDisabledMapGet.Insert("enable", false);
788   underlineDisabledMapGet.Insert("color", Color::GREEN);
789   underlineDisabledMapGet.Insert("height", 2);
790   underlineDisabledMapGet.Insert("type", Text::Underline::DASHED);
791   underlineDisabledMapGet.Insert("dashWidth", 2);
792   underlineDisabledMapGet.Insert("dashGap", 1);
793
794   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
795
796   application.SendNotification();
797   application.Render();
798
799   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
800   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
801   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
802
803   // Check the double underline property
804   underlineMapSet.Clear();
805   underlineMapSet.Insert("enable", true);
806   underlineMapSet.Insert("color", Color::RED);
807   underlineMapSet.Insert("height", 1);
808   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
809   underlineMapSet.Insert("dashWidth", 2);
810   underlineMapSet.Insert("dashGap", 1);
811
812   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
813
814   application.SendNotification();
815   application.Render();
816
817   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
818   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
819   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
820
821   // Check the transparent double underline property for coverage.
822   underlineMapSet.Clear();
823   underlineMapSet.Insert("enable", true);
824   underlineMapSet.Insert("color", Color::TRANSPARENT);
825   underlineMapSet.Insert("height", 1);
826   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
827   underlineMapSet.Insert("dashWidth", 2);
828   underlineMapSet.Insert("dashGap", 1);
829
830   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
831
832   application.SendNotification();
833   application.Render();
834
835   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
836   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
837   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
838
839   underlineMapSet.Clear();
840   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
841   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
842   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
843   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DOUBLE);
844   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
845   underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
846
847   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
848
849   application.SendNotification();
850   application.Render();
851
852   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
853   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
854   underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
855   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
856
857   underlineMapSet.Clear();
858
859   underlineDisabledMapGet.Clear();
860   underlineDisabledMapGet.Insert("enable", false);
861   underlineDisabledMapGet.Insert("color", Color::GREEN);
862   underlineDisabledMapGet.Insert("height", 2);
863   underlineDisabledMapGet.Insert("type", Text::Underline::DOUBLE);
864   underlineDisabledMapGet.Insert("dashWidth", 2);
865   underlineDisabledMapGet.Insert("dashGap", 1);
866
867   label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
868
869   application.SendNotification();
870   application.Render();
871
872   underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
873   DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
874   DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
875
876   // Check the shadow property
877
878   Property::Map shadowMapSet;
879   Property::Map shadowMapGet;
880
881   shadowMapSet.Insert("color", Color::GREEN);
882   shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
883   shadowMapSet.Insert("blurRadius", 5.0f);
884
885   label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
886
887   shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
888   DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
889   DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
890
891   shadowMapSet.Clear();
892
893   shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
894   shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0");
895   shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
896
897   label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
898
899   // Replace the offset (string) by a vector2
900   shadowMapSet.Clear();
901   shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
902   shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, Vector2(3.0, 3.0));
903   shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
904
905   shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
906   DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
907   std::vector<std::string> shadowIndicesConversionTable = {"color", "offset", "blurRadius"};
908   DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet, shadowIndicesConversionTable), true, TEST_LOCATION);
909
910   shadowMapSet.Clear();
911   Property::Map shadowDisabledMapGet;
912   shadowDisabledMapGet.Insert("color", Color::BLUE);
913   shadowDisabledMapGet.Insert("offset", Vector2(0.0f, 0.0f));
914   shadowDisabledMapGet.Insert("blurRadius", 3.0f);
915
916   label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
917
918   shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
919   DALI_TEST_EQUALS(shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION);
920   DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowDisabledMapGet), true, TEST_LOCATION);
921
922   // Check the emboss property
923   label.SetProperty(TextLabel::Property::EMBOSS, "Emboss properties");
924   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
925
926   // Check the outline property
927
928   // Test string type first
929   // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
930   label.SetProperty(TextLabel::Property::OUTLINE, "Outline properties");
931   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
932
933   // Then test the property map type
934   Property::Map outlineMapSet;
935   Property::Map outlineMapGet;
936
937   outlineMapSet["color"] = Color::RED;
938   outlineMapSet["width"] = 2.0f;
939   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
940
941   outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
942   DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
943   DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
944
945   outlineMapSet.Clear();
946   outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
947   outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
948   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
949
950   outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
951   DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
952   std::vector<std::string> outlineIndicesConversionTable = {"color", "width"};
953   DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
954
955   // Check the background property
956   Property::Map backgroundMapSet;
957   Property::Map backgroundMapGet;
958
959   backgroundMapSet["enable"] = true;
960   backgroundMapSet["color"]  = Color::RED;
961   label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
962
963   backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
964   DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
965   DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
966
967   // Check the transparent background property for coverage
968   backgroundMapSet.Clear();
969   backgroundMapSet["enable"] = true;
970   backgroundMapSet["color"]  = Color::TRANSPARENT;
971   label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
972
973   application.SendNotification();
974   application.Render();
975
976   backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
977   DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
978   DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
979
980   backgroundMapSet.Clear();
981   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
982   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR]  = Color::GREEN;
983   label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
984
985   backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
986   DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
987   std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
988   DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
989
990   // Check the pixel size of font
991   label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
992   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
993
994   // Check the ellipsis property
995   DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
996   label.SetProperty(TextLabel::Property::ELLIPSIS, false);
997   DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
998
999   // Check the layout direction property
1000   label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1001   DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1002
1003   // Check the line size property
1004   DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1005   label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1006   DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1007
1008   application.SendNotification();
1009   application.Render();
1010
1011   END_TEST;
1012 }
1013
1014 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1015 {
1016   ToolkitTestApplication application;
1017   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1018   TextLabel label = TextLabel::New("Test Text");
1019   DALI_TEST_CHECK(label);
1020
1021   // Avoid a crash when core load gl resources.
1022   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1023
1024   application.GetScene().Add(label);
1025
1026   // Turn on all the effects
1027   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1028   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1029
1030   Property::Map underlineMap;
1031   underlineMap.Insert("enable", true);
1032   underlineMap.Insert("color", Color::RED);
1033   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1034
1035   Property::Map shadowMap;
1036   shadowMap.Insert("color", Color::BLUE);
1037   shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1038   label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1039
1040   Property::Map strikethroughMap;
1041   strikethroughMap.Insert("enable", true);
1042   strikethroughMap.Insert("color", Color::GREEN);
1043   strikethroughMap.Insert("height", 2.0f);
1044   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1045
1046   try
1047   {
1048     // Render some text with the shared atlas backend
1049     label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1050     application.SendNotification();
1051     application.Render();
1052   }
1053   catch(...)
1054   {
1055     tet_result(TET_FAIL);
1056   }
1057
1058   try
1059   {
1060     // Render some text with the shared atlas backend
1061     label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1062     application.SendNotification();
1063     application.Render();
1064   }
1065   catch(...)
1066   {
1067     tet_result(TET_FAIL);
1068   }
1069   END_TEST;
1070 }
1071
1072 int UtcDaliToolkitTextLabelLanguagesP(void)
1073 {
1074   ToolkitTestApplication application;
1075   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1076   TextLabel label = TextLabel::New();
1077   DALI_TEST_CHECK(label);
1078
1079   application.GetScene().Add(label);
1080
1081   const std::string scripts(
1082     " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1083     "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1084     "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1085     "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1086     "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1087     "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1088
1089   label.SetProperty(TextLabel::Property::TEXT, scripts);
1090   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1091
1092   application.SendNotification();
1093   application.Render();
1094
1095   END_TEST;
1096 }
1097
1098 int UtcDaliToolkitTextLabelEmojisP(void)
1099 {
1100   ToolkitTestApplication application;
1101   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1102   TextLabel label = TextLabel::New();
1103   DALI_TEST_CHECK(label);
1104
1105   application.GetScene().Add(label);
1106
1107   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1108
1109   char*             pathNamePtr = get_current_dir_name();
1110   const std::string pathName(pathNamePtr);
1111   free(pathNamePtr);
1112
1113   TextAbstraction::FontDescription fontDescription;
1114   fontDescription.path   = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1115   fontDescription.family = "BreezeColorEmoji";
1116   fontDescription.width  = TextAbstraction::FontWidth::NONE;
1117   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1118   fontDescription.slant  = TextAbstraction::FontSlant::NONE;
1119
1120   fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1121
1122   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>";
1123   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1124   label.SetProperty(TextLabel::Property::TEXT, emojis);
1125
1126   Property::Map shadowMap;
1127   shadowMap.Insert("color", "green");
1128   shadowMap.Insert("offset", "2 2");
1129   label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1130
1131   application.SendNotification();
1132   application.Render();
1133
1134   // EMOJI + ZWJ + EMOJI case for coverage.
1135   const std::string emojiWithZWJ = "&#x1f469;&#x200d;&#x1f52c;";
1136   label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1137
1138   application.SendNotification();
1139   application.Render();
1140
1141   // EMOJI Sequences case for coverage.
1142   std::string emojiSequences =
1143     "Glyphs not included in the font &#xf01a;&#xf01b;&#xf01c;&#xf01d;&#xf01e;&#xf01f;\n"   //case for coverage when glyph is not included in the font
1144     "Text VS15 &#x262a;&#xfe0e;\n"                                                         //text presentation sequence and selector
1145     "Color VS16 &#x262a;&#xfe0f;\n"                                                        //emoji presentation sequence and selector
1146     "Default &#x262a; \n"                                                                  //default presentation
1147     "FamilyManWomanGirlBoy &#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;\n" // emoji multi zwj sequence
1148     "WomanScientist &#x1f469;&#x200d;&#x1f52c;\n"                                          // emoji zwj sequence
1149     "WomanScientistLightSkinTone&#x1F469;&#x1F3FB;&#x200D;&#x1F52C; \n"                    // emoji modifier sequence: skin tone & JWZ
1150     "LeftRightArrowText&#x2194;&#xfe0e;\n"                                                 // text presentation sequence and selector
1151     "LeftRightArrowEmoji&#x2194;&#xfe0f;\n"                                                // emoji presentation sequence and selector
1152     "SouthKoreaFlag&#x1f1f0;&#x1f1f7;\n"                                                   // emoji flag sequence
1153     "JordanFlag&#x1f1ef;&#x1f1f4;\n"                                                       // emoji flag sequence
1154     "EnglandFlag&#x1F3F4;&#xE0067;&#xE0062;&#xE0065;&#xE006E;&#xE0067;&#xE007F;\n"         // emoji tag sequence like England flag
1155     "Runner &#x1f3c3;&#x200d;&#x27a1;&#xfe0f; \n"
1156     "VictoryHandMediumLightSkinTone:&#x270C;&#xFE0F;&#x1F3FC;\n"                                                                // emoji modifier sequence: skin tone
1157     "RainbowFlag:&#x1F3F3;&#xFE0F;&#x200D;&#x1F308; \n"                                                                         // emoji zwj sequence: Rainbow Flag
1158     "keycap# &#x0023;&#xFE0F;&#x20E3; \n"                                                                                       // fully-qualified  emoji keycap sequence
1159     "keycap#_text &#x0023;&#x20E3; \n"                                                                                          // unqualified emoji keycap sequence
1160     "keycap3 &#x0033;&#xfe0f;&#x20e3; \n"                                                                                       // fully-qualified  emoji keycap sequence
1161     "keycap3_text &#x0033;&#x20e3; \n"                                                                                          // unqualified emoji keycap sequence
1162     "two adjacent glyphs &#x262a;&#xfe0f;&#xfe0f;&#xfe0f;&#x262a;&#xfe0f;\n"                                                    // This line should be rendered as two adjacent glyphs
1163     "Digit 8&#xfe0f; 8&#xfe0e; 8\n"                                                                                             // should be rendered according to selector
1164     "Surfing Medium Skin Female:  &#x1f3c4;&#x1f3fc;&#x200d;&#x2640;&#xfe0f;\n"                                                 // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1165     "SYMBOLS_NSLCL variation selector: &#x1f170;&#xfe0f;&#x1f171;&#xfe0f;&#x1f172;&#xfe0e;&#x1f173;&#xfe0e;&#x1f174;&#xfe0e;\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1166     "SYMBOLS_NSLCL with VS15: &#x1f170;&#xfe0e;&#x1f171;&#xfe0e;&#x1f172;&#xfe0e;&#x1f173;&#xfe0e;&#x1f174;&#xfe0e;\n"          // 1F170 ~ 1F174 with VS15
1167     "SYMBOLS_NSLCL with VS16: &#x1f170;&#xfe0f;&#x1f171;&#xfe0f;&#x1f172;&#xfe0f;&#x1f173;&#xfe0f;&#x1f174;&#xfe0f;\n"          // 1F170 ~ 1F174 with VS16
1168
1169     ;
1170
1171   label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1172   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1173   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1174   label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1175
1176   application.SendNotification();
1177   application.Render();
1178   END_TEST;
1179 }
1180
1181 int UtcDaliToolkitTextlabelScrollingP(void)
1182 {
1183   ToolkitTestApplication application;
1184   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1185   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1186   TextLabel labelFinished  = TextLabel::New("مرحبا بالعالم");
1187
1188   DALI_TEST_CHECK(labelImmediate);
1189   DALI_TEST_CHECK(labelFinished);
1190   // Avoid a crash when core load gl resources.
1191   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1192   application.GetScene().Add(labelImmediate);
1193   // Turn on all the effects
1194   labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1195   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1196   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1197   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1198   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1199
1200   application.GetScene().Add(labelFinished);
1201   // Turn on all the effects
1202   labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1203   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1204   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1205   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1206   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1207
1208   try
1209   {
1210     // Render some text with the shared atlas backend
1211     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1212     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1213
1214     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1215     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1216
1217     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1218     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1219     application.SendNotification();
1220     application.Render();
1221
1222     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1223     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1224     application.SendNotification();
1225     application.Render();
1226   }
1227   catch(...)
1228   {
1229     tet_result(TET_FAIL);
1230   }
1231
1232   END_TEST;
1233 }
1234
1235 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1236 {
1237   ToolkitTestApplication application;
1238   TextLabel              labelShort = TextLabel::New("Some text to scroll");
1239   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!");
1240
1241   DALI_TEST_CHECK(labelShort);
1242   DALI_TEST_CHECK(labelLong);
1243   // Avoid a crash when core load gl resources.
1244   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1245   application.GetScene().Add(labelShort);
1246   // Turn on all the effects
1247   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1248   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1249   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1250   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1251   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1252   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1253
1254   application.GetScene().Add(labelLong);
1255   // Turn on all the effects
1256   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1257   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1258   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1259   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1260   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1261   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1262
1263   try
1264   {
1265     // Render some text with the shared atlas backend
1266     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1267     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1268     application.SendNotification();
1269     application.Render();
1270
1271     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1272     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1273     application.SendNotification();
1274     application.Render();
1275   }
1276   catch(...)
1277   {
1278     tet_result(TET_FAIL);
1279   }
1280
1281   END_TEST;
1282 }
1283
1284 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1285 {
1286   ToolkitTestApplication application;
1287   TextLabel              labelShort = TextLabel::New("مرحبا بالعالم");
1288   TextLabel              labelLong  = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1289
1290   DALI_TEST_CHECK(labelShort);
1291   DALI_TEST_CHECK(labelLong);
1292   // Avoid a crash when core load gl resources.
1293   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1294   application.GetScene().Add(labelShort);
1295   // Turn on all the effects
1296   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1297   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1298   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1299   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1300   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1301   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1302
1303   application.GetScene().Add(labelLong);
1304   // Turn on all the effects
1305   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1306   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1307   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1308   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1309   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1310   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1311
1312   try
1313   {
1314     // Render some text with the shared atlas backend
1315     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1316     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1317     application.SendNotification();
1318     application.Render();
1319
1320     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1321     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1322     application.SendNotification();
1323     application.Render();
1324   }
1325   catch(...)
1326   {
1327     tet_result(TET_FAIL);
1328   }
1329
1330   END_TEST;
1331 }
1332
1333 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1334 {
1335   ToolkitTestApplication application;
1336   TextLabel              labelShort = TextLabel::New("Some text to scroll");
1337   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!");
1338
1339   DALI_TEST_CHECK(labelShort);
1340   DALI_TEST_CHECK(labelLong);
1341   // Avoid a crash when core load gl resources.
1342   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1343   application.GetScene().Add(labelShort);
1344   // Turn on all the effects
1345   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1346   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1347   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1348   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1349   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1350   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1351
1352   application.GetScene().Add(labelLong);
1353   // Turn on all the effects
1354   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1355   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1356   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1357   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1358   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1359   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1360
1361   try
1362   {
1363     // Render some text with the shared atlas backend
1364     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1365     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1366     application.SendNotification();
1367     application.Render();
1368
1369     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1370     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1371     application.SendNotification();
1372     application.Render();
1373   }
1374   catch(...)
1375   {
1376     tet_result(TET_FAIL);
1377   }
1378
1379   END_TEST;
1380 }
1381
1382 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1383 {
1384   ToolkitTestApplication application;
1385   TextLabel              labelShort = TextLabel::New("مرحبا بالعالم");
1386   TextLabel              labelLong  = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1387
1388   DALI_TEST_CHECK(labelShort);
1389   DALI_TEST_CHECK(labelLong);
1390   // Avoid a crash when core load gl resources.
1391   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1392   application.GetScene().Add(labelShort);
1393   // Turn on all the effects
1394   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1395   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1396   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1397   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1398   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1399   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1400
1401   application.GetScene().Add(labelLong);
1402   // Turn on all the effects
1403   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1404   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1405   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1406   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1407   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1408   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1409
1410   try
1411   {
1412     // Render some text with the shared atlas backend
1413     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1414     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1415     application.SendNotification();
1416     application.Render();
1417
1418     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1419     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1420     application.SendNotification();
1421     application.Render();
1422   }
1423   catch(...)
1424   {
1425     tet_result(TET_FAIL);
1426   }
1427
1428   END_TEST;
1429 }
1430
1431 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1432 {
1433   ToolkitTestApplication application;
1434   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1435   TextLabel label = TextLabel::New("Some text to scroll");
1436   DALI_TEST_CHECK(label);
1437   // Avoid a crash when core load gl resources.
1438   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1439   application.GetScene().Add(label);
1440   label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1441   // Turn on all the effects
1442   label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1443   label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1444   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1445   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1446
1447   // Render the text.
1448   application.SendNotification();
1449   application.Render();
1450
1451   unsigned int actorCount1 = label.GetChildCount();
1452   tet_printf("Initial actor count is(%d)\n", actorCount1);
1453
1454   try
1455   {
1456     // Render some text with the shared atlas backend
1457     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1458     application.SendNotification();
1459     application.Render(2000);
1460
1461     unsigned int actorCount1 = label.GetChildCount();
1462     tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1463
1464     label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1465
1466     // Render the text.
1467     application.SendNotification();
1468     application.Render();
1469
1470     unsigned int actorCount2 = label.GetChildCount();
1471     tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1472
1473     DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1474   }
1475   catch(...)
1476   {
1477     tet_result(TET_FAIL);
1478   }
1479
1480   END_TEST;
1481 }
1482
1483 int UtcDaliToolkitTextlabelScrollingN(void)
1484 {
1485   ToolkitTestApplication application;
1486   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1487
1488   TextLabel label = TextLabel::New("Some text to scroll");
1489   DALI_TEST_CHECK(label);
1490
1491   application.GetScene().Add(label);
1492
1493   // Avoid a crash when core load gl resources.
1494   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1495
1496   // The text scrolling works only on single line text.
1497   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1498
1499   // Turn on all the effects.
1500   label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1501   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1502   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1503
1504   // Enable the auto scrolling effect.
1505   label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1506
1507   // The auto scrolling shouldn't be enabled.
1508   const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1509   DALI_TEST_CHECK(!enabled);
1510
1511   label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1512   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
1513   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
1514   label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1515
1516   try
1517   {
1518     // Render the text.
1519     application.SendNotification();
1520     application.Render(1000);
1521
1522     application.GetScene().Remove(label);
1523     application.SendNotification();
1524     application.Render();
1525
1526     DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1527
1528     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1529     application.GetScene().Add(label);
1530
1531     application.SendNotification();
1532     application.Render();
1533
1534     DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1535
1536     label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
1537     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1538
1539     application.SendNotification();
1540     application.Render();
1541
1542     DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1543   }
1544   catch(...)
1545   {
1546     tet_result(TET_FAIL);
1547   }
1548
1549   END_TEST;
1550 }
1551
1552 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1553 {
1554   ToolkitTestApplication application;
1555   tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1556
1557   TextLabel label = TextLabel::New("Some text to scroll");
1558   DALI_TEST_CHECK(label);
1559
1560   application.GetScene().Add(label);
1561
1562   // Avoid a crash when core load gl resources.
1563   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1564
1565   // Turn on all the effects.
1566   label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1567   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1568   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1569
1570   try
1571   {
1572     // Enable the auto scrolling effect.
1573     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1574     label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1575
1576     // Disable the ellipsis
1577     label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1578
1579     // Render the text.
1580     application.SendNotification();
1581     application.Render();
1582
1583     // Stop auto scrolling
1584     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1585
1586     // Check the ellipsis property
1587     DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1588   }
1589   catch(...)
1590   {
1591     tet_result(TET_FAIL);
1592   }
1593
1594   END_TEST;
1595 }
1596
1597 int UtcDaliToolkitTextlabelEllipsis(void)
1598 {
1599   ToolkitTestApplication application;
1600   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1601
1602   TextLabel label = TextLabel::New("Hello world");
1603   DALI_TEST_CHECK(label);
1604
1605   // Avoid a crash when core load gl resources.
1606   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1607
1608   application.GetScene().Add(label);
1609
1610   // Turn on all the effects
1611   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1612   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1613   label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1614
1615   try
1616   {
1617     // Render the text.
1618     application.SendNotification();
1619     application.Render();
1620   }
1621   catch(...)
1622   {
1623     tet_result(TET_FAIL);
1624   }
1625
1626   label.SetProperty(TextLabel::Property::TEXT, "Hello world                                        ");
1627   label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1628   label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1629
1630   try
1631   {
1632     // Render the text.
1633     application.SendNotification();
1634     application.Render();
1635   }
1636   catch(...)
1637   {
1638     tet_result(TET_FAIL);
1639   }
1640
1641   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1642   label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1643   label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1644
1645   try
1646   {
1647     // Render the text.
1648     application.SendNotification();
1649     application.Render();
1650   }
1651   catch(...)
1652   {
1653     tet_result(TET_FAIL);
1654   }
1655
1656   END_TEST;
1657 }
1658
1659 int UtcDaliToolkitTextlabelTextWrapMode(void)
1660 {
1661   ToolkitTestApplication application;
1662   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1663
1664   int lineCount = 0;
1665
1666   TextLabel label = TextLabel::New();
1667   label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1668   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1669   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1670
1671   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1672   application.GetScene().Add(label);
1673
1674   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1675   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1676
1677   application.SendNotification();
1678   application.Render();
1679
1680   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1681   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1682
1683   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1684   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1685
1686   application.SendNotification();
1687   application.Render();
1688
1689   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1690   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1691
1692   application.SendNotification();
1693   application.Render();
1694
1695   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1696   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1697
1698   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1699   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1700
1701   application.SendNotification();
1702   application.Render();
1703
1704   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1705   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1706
1707   tet_infoline("Ensure invalid string does not change wrapping mode");
1708   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1709   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1710
1711   END_TEST;
1712 }
1713
1714 int UtcDaliToolkitTextLabelColorComponents(void)
1715 {
1716   ToolkitTestApplication application;
1717
1718   TextLabel label = TextLabel::New();
1719   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1720   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1721   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1722   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1723   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1724
1725   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1726   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1727   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1728   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1729   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1730
1731   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1732   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1733   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1734   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1735   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1736
1737   label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1738   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1739   DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1740
1741   // Test a transparent text - Rendering should be skipped.
1742   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1743   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1744
1745   application.GetScene().Add(label);
1746
1747   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1748   drawTrace.Enable(true);
1749
1750   application.SendNotification();
1751   application.Render();
1752
1753   DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1754
1755   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1756
1757   drawTrace.Reset();
1758
1759   application.SendNotification();
1760   application.Render();
1761
1762   DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1763
1764   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1765
1766   drawTrace.Reset();
1767
1768   application.SendNotification();
1769   application.Render();
1770
1771   DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1772
1773   END_TEST;
1774 }
1775
1776 int UtcDaliToolkitTextlabelTextStyle01(void)
1777 {
1778   ToolkitTestApplication application;
1779   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1780
1781   TextLabel label = TextLabel::New();
1782   label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1783   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1784   label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1785   application.GetScene().Add(label);
1786
1787   Property::Map outlineMapSet;
1788   Property::Map outlineMapGet;
1789
1790   outlineMapSet["color"] = Color::BLUE;
1791   outlineMapSet["width"] = 2.0f;
1792   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1793
1794   application.SendNotification();
1795   application.Render();
1796
1797   Property::Map shadowMapSet;
1798   shadowMapSet.Insert("color", "green");
1799   shadowMapSet.Insert("offset", "2 2");
1800   shadowMapSet.Insert("blurRadius", "3");
1801   label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1802
1803   outlineMapSet["color"] = Color::RED;
1804   outlineMapSet["width"] = 0.0f;
1805   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1806
1807   application.SendNotification();
1808   application.Render();
1809
1810   outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1811
1812   Property::Value* colorValue = outlineMapGet.Find("color");
1813
1814   bool colorMatched(false);
1815
1816   if(colorValue)
1817   {
1818     Property::Type valueType = colorValue->GetType();
1819
1820     if(Property::STRING == valueType)
1821     {
1822       std::string stringValue;
1823       colorValue->Get(stringValue);
1824       if(stringValue == "red")
1825       {
1826         colorMatched = true;
1827       }
1828     }
1829     else if(Property::VECTOR4 == valueType)
1830     {
1831       Vector4 colorVector4;
1832       colorValue->Get(colorVector4);
1833       if(colorVector4 == Color::RED)
1834       {
1835         colorMatched = true;
1836       }
1837     }
1838   }
1839
1840   DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1841
1842   END_TEST;
1843 }
1844
1845 int UtcDaliToolkitTextlabelMultiline(void)
1846 {
1847   ToolkitTestApplication application;
1848   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1849
1850   TextLabel label = TextLabel::New();
1851   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1852   label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1853   label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1854   application.GetScene().Add(label);
1855
1856   application.SendNotification();
1857   application.Render();
1858
1859   int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1860   DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1861
1862   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1863
1864   application.SendNotification();
1865   application.Render();
1866
1867   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1868   DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1869
1870   END_TEST;
1871 }
1872
1873 int UtcDaliToolkitTextlabelTextDirection(void)
1874 {
1875   ToolkitTestApplication application;
1876   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1877
1878   TextLabel label = TextLabel::New();
1879   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1880
1881   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1882   label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1883   label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1884   application.GetScene().Add(label);
1885
1886   // Test LTR text
1887   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1888
1889   // Test RTL text
1890   label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1891   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1892
1893   // Test RTL text starting with weak character
1894   label.SetProperty(TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1895   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1896
1897   // Test RTL text string with emoji and weak character
1898   label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1899   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1900
1901   END_TEST;
1902 }
1903
1904 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1905 {
1906   ToolkitTestApplication application;
1907   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1908
1909   TextLabel label = TextLabel::New();
1910
1911   label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1912   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1913   label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1914   label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1915   application.GetScene().Add(label);
1916   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1917
1918   label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1919   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1920
1921   label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1922   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1923
1924   END_TEST;
1925 }
1926
1927 int UtcDaliToolkitTextLabelBitmapFont(void)
1928 {
1929   ToolkitTestApplication application;
1930   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1931
1932   DevelText::BitmapFontDescription fontDescription;
1933   fontDescription.name               = "Digits";
1934   fontDescription.underlinePosition  = 0.f;
1935   fontDescription.underlineThickness = 0.f;
1936
1937   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1938   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1939   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1940   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1941   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1942   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1943   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1944   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
1945   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
1946   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
1947   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
1948
1949   TextAbstraction::BitmapFont bitmapFont;
1950   DevelText::CreateBitmapFont(fontDescription, bitmapFont);
1951
1952   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1953   fontClient.GetFontId(bitmapFont);
1954
1955   TextLabel label = TextLabel::New();
1956
1957   label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
1958   label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
1959
1960   // 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.
1961   DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1962
1963   application.GetScene().Add(label);
1964
1965   application.SendNotification();
1966   application.Render();
1967
1968   // The text has been rendered if the height of the text-label is the height of the line.
1969   DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1970
1971   END_TEST;
1972 }
1973
1974 int ConvertPointToPixel(float point)
1975 {
1976   unsigned int                horizontalDpi = 0u;
1977   unsigned int                verticalDpi   = 0u;
1978   TextAbstraction::FontClient fontClient    = TextAbstraction::FontClient::Get();
1979   fontClient.GetDpi(horizontalDpi, verticalDpi);
1980
1981   return (point * 72.f) / static_cast<float>(horizontalDpi);
1982 }
1983
1984 int UtcDaliToolkitTextlabelTextFit(void)
1985 {
1986   ToolkitTestApplication application;
1987   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1988   TextLabel label = TextLabel::New();
1989   Vector2   size(460.0f, 100.0f);
1990   label.SetProperty(Actor::Property::SIZE, size);
1991   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1992
1993   // connect to the text git changed signal.
1994   ConnectionTracker* testTracker = new ConnectionTracker();
1995   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
1996   bool textFitChangedSignal = false;
1997   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
1998   gTextFitChangedCallBackCalled = false;
1999
2000   // check point size
2001   Property::Map textFitMapSet;
2002   textFitMapSet["enable"]       = true;
2003   textFitMapSet["minSize"]      = 10.f;
2004   textFitMapSet["maxSize"]      = 100.f;
2005   textFitMapSet["stepSize"]     = -1.f;
2006   textFitMapSet["fontSizeType"] = "pointSize";
2007
2008   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2009   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2010
2011   application.GetScene().Add(label);
2012
2013   application.SendNotification();
2014   application.Render();
2015
2016   const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2017   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2018
2019   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2020   DALI_TEST_CHECK(textFitChangedSignal);
2021
2022   // check pixel size
2023   textFitMapSet.Clear();
2024   textFitMapSet["enable"]       = true;
2025   textFitMapSet["minSize"]      = ConvertPointToPixel(10.f);
2026   textFitMapSet["maxSize"]      = ConvertPointToPixel(100.f);
2027   textFitMapSet["stepSize"]     = ConvertPointToPixel(1.f);
2028   textFitMapSet["fontSizeType"] = "pixelSize";
2029
2030   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2031
2032   application.SendNotification();
2033   application.Render();
2034
2035   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2036
2037   END_TEST;
2038 }
2039
2040 int UtcDaliToolkitTextlabelTextFitStressTest(void)
2041 {
2042   ToolkitTestApplication application;
2043   tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
2044   TextLabel label = TextLabel::New();
2045   Vector2   size(460.0f, 100.0f);
2046   label.SetProperty(Actor::Property::SIZE, size);
2047   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2048
2049   // connect to the text git changed signal.
2050   ConnectionTracker* testTracker = new ConnectionTracker();
2051   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2052   bool textFitChangedSignal = false;
2053   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2054   gTextFitChangedCallBackCalled = false;
2055
2056   // check point size with veryvery big range
2057   Property::Map textFitMapSet;
2058   textFitMapSet["enable"]       = true;
2059   textFitMapSet["minSize"]      = 10.f;
2060   textFitMapSet["maxSize"]      = 10000.f;
2061   textFitMapSet["stepSize"]     = -1.0f;
2062   textFitMapSet["fontSizeType"] = "pointSize";
2063
2064   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2065   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2066
2067   application.GetScene().Add(label);
2068
2069   application.SendNotification();
2070   application.Render();
2071
2072   const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2073   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2074
2075   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2076   DALI_TEST_CHECK(textFitChangedSignal);
2077
2078   END_TEST;
2079 }
2080
2081 int UtcDaliToolkitTextlabelTextFitArray(void)
2082 {
2083   ToolkitTestApplication application;
2084   tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2085   TextLabel label = TextLabel::New();
2086   Vector2   size(300.0f, 80.0f);
2087   label.SetProperty(Actor::Property::SIZE, size);
2088   label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2089   label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2090   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2091   application.GetScene().Add(label);
2092
2093   // make sorted options.
2094   std::vector<DevelTextLabel::FitOption> fitOptions;
2095   fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2096   fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2097   fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2098   fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2099   fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2100   fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2101   fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2102
2103   DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2104
2105   application.SendNotification();
2106   application.Render();
2107
2108   bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2109   DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2110
2111   std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2112   size_t numberOfFitOptions = getFitOptions.size();
2113   DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2114
2115   const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2116   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2117
2118   std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2119   DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2120
2121   application.SendNotification();
2122   application.Render();
2123
2124   enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2125   DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2126
2127   const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2128   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2129
2130   // make unsorted options.
2131   std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2132   unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2133   unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2134   unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2135   unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2136
2137   DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2138
2139   application.SendNotification();
2140   application.Render();
2141
2142   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2143
2144   END_TEST;
2145 }
2146
2147 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2148 {
2149   ToolkitTestApplication application;
2150   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2151
2152   DevelText::BitmapFontDescription fontDescription;
2153   fontDescription.name = "Digits";
2154   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2155
2156   TextAbstraction::BitmapFont bitmapFont;
2157   DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2158
2159   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2160   fontClient.GetFontId(bitmapFont);
2161
2162   TextLabel label = TextLabel::New();
2163   label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2164   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2165   label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2166   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2167   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2168
2169   Property::Map underlineMapSet;
2170   underlineMapSet.Clear();
2171   underlineMapSet.Insert("enable", true);
2172   underlineMapSet.Insert("color", Color::RED);
2173   underlineMapSet.Insert("height", 1);
2174   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2175   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2176
2177   Property::Map strikethroughMapSet;
2178   strikethroughMapSet.Clear();
2179   strikethroughMapSet.Insert("enable", true);
2180   strikethroughMapSet.Insert("color", Color::RED);
2181   strikethroughMapSet.Insert("height", 2.0f);
2182   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2183   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2184
2185   application.GetScene().Add(label);
2186
2187   application.SendNotification();
2188   application.Render();
2189
2190   const int maxTextureSize = Dali::GetMaxTextureSize();
2191   // Whether the rendered text is greater than maxTextureSize
2192   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2193
2194   // Check if the number of renderers is greater than 1.
2195   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2196
2197   //DASHED
2198   underlineMapSet.Clear();
2199   underlineMapSet.Insert("enable", false);
2200   underlineMapSet.Insert("color", Color::BLUE);
2201   underlineMapSet.Insert("height", 0);
2202   underlineMapSet.Insert("type", Text::Underline::DASHED);
2203   underlineMapSet.Insert("dashWidth", 2);
2204   underlineMapSet.Insert("dashGap", 1);
2205   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2206   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2207
2208   application.GetScene().Add(label);
2209
2210   application.SendNotification();
2211   application.Render();
2212
2213   // Whether the rendered text is greater than maxTextureSize
2214   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2215
2216   // Check if the number of renderers is greater than 1.
2217   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2218
2219   //DOUBLE
2220   underlineMapSet.Clear();
2221   underlineMapSet.Insert("enable", false);
2222   underlineMapSet.Insert("color", Color::BLUE);
2223   underlineMapSet.Insert("height", 0);
2224   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2225   underlineMapSet.Insert("dashWidth", 2);
2226   underlineMapSet.Insert("dashGap", 1);
2227   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2228   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2229
2230   application.GetScene().Add(label);
2231
2232   application.SendNotification();
2233   application.Render();
2234
2235   // Whether the rendered text is greater than maxTextureSize
2236   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2237
2238   // Check if the number of renderers is greater than 1.
2239   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2240
2241   // Coverage test for case of layoutSize is bigger than maxTextureSize
2242   float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2243   label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2244   application.SendNotification();
2245   application.Render();
2246
2247   END_TEST;
2248 }
2249
2250 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2251 {
2252   ToolkitTestApplication application;
2253   tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2254
2255   TextLabel label = TextLabel::New();
2256   label.SetProperty(TextLabel::Property::TEXT, "Test");
2257   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2258   //Exeeding BufferWidth
2259   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2260   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2261   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2262
2263   application.GetScene().Add(label);
2264   application.SendNotification();
2265   application.Render();
2266
2267   Property::Map strikethroughMapSet;
2268   strikethroughMapSet.Clear();
2269   strikethroughMapSet.Insert("enable", true);
2270   strikethroughMapSet.Insert("color", Color::BLUE);
2271   strikethroughMapSet.Insert("height", 2.0f);
2272   label.SetProperty(TextLabel::Property::TEXT, "Test1");
2273   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2274   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2275   application.GetScene().Add(label);
2276   application.SendNotification();
2277   application.Render();
2278   // Check if the number of renderers is 1.
2279   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2280
2281   label = TextLabel::New();
2282   label.SetProperty(TextLabel::Property::TEXT, "Test");
2283   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2284
2285   //Exeeding BufferHeight
2286   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2287   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2288   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2289
2290   application.GetScene().Add(label);
2291   application.SendNotification();
2292   application.Render();
2293
2294   strikethroughMapSet.Clear();
2295   strikethroughMapSet.Insert("enable", true);
2296   strikethroughMapSet.Insert("color", Color::BLUE);
2297   strikethroughMapSet.Insert("height", 2.0f);
2298   label.SetProperty(TextLabel::Property::TEXT, "Test2");
2299   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2300   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2301   application.GetScene().Add(label);
2302   application.SendNotification();
2303   application.Render();
2304   // Check if the number of renderers is 1.
2305   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2306
2307   END_TEST;
2308 }
2309
2310 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2311 {
2312   ToolkitTestApplication application;
2313   tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2314
2315   TextLabel label = TextLabel::New();
2316   label.SetProperty(TextLabel::Property::TEXT, "Test");
2317   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2318   //Exeeding BufferWidth
2319   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2320   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2321   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2322
2323   application.GetScene().Add(label);
2324   application.SendNotification();
2325   application.Render();
2326
2327   Property::Map underlineMapSet;
2328
2329   //SOLID
2330   underlineMapSet.Clear();
2331   underlineMapSet.Insert("enable", true);
2332   underlineMapSet.Insert("color", Color::BLUE);
2333   underlineMapSet.Insert("height", 1);
2334   underlineMapSet.Insert("type", Text::Underline::SOLID);
2335   underlineMapSet.Insert("dashWidth", 2);
2336   underlineMapSet.Insert("dashGap", 1);
2337   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2338   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2339
2340   application.GetScene().Add(label);
2341
2342   application.SendNotification();
2343   application.Render();
2344
2345   // Check if the number of renderers is 1.
2346   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2347
2348   //DASHED
2349   underlineMapSet.Clear();
2350   underlineMapSet.Insert("enable", true);
2351   underlineMapSet.Insert("color", Color::BLUE);
2352   underlineMapSet.Insert("height", 1);
2353   underlineMapSet.Insert("type", Text::Underline::DASHED);
2354   underlineMapSet.Insert("dashWidth", 2);
2355   underlineMapSet.Insert("dashGap", 1);
2356   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2357   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2358
2359   application.GetScene().Add(label);
2360
2361   application.SendNotification();
2362   application.Render();
2363
2364   // Check if the number of renderers is 1.
2365   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2366
2367   //DOUBLE
2368   underlineMapSet.Clear();
2369   underlineMapSet.Insert("enable", true);
2370   underlineMapSet.Insert("color", Color::BLUE);
2371   underlineMapSet.Insert("height", 1);
2372   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2373   underlineMapSet.Insert("dashWidth", 2);
2374   underlineMapSet.Insert("dashGap", 1);
2375   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2376   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2377
2378   application.GetScene().Add(label);
2379
2380   application.SendNotification();
2381   application.Render();
2382
2383   // Check if the number of renderers is 1.
2384   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2385
2386   END_TEST;
2387 }
2388
2389 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2390 {
2391   ToolkitTestApplication application;
2392   tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2393
2394   Vector2 size(300.0f, 100.0f);
2395
2396   Dali::Toolkit::DevelText::RendererParameters textParameters;
2397   textParameters.text              = "This is a sample text to get the last index.";
2398   textParameters.layout            = "multiLine";
2399   textParameters.fontSize          = 20.f;
2400   textParameters.textWidth         = 300u;
2401   textParameters.textHeight        = 100u;
2402   textParameters.ellipsisEnabled   = true;
2403   Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2404
2405   DALI_TEST_CHECK(!indexArray.Empty());
2406   DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2407
2408   END_TEST;
2409 }
2410
2411 int UtcDaliToolkitTextlabelFontSizeScale(void)
2412 {
2413   ToolkitTestApplication application;
2414   tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2415
2416   TextLabel label = TextLabel::New();
2417   label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2418   label.SetProperty(TextLabel::Property::TEXT, "Test");
2419   Vector3 nonScaledSize = label.GetNaturalSize();
2420
2421   TextLabel labelScaled = TextLabel::New();
2422   labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2423   labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2424   labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2425   Vector3 scaledSize = labelScaled.GetNaturalSize();
2426
2427   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2428
2429   label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2430   label.SetProperty(TextLabel::Property::TEXT, "Test");
2431   nonScaledSize = label.GetNaturalSize();
2432
2433   labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2434   labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2435   labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2436   scaledSize = labelScaled.GetNaturalSize();
2437
2438   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2439
2440   END_TEST;
2441 }
2442
2443 // Positive test for the anchorClicked signal.
2444 int UtcDaliToolkitTextlabelAnchorClicked(void)
2445 {
2446   ToolkitTestApplication application;
2447   tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2448   TextLabel label = TextLabel::New();
2449   DALI_TEST_CHECK(label);
2450
2451   application.GetScene().Add(label);
2452
2453   // connect to the anchor clicked signal.
2454   ConnectionTracker* testTracker = new ConnectionTracker();
2455   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2456   bool anchorClickedSignal = false;
2457   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2458
2459   gAnchorClickedCallBackCalled = false;
2460   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2461   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2462   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2463   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2464   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2465
2466   application.SendNotification();
2467   application.Render();
2468
2469   // Create a tap event to touch the text label.
2470   TestGenerateTap(application, 5.0f, 25.0f, 100);
2471   application.SendNotification();
2472   application.Render();
2473
2474   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2475   DALI_TEST_CHECK(anchorClickedSignal);
2476
2477   // reset
2478   gAnchorClickedCallBackCalled = false;
2479   anchorClickedSignal          = false;
2480   label.SetProperty(TextLabel::Property::TEXT, "");
2481   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2482
2483   application.SendNotification();
2484   application.Render();
2485
2486   // sets anchor text
2487   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2488   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2489   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2490   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2491   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2492
2493   application.SendNotification();
2494   application.Render();
2495
2496   // Create a tap event to touch the text label.
2497   TestGenerateTap(application, 5.0f, 25.0f, 200);
2498   application.SendNotification();
2499   application.Render();
2500
2501   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2502   DALI_TEST_CHECK(anchorClickedSignal);
2503
2504   gAnchorClickedCallBackNotCalled = true;
2505   // Tap the outside of anchor, callback should not be called.
2506   TestGenerateTap(application, 150.f, 100.f, 300);
2507   application.SendNotification();
2508   application.Render();
2509
2510   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2511
2512   END_TEST;
2513 }
2514
2515 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2516 {
2517   ToolkitTestApplication application;
2518   tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2519
2520   //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2521
2522   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2523   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2524   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2525
2526   // Create a text editor
2527   TextLabel textLabel = TextLabel::New();
2528   //Set size to avoid automatic eliding
2529   textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2530   //Set very large font-size using point-size
2531   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2532   //Specify font-family
2533   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2534   //Set text to check if appear or not
2535   textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2536
2537   application.GetScene().Add(textLabel);
2538
2539   application.SendNotification();
2540   application.Render();
2541   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2542   Vector3 naturalSize = textLabel.GetNaturalSize();
2543
2544   DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2545   DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2546
2547   END_TEST;
2548 }
2549
2550 int UtcDaliTextLabelHyphenWrapMode(void)
2551 {
2552   ToolkitTestApplication application;
2553   tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2554
2555   int       lineCount = 0;
2556   TextLabel label     = TextLabel::New();
2557   label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2558   label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2559   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2560   application.GetScene().Add(label);
2561   application.SendNotification();
2562   application.Render();
2563
2564   label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2565   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2566   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2567
2568   application.SendNotification();
2569   application.Render();
2570
2571   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2572   /*
2573     text will be :
2574     Hi Exp-
2575     erimen
2576   */
2577   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2578
2579   label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2580   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2581   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2582
2583   application.SendNotification();
2584   application.Render();
2585
2586   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2587   /*
2588     text will be :
2589     Hi
2590     Experi-
2591     men
2592   */
2593   DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2594
2595   END_TEST;
2596 }
2597
2598 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2599 {
2600   ToolkitTestApplication application;
2601
2602   tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2603
2604   int lineCountBefore = 0;
2605   int lineCountAfter  = 0;
2606
2607   // Create a text editor
2608   TextLabel textLabel = TextLabel::New();
2609   //Set very large font-size using point-size
2610   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2611   //Specify font-family
2612   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2613   //Specify size
2614   textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2615   //Set text longer than width of textLabel
2616   textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2617   //Set line wrap mode Character
2618   textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2619   textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2620
2621   application.GetScene().Add(textLabel);
2622
2623   application.SendNotification();
2624   application.Render();
2625
2626   lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2627
2628   textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2629   lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2630
2631   // When the text changed, the Line-count should be updated according to new text.
2632   // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2633   DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2634   DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2635
2636   END_TEST;
2637 }
2638
2639 int utcDaliTextLabelGeometryRTL(void)
2640 {
2641   ToolkitTestApplication application;
2642   tet_infoline(" utcDaliTextLabelGeometryRTL");
2643
2644   TextLabel label = TextLabel::New();
2645   DALI_TEST_CHECK(label);
2646
2647   application.GetScene().Add(label);
2648
2649   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2650   label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2651   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2652   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2653   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2654   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2655   label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2656   // Avoid a crash when core load gl resources.
2657   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2658
2659   // Render and notify
2660   application.SendNotification();
2661   application.Render();
2662
2663   unsigned int expectedCount = 4;
2664   unsigned int startIndex    = 3;
2665   unsigned int endIndex      = 24;
2666
2667   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2668   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2669
2670   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2671   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2672
2673   Vector<Vector2> expectedSizes;
2674   Vector<Vector2> expectedPositions;
2675
2676   expectedPositions.PushBack(Vector2(25, 0));
2677   expectedSizes.PushBack(Vector2(34, 25));
2678
2679   expectedPositions.PushBack(Vector2(-1, 25));
2680   expectedSizes.PushBack(Vector2(53, 25));
2681
2682   expectedPositions.PushBack(Vector2(-1, 50));
2683   expectedSizes.PushBack(Vector2(60, 25));
2684
2685   expectedPositions.PushBack(Vector2(75, 75));
2686   expectedSizes.PushBack(Vector2(37, 25));
2687
2688   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2689
2690   END_TEST;
2691 }
2692
2693 int utcDaliTextLabelGeometryGlyphMiddle(void)
2694 {
2695   ToolkitTestApplication application;
2696   tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2697
2698   TextLabel label = TextLabel::New();
2699   DALI_TEST_CHECK(label);
2700
2701   application.GetScene().Add(label);
2702
2703   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2704   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2705   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2706   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2707   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2708   label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2709
2710   // Avoid a crash when core load gl resources.
2711   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2712
2713   // Render and notify
2714   application.SendNotification();
2715   application.Render();
2716
2717   unsigned int expectedCount = 1;
2718   unsigned int startIndex    = 1;
2719   unsigned int endIndex      = 13;
2720
2721   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2722   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2723
2724   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2725   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2726
2727   Vector<Vector2> expectedSizes;
2728   Vector<Vector2> expectedPositions;
2729
2730   expectedPositions.PushBack(Vector2(6, 0));
2731   expectedSizes.PushBack(Vector2(125, 25));
2732
2733   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2734
2735   END_TEST;
2736 }
2737
2738 int utcDaliTextLabelGeometryOneGlyph(void)
2739 {
2740   ToolkitTestApplication application;
2741   tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2742
2743   TextLabel label = TextLabel::New();
2744   DALI_TEST_CHECK(label);
2745
2746   application.GetScene().Add(label);
2747
2748   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2749   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2750   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2751   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2752   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2753   label.SetProperty(TextLabel::Property::TEXT, "H");
2754
2755   // Avoid a crash when core load gl resources.
2756   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2757
2758   // Render and notify
2759   application.SendNotification();
2760   application.Render();
2761
2762   unsigned int expectedCount = 1;
2763   unsigned int startIndex    = 0;
2764   unsigned int endIndex      = 0;
2765
2766   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2767   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2768
2769   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2770   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2771
2772   Vector<Vector2> expectedSizes;
2773   Vector<Vector2> expectedPositions;
2774
2775   expectedPositions.PushBack(Vector2(-2, 0));
2776   expectedSizes.PushBack(Vector2(16, 25));
2777
2778   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2779
2780   positionsList.Clear();
2781   sizeList.Clear();
2782
2783   startIndex = 2;
2784   endIndex   = 0;
2785
2786   positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2787   sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2788
2789   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2790
2791   END_TEST;
2792 }
2793
2794 int utcDaliTextLabelGeometryNullPtr(void)
2795 {
2796   ToolkitTestApplication application;
2797   tet_infoline("utcDaliTextLabelGeometryNullPtr");
2798
2799   TextLabel label = TextLabel::New();
2800   DALI_TEST_CHECK(label);
2801
2802   application.GetScene().Add(label);
2803
2804   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2805   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2806   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2807   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2808   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2809   label.SetProperty(TextLabel::Property::TEXT, "");
2810
2811   // Avoid a crash when core load gl resources.
2812   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2813
2814   unsigned int expectedCount = 0;
2815   unsigned int startIndex    = 0;
2816   unsigned int endIndex      = 0;
2817
2818   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2819   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2820
2821   // Render and notify
2822   application.SendNotification();
2823   application.Render();
2824
2825   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2826   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2827
2828   END_TEST;
2829 }
2830
2831 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2832 {
2833   ToolkitTestApplication application;
2834   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2835   TextLabel textLabel = TextLabel::New();
2836
2837   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2838   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2839
2840   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2841   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2842   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2843
2844   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2845   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2846   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2847
2848   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2849   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2850   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2851
2852   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2853   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2854   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2855
2856   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2857   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2858   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2859
2860   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2861   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2862   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2863
2864   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2865   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2866   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2867
2868   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2869   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2870   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2871
2872   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2873   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2874   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2875
2876   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2877   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2878   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2879
2880   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2881   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2882   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2883
2884   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2885   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2886   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2887
2888   END_TEST;
2889 }
2890
2891 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
2892 {
2893   ToolkitTestApplication application;
2894   tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
2895
2896   TextLabel textLabel = TextLabel::New();
2897   textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
2898   textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
2899   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2900   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2901
2902   application.GetScene().Add(textLabel);
2903   application.SendNotification();
2904   application.Render();
2905
2906   Property::Map strikethroughMapSet;
2907   Property::Map strikethroughMapGet;
2908
2909   strikethroughMapSet.Insert("enable", true);
2910   strikethroughMapSet.Insert("color", Color::RED);
2911   strikethroughMapSet.Insert("height", 2.0f);
2912
2913   // Check the strikethrough property
2914   textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2915   strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
2916   textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
2917   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
2918   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
2919
2920   // Render and notify
2921   application.SendNotification();
2922   application.Render();
2923
2924   strikethroughMapSet.Clear();
2925   strikethroughMapGet.Clear();
2926
2927   END_TEST;
2928 }
2929
2930 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
2931 {
2932   ToolkitTestApplication application;
2933   tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
2934
2935   TextLabel label = TextLabel::New();
2936   label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2937   label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2938   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2939   label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
2940   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
2941   label.SetProperty(TextLabel::Property::ELLIPSIS, false);
2942   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2943
2944   TextLabel labelSingleLineParagraph = TextLabel::New();
2945   labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2946   labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2947   labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
2948   labelSingleLineParagraph.SetProperty(TextLabel::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line 2</p>line 3<p rel-line-height=3>line 4</p>line 5");
2949   labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
2950   labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
2951   labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2952
2953   TextLabel labelMultiLineParagraph = TextLabel::New();
2954   labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2955   labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2956   labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
2957   labelMultiLineParagraph.SetProperty(TextLabel::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line\n2</p>line 3<p rel-line-height=3>line\n4</p>line 5");
2958   labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
2959   labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
2960   labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2961
2962   application.GetScene().Add(label);
2963   application.GetScene().Add(labelSingleLineParagraph);
2964   application.GetScene().Add(labelMultiLineParagraph);
2965   application.SendNotification();
2966   application.Render();
2967
2968   Vector3 naturalSize               = label.GetNaturalSize();
2969   Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
2970   Vector3 relativeMultiNaturalSize  = labelMultiLineParagraph.GetNaturalSize();
2971
2972   float lineSize = naturalSize.y / 5.0f; //total size/number of lines
2973
2974   //no effect of relative line size for paragraph with single line
2975   DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2976
2977   DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2978
2979   END_TEST;
2980 }
2981
2982 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
2983 {
2984   ToolkitTestApplication application;
2985   tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
2986
2987   TextLabel label = TextLabel::New();
2988   label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2989   label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2990   label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
2991
2992   application.GetScene().Add(label);
2993   application.SendNotification();
2994   application.Render();
2995
2996   Vector3 naturalSize = label.GetNaturalSize();
2997
2998   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
2999
3000   application.SendNotification();
3001   application.Render();
3002
3003   Vector3 relativeNaturalSize = label.GetNaturalSize();
3004
3005   DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3006
3007   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3008
3009   application.SendNotification();
3010   application.Render();
3011
3012   relativeNaturalSize = label.GetNaturalSize();
3013
3014   DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3015   END_TEST;
3016 }
3017
3018 int UtcDaliTextLabelCharacterSpacing(void)
3019 {
3020   ToolkitTestApplication application;
3021   tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3022
3023   TextLabel textLabel = TextLabel::New();
3024
3025   textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3026
3027   application.GetScene().Add(textLabel);
3028   application.SendNotification();
3029   application.Render();
3030
3031   textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3032   textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3033   DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3034
3035   application.SendNotification();
3036   application.Render();
3037
3038   END_TEST;
3039 }
3040
3041 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3042 {
3043   ToolkitTestApplication application;
3044   tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3045
3046   TextLabel label = TextLabel::New();
3047
3048   float lineSpacing = -20.f;
3049
3050   label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3051   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3052   label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3053   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3054   label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3055
3056   application.GetScene().Add(label);
3057   application.SendNotification();
3058   application.Render();
3059
3060   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3061   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, 0, 123);
3062
3063   Vector2 lastLinePos  = positionsList[positionsList.Size() - 1];
3064   Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3065
3066   DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3067   DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3068
3069   application.SendNotification();
3070   application.Render();
3071
3072   END_TEST;
3073 }
3074
3075 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3076 {
3077   ToolkitTestApplication application;
3078   tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3079
3080   TextLabel label = TextLabel::New();
3081
3082   float lineSpacing = -20.f;
3083
3084   label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3085   label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3086   label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3087   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3088   label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3089   label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3090
3091   application.GetScene().Add(label);
3092   application.SendNotification();
3093   application.Render();
3094
3095   Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3096
3097   int lineCount = sizeList.Size();
3098   DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3099
3100   application.SendNotification();
3101   application.Render();
3102
3103   END_TEST;
3104 }
3105
3106 int UtcDaliToolkitTextlabelParagraphTag(void)
3107 {
3108   ToolkitTestApplication application;
3109   tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3110   TextLabel labelNewlineSeparator = TextLabel::New();
3111   TextLabel labelParagraphTag     = TextLabel::New();
3112   DALI_TEST_CHECK(labelNewlineSeparator);
3113   DALI_TEST_CHECK(labelParagraphTag);
3114
3115   application.GetScene().Add(labelNewlineSeparator);
3116   application.GetScene().Add(labelParagraphTag);
3117
3118   //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3119   labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3120   labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3121   labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3122   labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3123   labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3124   labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3125   labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3126
3127   labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3128   labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3129   labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3130   labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3131   labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3132   labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3133   labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3134
3135   application.SendNotification();
3136   application.Render();
3137
3138   Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3139   Vector3 textNaturalSizeParagraphTag     = labelParagraphTag.GetNaturalSize();
3140
3141   DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3142
3143   application.SendNotification();
3144   application.Render();
3145
3146   END_TEST;
3147 }
3148
3149 int utcDaliTextLabelGetTextBoundingRectangle(void)
3150 {
3151   ToolkitTestApplication application;
3152   tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3153
3154   TextLabel label = TextLabel::New();
3155   DALI_TEST_CHECK(label);
3156
3157   application.GetScene().Add(label);
3158
3159   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3160   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3161   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3162   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3163   label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3164
3165   // Avoid a crash when core load gl resources.
3166   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3167
3168   // Render and notify
3169   application.SendNotification();
3170   application.Render();
3171
3172   unsigned int startIndex    = 0;
3173   unsigned int endIndex      = 15;
3174
3175   Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3176   Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3177
3178   TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
3179
3180   END_TEST;
3181 }