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