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