Merge "Add offset to text outline" into devel/master
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <iostream>
21
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/bitmap-font.h>
27 #include <dali-toolkit/devel-api/text/rendering-backend.h>
28 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
29 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
30 #include <dali/devel-api/adaptor-framework/image-loading.h>
31 #include <dali/devel-api/text-abstraction/bitmap-font.h>
32 #include <dali/devel-api/text-abstraction/font-client.h>
33 #include "test-text-geometry-utils.h"
34
35 using namespace Dali;
36 using namespace Toolkit;
37
38 void dali_textlabel_startup(void)
39 {
40   test_return_value = TET_UNDEF;
41 }
42
43 void dali_textlabel_cleanup(void)
44 {
45   test_return_value = TET_PASS;
46 }
47
48 namespace
49 {
50 const char* const PROPERTY_NAME_RENDERING_BACKEND        = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT                     = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY              = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE               = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE               = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE               = "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT     = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT       = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR               = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP            = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL       = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP   = "autoScrollGap";
64
65 const char* const PROPERTY_NAME_LINE_SPACING  = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE     = "underline";
67 const char* const PROPERTY_NAME_SHADOW        = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS        = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE       = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND    = "textBackground";
71 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
72
73 const char* const PROPERTY_NAME_PIXEL_SIZE             = "pixelSize";
74 const char* const PROPERTY_NAME_ELLIPSIS               = "ellipsis";
75 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
76 const char* const PROPERTY_NAME_FONT_SIZE_SCALE        = "fontSizeScale";
77 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
78
79 const char* const PROPERTY_NAME_ELLIPSIS_POSITION    = "ellipsisPosition";
80 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   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
957
958   outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
959   DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
960   DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
961
962   outlineMapSet.Clear();
963   outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
964   outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
965   outlineMapSet[Toolkit::DevelText::Outline::Property::OFFSET] = Vector2(3.0f, 3.0f);
966
967   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
968
969   outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
970   DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
971   std::vector<std::string> outlineIndicesConversionTable = {"color", "width", "offset"};
972   DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
973
974   // Check the background property
975   Property::Map backgroundMapSet;
976   Property::Map backgroundMapGet;
977
978   backgroundMapSet["enable"] = true;
979   backgroundMapSet["color"]  = Color::RED;
980   label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
981
982   backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
983   DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
984   DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
985
986   // Check the transparent background property for coverage
987   backgroundMapSet.Clear();
988   backgroundMapSet["enable"] = true;
989   backgroundMapSet["color"]  = Color::TRANSPARENT;
990   label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
991
992   application.SendNotification();
993   application.Render();
994
995   backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
996   DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
997   DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
998
999   backgroundMapSet.Clear();
1000   backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
1001   backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR]  = Color::GREEN;
1002   label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
1003
1004   backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
1005   DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
1006   std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
1007   DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
1008
1009   // Check the pixel size of font
1010   label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
1011   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1012
1013   // Check the ellipsis property
1014   DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1015   label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1016   DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1017
1018   // Check the layout direction property
1019   label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1020   DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1021
1022   // Check the line size property
1023   DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1024   label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1025   DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1026
1027   application.SendNotification();
1028   application.Render();
1029
1030   // Check Remove Front/Back Inset Property
1031   DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1032   label.SetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET, false);
1033   DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1034
1035   DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1036   label.SetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET, false);
1037   DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1038
1039   application.SendNotification();
1040   application.Render();
1041
1042   END_TEST;
1043 }
1044
1045 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1046 {
1047   ToolkitTestApplication application;
1048   tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1049   TextLabel label = TextLabel::New("Test Text");
1050   DALI_TEST_CHECK(label);
1051
1052   // Avoid a crash when core load gl resources.
1053   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1054
1055   application.GetScene().Add(label);
1056
1057   // Turn on all the effects
1058   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1059   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1060
1061   Property::Map underlineMap;
1062   underlineMap.Insert("enable", true);
1063   underlineMap.Insert("color", Color::RED);
1064   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1065
1066   Property::Map shadowMap;
1067   shadowMap.Insert("color", Color::BLUE);
1068   shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1069   label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1070
1071   Property::Map strikethroughMap;
1072   strikethroughMap.Insert("enable", true);
1073   strikethroughMap.Insert("color", Color::GREEN);
1074   strikethroughMap.Insert("height", 2.0f);
1075   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1076
1077   try
1078   {
1079     // Render some text with the shared atlas backend
1080     label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1081     application.SendNotification();
1082     application.Render();
1083   }
1084   catch(...)
1085   {
1086     tet_result(TET_FAIL);
1087   }
1088
1089   try
1090   {
1091     // Render some text with the shared atlas backend
1092     label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1093     application.SendNotification();
1094     application.Render();
1095   }
1096   catch(...)
1097   {
1098     tet_result(TET_FAIL);
1099   }
1100   END_TEST;
1101 }
1102
1103 int UtcDaliToolkitTextLabelLanguagesP(void)
1104 {
1105   ToolkitTestApplication application;
1106   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1107   TextLabel label = TextLabel::New();
1108   DALI_TEST_CHECK(label);
1109
1110   application.GetScene().Add(label);
1111
1112   const std::string scripts(
1113     " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1114     "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1115     "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1116     "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1117     "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1118     "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1119
1120   label.SetProperty(TextLabel::Property::TEXT, scripts);
1121   DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1122
1123   application.SendNotification();
1124   application.Render();
1125
1126   END_TEST;
1127 }
1128
1129 int UtcDaliToolkitTextLabelEmojisP(void)
1130 {
1131   ToolkitTestApplication application;
1132   tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1133   TextLabel label = TextLabel::New();
1134   DALI_TEST_CHECK(label);
1135
1136   application.GetScene().Add(label);
1137
1138   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1139
1140   char*             pathNamePtr = get_current_dir_name();
1141   const std::string pathName(pathNamePtr);
1142   free(pathNamePtr);
1143
1144   TextAbstraction::FontDescription fontDescription;
1145   fontDescription.path   = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1146   fontDescription.family = "BreezeColorEmoji";
1147   fontDescription.width  = TextAbstraction::FontWidth::NONE;
1148   fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1149   fontDescription.slant  = TextAbstraction::FontSlant::NONE;
1150
1151   fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1152
1153   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>";
1154   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1155   label.SetProperty(TextLabel::Property::TEXT, emojis);
1156
1157   Property::Map shadowMap;
1158   shadowMap.Insert("color", "green");
1159   shadowMap.Insert("offset", "2 2");
1160   label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1161
1162   application.SendNotification();
1163   application.Render();
1164
1165   // EMOJI + ZWJ + EMOJI case for coverage.
1166   const std::string emojiWithZWJ = "&#x1f469;&#x200d;&#x1f52c;";
1167   label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1168
1169   application.SendNotification();
1170   application.Render();
1171
1172   // EMOJI Sequences case for coverage.
1173   std::string emojiSequences =
1174     "Glyphs not included in the font &#xf01a;&#xf01b;&#xf01c;&#xf01d;&#xf01e;&#xf01f;\n"   //case for coverage when glyph is not included in the font
1175     "Text VS15 &#x262a;&#xfe0e;\n"                                                         //text presentation sequence and selector
1176     "Color VS16 &#x262a;&#xfe0f;\n"                                                        //emoji presentation sequence and selector
1177     "Default &#x262a; \n"                                                                  //default presentation
1178     "FamilyManWomanGirlBoy &#x1F468;&#x200D;&#x1F469;&#x200D;&#x1F467;&#x200D;&#x1F466;\n" // emoji multi zwj sequence
1179     "WomanScientist &#x1f469;&#x200d;&#x1f52c;\n"                                          // emoji zwj sequence
1180     "WomanScientistLightSkinTone&#x1F469;&#x1F3FB;&#x200D;&#x1F52C; \n"                    // emoji modifier sequence: skin tone & JWZ
1181     "LeftRightArrowText&#x2194;&#xfe0e;\n"                                                 // text presentation sequence and selector
1182     "LeftRightArrowEmoji&#x2194;&#xfe0f;\n"                                                // emoji presentation sequence and selector
1183     "SouthKoreaFlag&#x1f1f0;&#x1f1f7;\n"                                                   // emoji flag sequence
1184     "JordanFlag&#x1f1ef;&#x1f1f4;\n"                                                       // emoji flag sequence
1185     "EnglandFlag&#x1F3F4;&#xE0067;&#xE0062;&#xE0065;&#xE006E;&#xE0067;&#xE007F;\n"         // emoji tag sequence like England flag
1186     "Runner &#x1f3c3;&#x200d;&#x27a1;&#xfe0f; \n"
1187     "VictoryHandMediumLightSkinTone:&#x270C;&#xFE0F;&#x1F3FC;\n"                                                                // emoji modifier sequence: skin tone
1188     "RainbowFlag:&#x1F3F3;&#xFE0F;&#x200D;&#x1F308; \n"                                                                         // emoji zwj sequence: Rainbow Flag
1189     "keycap# &#x0023;&#xFE0F;&#x20E3; \n"                                                                                       // fully-qualified  emoji keycap sequence
1190     "keycap#_text &#x0023;&#x20E3; \n"                                                                                          // unqualified emoji keycap sequence
1191     "keycap3 &#x0033;&#xfe0f;&#x20e3; \n"                                                                                       // fully-qualified  emoji keycap sequence
1192     "keycap3_text &#x0033;&#x20e3; \n"                                                                                          // unqualified emoji keycap sequence
1193     "two adjacent glyphs &#x262a;&#xfe0f;&#xfe0f;&#xfe0f;&#x262a;&#xfe0f;\n"                                                    // This line should be rendered as two adjacent glyphs
1194     "Digit 8&#xfe0f; 8&#xfe0e; 8\n"                                                                                             // should be rendered according to selector
1195     "Surfing Medium Skin Female:  &#x1f3c4;&#x1f3fc;&#x200d;&#x2640;&#xfe0f;\n"                                                 // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1196     "SYMBOLS_NSLCL variation selector: &#x1f170;&#xfe0f;&#x1f171;&#xfe0f;&#x1f172;&#xfe0e;&#x1f173;&#xfe0e;&#x1f174;&#xfe0e;\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1197     "SYMBOLS_NSLCL with VS15: &#x1f170;&#xfe0e;&#x1f171;&#xfe0e;&#x1f172;&#xfe0e;&#x1f173;&#xfe0e;&#x1f174;&#xfe0e;\n"          // 1F170 ~ 1F174 with VS15
1198     "SYMBOLS_NSLCL with VS16: &#x1f170;&#xfe0f;&#x1f171;&#xfe0f;&#x1f172;&#xfe0f;&#x1f173;&#xfe0f;&#x1f174;&#xfe0f;\n"          // 1F170 ~ 1F174 with VS16
1199
1200     ;
1201
1202   label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1203   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1204   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1205   label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1206
1207   application.SendNotification();
1208   application.Render();
1209   END_TEST;
1210 }
1211
1212 int UtcDaliToolkitTextlabelScrollingP(void)
1213 {
1214   ToolkitTestApplication application;
1215   tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1216   TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1217   TextLabel labelFinished  = TextLabel::New("مرحبا بالعالم");
1218
1219   DALI_TEST_CHECK(labelImmediate);
1220   DALI_TEST_CHECK(labelFinished);
1221   // Avoid a crash when core load gl resources.
1222   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1223   application.GetScene().Add(labelImmediate);
1224   // Turn on all the effects
1225   labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1226   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1227   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1228   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1229   labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1230
1231   application.GetScene().Add(labelFinished);
1232   // Turn on all the effects
1233   labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1234   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1235   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1236   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1237   labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1238
1239   try
1240   {
1241     // Render some text with the shared atlas backend
1242     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1243     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1244
1245     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1246     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1247
1248     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1249     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1250     application.SendNotification();
1251     application.Render();
1252
1253     labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1254     labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1255     application.SendNotification();
1256     application.Render();
1257   }
1258   catch(...)
1259   {
1260     tet_result(TET_FAIL);
1261   }
1262
1263   END_TEST;
1264 }
1265
1266 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1267 {
1268   ToolkitTestApplication application;
1269   TextLabel              labelShort = TextLabel::New("Some text to scroll");
1270   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!");
1271
1272   DALI_TEST_CHECK(labelShort);
1273   DALI_TEST_CHECK(labelLong);
1274   // Avoid a crash when core load gl resources.
1275   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1276   application.GetScene().Add(labelShort);
1277   // Turn on all the effects
1278   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1279   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1280   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1281   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1282   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1283   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1284
1285   application.GetScene().Add(labelLong);
1286   // Turn on all the effects
1287   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1288   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1289   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1290   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1291   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1292   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1293
1294   try
1295   {
1296     // Render some text with the shared atlas backend
1297     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1298     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1299     application.SendNotification();
1300     application.Render();
1301
1302     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1303     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1304     application.SendNotification();
1305     application.Render();
1306   }
1307   catch(...)
1308   {
1309     tet_result(TET_FAIL);
1310   }
1311
1312   END_TEST;
1313 }
1314
1315 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1316 {
1317   ToolkitTestApplication application;
1318   TextLabel              labelShort = TextLabel::New("مرحبا بالعالم");
1319   TextLabel              labelLong  = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1320
1321   DALI_TEST_CHECK(labelShort);
1322   DALI_TEST_CHECK(labelLong);
1323   // Avoid a crash when core load gl resources.
1324   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1325   application.GetScene().Add(labelShort);
1326   // Turn on all the effects
1327   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1328   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1329   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1330   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1331   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1332   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1333
1334   application.GetScene().Add(labelLong);
1335   // Turn on all the effects
1336   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1337   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1338   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1339   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1340   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1341   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1342
1343   try
1344   {
1345     // Render some text with the shared atlas backend
1346     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1347     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1348     application.SendNotification();
1349     application.Render();
1350
1351     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1352     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1353     application.SendNotification();
1354     application.Render();
1355   }
1356   catch(...)
1357   {
1358     tet_result(TET_FAIL);
1359   }
1360
1361   END_TEST;
1362 }
1363
1364 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1365 {
1366   ToolkitTestApplication application;
1367   TextLabel              labelShort = TextLabel::New("Some text to scroll");
1368   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!");
1369
1370   DALI_TEST_CHECK(labelShort);
1371   DALI_TEST_CHECK(labelLong);
1372   // Avoid a crash when core load gl resources.
1373   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1374   application.GetScene().Add(labelShort);
1375   // Turn on all the effects
1376   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1377   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1378   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1379   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1380   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1381   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1382
1383   application.GetScene().Add(labelLong);
1384   // Turn on all the effects
1385   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1386   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1387   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1388   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1389   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1390   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1391
1392   try
1393   {
1394     // Render some text with the shared atlas backend
1395     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1396     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1397     application.SendNotification();
1398     application.Render();
1399
1400     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1401     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1402     application.SendNotification();
1403     application.Render();
1404   }
1405   catch(...)
1406   {
1407     tet_result(TET_FAIL);
1408   }
1409
1410   END_TEST;
1411 }
1412
1413 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1414 {
1415   ToolkitTestApplication application;
1416   TextLabel              labelShort = TextLabel::New("مرحبا بالعالم");
1417   TextLabel              labelLong  = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار  النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1418
1419   DALI_TEST_CHECK(labelShort);
1420   DALI_TEST_CHECK(labelLong);
1421   // Avoid a crash when core load gl resources.
1422   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1423   application.GetScene().Add(labelShort);
1424   // Turn on all the effects
1425   labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1426   labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1427   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1428   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1429   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1430   labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1431
1432   application.GetScene().Add(labelLong);
1433   // Turn on all the effects
1434   labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1435   labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1436   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1437   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1438   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1439   labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1440
1441   try
1442   {
1443     // Render some text with the shared atlas backend
1444     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1445     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1446     application.SendNotification();
1447     application.Render();
1448
1449     labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1450     labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1451     application.SendNotification();
1452     application.Render();
1453   }
1454   catch(...)
1455   {
1456     tet_result(TET_FAIL);
1457   }
1458
1459   END_TEST;
1460 }
1461
1462 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1463 {
1464   ToolkitTestApplication application;
1465   tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1466   TextLabel label = TextLabel::New("Some text to scroll");
1467   DALI_TEST_CHECK(label);
1468   // Avoid a crash when core load gl resources.
1469   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1470   application.GetScene().Add(label);
1471   label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1472   // Turn on all the effects
1473   label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1474   label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1475   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1476   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1477
1478   // Render the text.
1479   application.SendNotification();
1480   application.Render();
1481
1482   unsigned int actorCount1 = label.GetChildCount();
1483   tet_printf("Initial actor count is(%d)\n", actorCount1);
1484
1485   try
1486   {
1487     // Render some text with the shared atlas backend
1488     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1489     application.SendNotification();
1490     application.Render(2000);
1491
1492     unsigned int actorCount1 = label.GetChildCount();
1493     tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1494
1495     label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1496
1497     // Render the text.
1498     application.SendNotification();
1499     application.Render();
1500
1501     unsigned int actorCount2 = label.GetChildCount();
1502     tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1503
1504     DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1505   }
1506   catch(...)
1507   {
1508     tet_result(TET_FAIL);
1509   }
1510
1511   END_TEST;
1512 }
1513
1514 int UtcDaliToolkitTextlabelScrollingN(void)
1515 {
1516   ToolkitTestApplication application;
1517   tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1518
1519   TextLabel label = TextLabel::New("Some text to scroll");
1520   DALI_TEST_CHECK(label);
1521
1522   application.GetScene().Add(label);
1523
1524   // Avoid a crash when core load gl resources.
1525   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1526
1527   // The text scrolling works only on single line text.
1528   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1529
1530   // Turn on all the effects.
1531   label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1532   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1533   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1534
1535   // Enable the auto scrolling effect.
1536   label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1537
1538   // The auto scrolling shouldn't be enabled.
1539   const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1540   DALI_TEST_CHECK(!enabled);
1541
1542   label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1543   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
1544   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
1545   label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1546
1547   try
1548   {
1549     // Render the text.
1550     application.SendNotification();
1551     application.Render(1000);
1552
1553     application.GetScene().Remove(label);
1554     application.SendNotification();
1555     application.Render();
1556
1557     DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1558
1559     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1560     application.GetScene().Add(label);
1561
1562     application.SendNotification();
1563     application.Render();
1564
1565     DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1566
1567     label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
1568     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1569
1570     application.SendNotification();
1571     application.Render();
1572
1573     DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1574   }
1575   catch(...)
1576   {
1577     tet_result(TET_FAIL);
1578   }
1579
1580   END_TEST;
1581 }
1582
1583 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1584 {
1585   ToolkitTestApplication application;
1586   tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1587
1588   TextLabel label = TextLabel::New("Some text to scroll");
1589   DALI_TEST_CHECK(label);
1590
1591   application.GetScene().Add(label);
1592
1593   // Avoid a crash when core load gl resources.
1594   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1595
1596   // Turn on all the effects.
1597   label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1598   label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1599   label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1600
1601   try
1602   {
1603     // Enable the auto scrolling effect.
1604     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1605     label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1606
1607     // Disable the ellipsis
1608     label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1609
1610     // Render the text.
1611     application.SendNotification();
1612     application.Render();
1613
1614     // Stop auto scrolling
1615     label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1616
1617     // Check the ellipsis property
1618     DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1619   }
1620   catch(...)
1621   {
1622     tet_result(TET_FAIL);
1623   }
1624
1625   END_TEST;
1626 }
1627
1628 int UtcDaliToolkitTextlabelEllipsis(void)
1629 {
1630   ToolkitTestApplication application;
1631   tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1632
1633   TextLabel label = TextLabel::New("Hello world");
1634   DALI_TEST_CHECK(label);
1635
1636   // Avoid a crash when core load gl resources.
1637   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1638
1639   application.GetScene().Add(label);
1640
1641   // Turn on all the effects
1642   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1643   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1644   label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1645
1646   try
1647   {
1648     // Render the text.
1649     application.SendNotification();
1650     application.Render();
1651   }
1652   catch(...)
1653   {
1654     tet_result(TET_FAIL);
1655   }
1656
1657   label.SetProperty(TextLabel::Property::TEXT, "Hello world                                        ");
1658   label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1659   label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1660
1661   try
1662   {
1663     // Render the text.
1664     application.SendNotification();
1665     application.Render();
1666   }
1667   catch(...)
1668   {
1669     tet_result(TET_FAIL);
1670   }
1671
1672   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1673   label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1674   label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1675
1676   try
1677   {
1678     // Render the text.
1679     application.SendNotification();
1680     application.Render();
1681   }
1682   catch(...)
1683   {
1684     tet_result(TET_FAIL);
1685   }
1686
1687   END_TEST;
1688 }
1689
1690 int UtcDaliToolkitTextlabelTextWrapMode(void)
1691 {
1692   ToolkitTestApplication application;
1693   tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1694
1695   int lineCount = 0;
1696
1697   TextLabel label = TextLabel::New();
1698   label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1699   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1700   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1701
1702   //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1703   application.GetScene().Add(label);
1704
1705   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1706   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1707
1708   application.SendNotification();
1709   application.Render();
1710
1711   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1712   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1713
1714   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1715   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1716
1717   application.SendNotification();
1718   application.Render();
1719
1720   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1721   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1722
1723   application.SendNotification();
1724   application.Render();
1725
1726   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1727   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1728
1729   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1730   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1731
1732   application.SendNotification();
1733   application.Render();
1734
1735   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1736   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1737
1738   tet_infoline("Ensure invalid string does not change wrapping mode");
1739   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1740   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1741
1742   END_TEST;
1743 }
1744
1745 int UtcDaliToolkitTextLabelColorComponents(void)
1746 {
1747   ToolkitTestApplication application;
1748
1749   TextLabel label = TextLabel::New();
1750   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1751   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1752   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1753   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1754   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1755
1756   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1757   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1758   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1759   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1760   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1761
1762   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1763   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1764   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1765   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1766   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1767
1768   label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1769   DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1770   DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1771
1772   // Test a transparent text - Rendering should be skipped.
1773   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1774   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1775
1776   application.GetScene().Add(label);
1777
1778   TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1779   drawTrace.Enable(true);
1780
1781   application.SendNotification();
1782   application.Render();
1783
1784   DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1785
1786   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1787
1788   drawTrace.Reset();
1789
1790   application.SendNotification();
1791   application.Render();
1792
1793   DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1794
1795   label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1796
1797   drawTrace.Reset();
1798
1799   application.SendNotification();
1800   application.Render();
1801
1802   DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1803
1804   END_TEST;
1805 }
1806
1807 int UtcDaliToolkitTextlabelTextStyle01(void)
1808 {
1809   ToolkitTestApplication application;
1810   tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1811
1812   TextLabel label = TextLabel::New();
1813   label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1814   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1815   label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1816   application.GetScene().Add(label);
1817
1818   Property::Map outlineMapSet;
1819   Property::Map outlineMapGet;
1820
1821   outlineMapSet["color"] = Color::BLUE;
1822   outlineMapSet["width"] = 2.0f;
1823   outlineMapSet["offset"] = "2 2";
1824   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1825
1826   application.SendNotification();
1827   application.Render();
1828
1829   Property::Map shadowMapSet;
1830   shadowMapSet.Insert("color", "green");
1831   shadowMapSet.Insert("offset", "2 2");
1832   shadowMapSet.Insert("blurRadius", "3");
1833   label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1834
1835   outlineMapSet["color"] = Color::RED;
1836   outlineMapSet["width"] = 0.0f;
1837   label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1838
1839   application.SendNotification();
1840   application.Render();
1841
1842   outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1843
1844   Property::Value* colorValue = outlineMapGet.Find("color");
1845
1846   bool colorMatched(false);
1847
1848   if(colorValue)
1849   {
1850     Property::Type valueType = colorValue->GetType();
1851
1852     if(Property::STRING == valueType)
1853     {
1854       std::string stringValue;
1855       colorValue->Get(stringValue);
1856       if(stringValue == "red")
1857       {
1858         colorMatched = true;
1859       }
1860     }
1861     else if(Property::VECTOR4 == valueType)
1862     {
1863       Vector4 colorVector4;
1864       colorValue->Get(colorVector4);
1865       if(colorVector4 == Color::RED)
1866       {
1867         colorMatched = true;
1868       }
1869     }
1870   }
1871
1872   DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1873
1874   END_TEST;
1875 }
1876
1877 int UtcDaliToolkitTextlabelMultiline(void)
1878 {
1879   ToolkitTestApplication application;
1880   tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1881
1882   TextLabel label = TextLabel::New();
1883   label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1884   label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1885   label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1886   application.GetScene().Add(label);
1887
1888   application.SendNotification();
1889   application.Render();
1890
1891   int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1892   DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1893
1894   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1895
1896   application.SendNotification();
1897   application.Render();
1898
1899   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1900   DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1901
1902   END_TEST;
1903 }
1904
1905 int UtcDaliToolkitTextlabelTextDirection(void)
1906 {
1907   ToolkitTestApplication application;
1908   tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1909
1910   TextLabel label = TextLabel::New();
1911   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1912
1913   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1914   label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1915   label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1916   application.GetScene().Add(label);
1917
1918   // Test LTR text
1919   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1920
1921   // Test RTL text
1922   label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1923   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1924
1925   // Test RTL text starting with weak character
1926   label.SetProperty(TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1927   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1928
1929   // Test RTL text string with emoji and weak character
1930   label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1931   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1932
1933   END_TEST;
1934 }
1935
1936 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1937 {
1938   ToolkitTestApplication application;
1939   tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1940
1941   TextLabel label = TextLabel::New();
1942
1943   label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1944   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1945   label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1946   label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1947   application.GetScene().Add(label);
1948   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1949
1950   label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1951   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1952
1953   label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1954   DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1955
1956   END_TEST;
1957 }
1958
1959 int UtcDaliToolkitTextLabelBitmapFont(void)
1960 {
1961   ToolkitTestApplication application;
1962   tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1963
1964   DevelText::BitmapFontDescription fontDescription;
1965   fontDescription.name               = "Digits";
1966   fontDescription.underlinePosition  = 0.f;
1967   fontDescription.underlineThickness = 0.f;
1968
1969   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1970   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1971   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1972   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1973   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1974   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1975   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1976   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
1977   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
1978   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
1979   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
1980
1981   TextAbstraction::BitmapFont bitmapFont;
1982   DevelText::CreateBitmapFont(fontDescription, bitmapFont);
1983
1984   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1985   fontClient.GetFontId(bitmapFont);
1986
1987   TextLabel label = TextLabel::New();
1988
1989   label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
1990   label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
1991
1992   // 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.
1993   DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1994
1995   application.GetScene().Add(label);
1996
1997   application.SendNotification();
1998   application.Render();
1999
2000   // The text has been rendered if the height of the text-label is the height of the line.
2001   DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2002
2003   END_TEST;
2004 }
2005
2006 int ConvertPointToPixel(float point)
2007 {
2008   unsigned int                horizontalDpi = 0u;
2009   unsigned int                verticalDpi   = 0u;
2010   TextAbstraction::FontClient fontClient    = TextAbstraction::FontClient::Get();
2011   fontClient.GetDpi(horizontalDpi, verticalDpi);
2012
2013   return (point * 72.f) / static_cast<float>(horizontalDpi);
2014 }
2015
2016 int UtcDaliToolkitTextlabelTextFit(void)
2017 {
2018   ToolkitTestApplication application;
2019   tet_infoline(" UtcDaliToolkitTextlabelTextFit");
2020   TextLabel label = TextLabel::New();
2021   Vector2   size(460.0f, 100.0f);
2022   label.SetProperty(Actor::Property::SIZE, size);
2023   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2024
2025   // connect to the text git changed signal.
2026   ConnectionTracker* testTracker = new ConnectionTracker();
2027   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2028   bool textFitChangedSignal = false;
2029   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2030   gTextFitChangedCallBackCalled = false;
2031
2032   // check point size
2033   Property::Map textFitMapSet;
2034   textFitMapSet["enable"]       = true;
2035   textFitMapSet["minSize"]      = 10.f;
2036   textFitMapSet["maxSize"]      = 100.f;
2037   textFitMapSet["stepSize"]     = -1.f;
2038   textFitMapSet["fontSizeType"] = "pointSize";
2039
2040   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2041   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2042
2043   application.GetScene().Add(label);
2044
2045   application.SendNotification();
2046   application.Render();
2047
2048   const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2049   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2050
2051   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2052   DALI_TEST_CHECK(textFitChangedSignal);
2053
2054   // check pixel size
2055   textFitMapSet.Clear();
2056   textFitMapSet["enable"]       = true;
2057   textFitMapSet["minSize"]      = ConvertPointToPixel(10.f);
2058   textFitMapSet["maxSize"]      = ConvertPointToPixel(100.f);
2059   textFitMapSet["stepSize"]     = ConvertPointToPixel(1.f);
2060   textFitMapSet["fontSizeType"] = "pixelSize";
2061
2062   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2063
2064   application.SendNotification();
2065   application.Render();
2066
2067   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2068
2069   END_TEST;
2070 }
2071
2072 int UtcDaliToolkitTextlabelTextFitStressTest(void)
2073 {
2074   ToolkitTestApplication application;
2075   tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
2076   TextLabel label = TextLabel::New();
2077   Vector2   size(460.0f, 100.0f);
2078   label.SetProperty(Actor::Property::SIZE, size);
2079   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2080
2081   // connect to the text git changed signal.
2082   ConnectionTracker* testTracker = new ConnectionTracker();
2083   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2084   bool textFitChangedSignal = false;
2085   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2086   gTextFitChangedCallBackCalled = false;
2087
2088   // check point size with veryvery big range
2089   Property::Map textFitMapSet;
2090   textFitMapSet["enable"]       = true;
2091   textFitMapSet["minSize"]      = 10.f;
2092   textFitMapSet["maxSize"]      = 10000.f;
2093   textFitMapSet["stepSize"]     = -1.0f;
2094   textFitMapSet["fontSizeType"] = "pointSize";
2095
2096   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2097   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2098
2099   application.GetScene().Add(label);
2100
2101   application.SendNotification();
2102   application.Render();
2103
2104   const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2105   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2106
2107   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2108   DALI_TEST_CHECK(textFitChangedSignal);
2109
2110   END_TEST;
2111 }
2112
2113 int UtcDaliToolkitTextlabelFastTextFitStressTest(void)
2114 {
2115   ToolkitTestApplication application;
2116   tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
2117   TextLabel label = TextLabel::New();
2118   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2119   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2120
2121   // connect to the text git changed signal.
2122   ConnectionTracker* testTracker = new ConnectionTracker();
2123   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2124   bool textFitChangedSignal = false;
2125   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2126   gTextFitChangedCallBackCalled = false;
2127
2128   application.GetScene().Add(label);
2129
2130   // check text label width at range [100, 299]
2131   for(int i=100; i<300; i++)
2132   {
2133     Vector2   size((float)i, 200.f);
2134     label.SetProperty(Actor::Property::SIZE, size);
2135
2136     // check point size with veryvery big range
2137     Property::Map textFitMapSet;
2138     textFitMapSet["enable"]       = true;
2139     textFitMapSet["minSize"]      = 10.f;
2140     textFitMapSet["maxSize"]      = 10000.f;
2141     textFitMapSet["stepSize"]     = -1.0f;
2142     textFitMapSet["fontSizeType"] = "pointSize";
2143
2144     label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2145
2146     application.SendNotification();
2147     application.Render();
2148   }
2149
2150   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2151   DALI_TEST_CHECK(textFitChangedSignal);
2152
2153   END_TEST;
2154 }
2155
2156 int UtcDaliToolkitTextlabelTextFitMultiLine(void)
2157 {
2158   ToolkitTestApplication application;
2159   tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
2160   TextLabel label = TextLabel::New();
2161   Vector2   size(500.0f, 100.0f);
2162   label.SetProperty(Actor::Property::SIZE, size);
2163   label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
2164   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2165
2166   // connect to the text git changed signal.
2167   ConnectionTracker* testTracker = new ConnectionTracker();
2168   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2169   bool textFitChangedSignal = false;
2170   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2171   gTextFitChangedCallBackCalled = false;
2172
2173   Property::Map textFitMapSet;
2174   textFitMapSet["enable"]       = true;
2175   textFitMapSet["minSize"]      = 10.f;
2176   textFitMapSet["maxSize"]      = 100.f;
2177   textFitMapSet["stepSize"]     = -1.0f;
2178   textFitMapSet["fontSizeType"] = "pointSize";
2179
2180   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2181   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2182
2183   application.GetScene().Add(label);
2184
2185   application.SendNotification();
2186   application.Render();
2187
2188   float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
2189   DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
2190
2191   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2192   DALI_TEST_CHECK(textFitChangedSignal);
2193
2194   END_TEST;
2195 }
2196
2197 int UtcDaliToolkitTextlabelTextFitArray(void)
2198 {
2199   ToolkitTestApplication application;
2200   tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2201   TextLabel label = TextLabel::New();
2202   Vector2   size(300.0f, 80.0f);
2203   label.SetProperty(Actor::Property::SIZE, size);
2204   label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2205   label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2206   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2207   application.GetScene().Add(label);
2208
2209   // make sorted options.
2210   std::vector<DevelTextLabel::FitOption> fitOptions;
2211   fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2212   fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2213   fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2214   fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2215   fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2216   fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2217   fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2218
2219   DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2220
2221   application.SendNotification();
2222   application.Render();
2223
2224   bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2225   DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2226
2227   std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2228   size_t numberOfFitOptions = getFitOptions.size();
2229   DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2230
2231   const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2232   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2233
2234   std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2235   DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2236
2237   application.SendNotification();
2238   application.Render();
2239
2240   enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2241   DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2242
2243   const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2244   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2245
2246   // make unsorted options.
2247   std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2248   unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2249   unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2250   unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2251   unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2252
2253   DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2254
2255   application.SendNotification();
2256   application.Render();
2257
2258   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2259
2260   END_TEST;
2261 }
2262
2263 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2264 {
2265   ToolkitTestApplication application;
2266   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2267
2268   DevelText::BitmapFontDescription fontDescription;
2269   fontDescription.name = "Digits";
2270   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2271
2272   TextAbstraction::BitmapFont bitmapFont;
2273   DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2274
2275   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2276   fontClient.GetFontId(bitmapFont);
2277
2278   TextLabel label = TextLabel::New();
2279   label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2280   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2281   label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2282   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2283   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2284
2285   Property::Map underlineMapSet;
2286   underlineMapSet.Clear();
2287   underlineMapSet.Insert("enable", true);
2288   underlineMapSet.Insert("color", Color::RED);
2289   underlineMapSet.Insert("height", 1);
2290   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2291   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2292
2293   Property::Map strikethroughMapSet;
2294   strikethroughMapSet.Clear();
2295   strikethroughMapSet.Insert("enable", true);
2296   strikethroughMapSet.Insert("color", Color::RED);
2297   strikethroughMapSet.Insert("height", 2.0f);
2298   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2299   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2300
2301   application.GetScene().Add(label);
2302
2303   application.SendNotification();
2304   application.Render();
2305
2306   const int maxTextureSize = Dali::GetMaxTextureSize();
2307   // Whether the rendered text is greater than maxTextureSize
2308   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2309
2310   // Check if the number of renderers is greater than 1.
2311   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2312
2313   //DASHED
2314   underlineMapSet.Clear();
2315   underlineMapSet.Insert("enable", false);
2316   underlineMapSet.Insert("color", Color::BLUE);
2317   underlineMapSet.Insert("height", 0);
2318   underlineMapSet.Insert("type", Text::Underline::DASHED);
2319   underlineMapSet.Insert("dashWidth", 2);
2320   underlineMapSet.Insert("dashGap", 1);
2321   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2322   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2323
2324   application.GetScene().Add(label);
2325
2326   application.SendNotification();
2327   application.Render();
2328
2329   // Whether the rendered text is greater than maxTextureSize
2330   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2331
2332   // Check if the number of renderers is greater than 1.
2333   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2334
2335   //DOUBLE
2336   underlineMapSet.Clear();
2337   underlineMapSet.Insert("enable", false);
2338   underlineMapSet.Insert("color", Color::BLUE);
2339   underlineMapSet.Insert("height", 0);
2340   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2341   underlineMapSet.Insert("dashWidth", 2);
2342   underlineMapSet.Insert("dashGap", 1);
2343   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2344   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2345
2346   application.GetScene().Add(label);
2347
2348   application.SendNotification();
2349   application.Render();
2350
2351   // Whether the rendered text is greater than maxTextureSize
2352   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2353
2354   // Check if the number of renderers is greater than 1.
2355   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2356
2357   // Coverage test for case of layoutSize is bigger than maxTextureSize
2358   float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2359   label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2360   application.SendNotification();
2361   application.Render();
2362
2363   END_TEST;
2364 }
2365
2366 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2367 {
2368   ToolkitTestApplication application;
2369   tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2370
2371   TextLabel label = TextLabel::New();
2372   label.SetProperty(TextLabel::Property::TEXT, "Test");
2373   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2374   //Exeeding BufferWidth
2375   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2376   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2377   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2378
2379   application.GetScene().Add(label);
2380   application.SendNotification();
2381   application.Render();
2382
2383   Property::Map strikethroughMapSet;
2384   strikethroughMapSet.Clear();
2385   strikethroughMapSet.Insert("enable", true);
2386   strikethroughMapSet.Insert("color", Color::BLUE);
2387   strikethroughMapSet.Insert("height", 2.0f);
2388   label.SetProperty(TextLabel::Property::TEXT, "Test1");
2389   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2390   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2391   application.GetScene().Add(label);
2392   application.SendNotification();
2393   application.Render();
2394   // Check if the number of renderers is 1.
2395   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2396
2397   label = TextLabel::New();
2398   label.SetProperty(TextLabel::Property::TEXT, "Test");
2399   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2400
2401   //Exeeding BufferHeight
2402   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2403   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2404   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2405
2406   application.GetScene().Add(label);
2407   application.SendNotification();
2408   application.Render();
2409
2410   strikethroughMapSet.Clear();
2411   strikethroughMapSet.Insert("enable", true);
2412   strikethroughMapSet.Insert("color", Color::BLUE);
2413   strikethroughMapSet.Insert("height", 2.0f);
2414   label.SetProperty(TextLabel::Property::TEXT, "Test2");
2415   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2416   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2417   application.GetScene().Add(label);
2418   application.SendNotification();
2419   application.Render();
2420   // Check if the number of renderers is 1.
2421   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2422
2423   END_TEST;
2424 }
2425
2426 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2427 {
2428   ToolkitTestApplication application;
2429   tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2430
2431   TextLabel label = TextLabel::New();
2432   label.SetProperty(TextLabel::Property::TEXT, "Test");
2433   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2434   //Exeeding BufferWidth
2435   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2436   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2437   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2438
2439   application.GetScene().Add(label);
2440   application.SendNotification();
2441   application.Render();
2442
2443   Property::Map underlineMapSet;
2444
2445   //SOLID
2446   underlineMapSet.Clear();
2447   underlineMapSet.Insert("enable", true);
2448   underlineMapSet.Insert("color", Color::BLUE);
2449   underlineMapSet.Insert("height", 1);
2450   underlineMapSet.Insert("type", Text::Underline::SOLID);
2451   underlineMapSet.Insert("dashWidth", 2);
2452   underlineMapSet.Insert("dashGap", 1);
2453   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2454   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2455
2456   application.GetScene().Add(label);
2457
2458   application.SendNotification();
2459   application.Render();
2460
2461   // Check if the number of renderers is 1.
2462   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2463
2464   //DASHED
2465   underlineMapSet.Clear();
2466   underlineMapSet.Insert("enable", true);
2467   underlineMapSet.Insert("color", Color::BLUE);
2468   underlineMapSet.Insert("height", 1);
2469   underlineMapSet.Insert("type", Text::Underline::DASHED);
2470   underlineMapSet.Insert("dashWidth", 2);
2471   underlineMapSet.Insert("dashGap", 1);
2472   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2473   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2474
2475   application.GetScene().Add(label);
2476
2477   application.SendNotification();
2478   application.Render();
2479
2480   // Check if the number of renderers is 1.
2481   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2482
2483   //DOUBLE
2484   underlineMapSet.Clear();
2485   underlineMapSet.Insert("enable", true);
2486   underlineMapSet.Insert("color", Color::BLUE);
2487   underlineMapSet.Insert("height", 1);
2488   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2489   underlineMapSet.Insert("dashWidth", 2);
2490   underlineMapSet.Insert("dashGap", 1);
2491   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2492   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2493
2494   application.GetScene().Add(label);
2495
2496   application.SendNotification();
2497   application.Render();
2498
2499   // Check if the number of renderers is 1.
2500   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2501
2502   END_TEST;
2503 }
2504
2505 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2506 {
2507   ToolkitTestApplication application;
2508   tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2509
2510   Vector2 size(300.0f, 100.0f);
2511
2512   Dali::Toolkit::DevelText::RendererParameters textParameters;
2513   textParameters.text              = "This is a sample text to get the last index.";
2514   textParameters.layout            = "multiLine";
2515   textParameters.fontSize          = 20.f;
2516   textParameters.textWidth         = 300u;
2517   textParameters.textHeight        = 100u;
2518   textParameters.ellipsisEnabled   = true;
2519   Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2520
2521   DALI_TEST_CHECK(!indexArray.Empty());
2522   DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2523
2524   END_TEST;
2525 }
2526
2527 int UtcDaliToolkitTextlabelFontSizeScale(void)
2528 {
2529   ToolkitTestApplication application;
2530   tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2531
2532   TextLabel label = TextLabel::New();
2533   label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2534   label.SetProperty(TextLabel::Property::TEXT, "Test");
2535   Vector3 nonScaledSize = label.GetNaturalSize();
2536
2537   TextLabel labelScaled = TextLabel::New();
2538   labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2539   labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2540   labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2541   Vector3 scaledSize = labelScaled.GetNaturalSize();
2542
2543   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2544
2545   label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2546   label.SetProperty(TextLabel::Property::TEXT, "Test");
2547   nonScaledSize = label.GetNaturalSize();
2548
2549   labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2550   labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2551   labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2552   scaledSize = labelScaled.GetNaturalSize();
2553
2554   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2555
2556   END_TEST;
2557 }
2558
2559 int UtcDaliToolkitTextlabelAnchorColor(void)
2560 {
2561   ToolkitTestApplication application;
2562   tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2563   TextLabel label = TextLabel::New();
2564   DALI_TEST_CHECK(label);
2565
2566   application.GetScene().Add(label);
2567
2568   // connect to the anchor clicked signal.
2569   ConnectionTracker* testTracker = new ConnectionTracker();
2570   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2571   bool anchorClickedSignal = false;
2572   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2573
2574   gAnchorClickedCallBackCalled = false;
2575   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2576   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2577   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2578   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2579   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2580
2581   // Check that anchor color can be properly set
2582   label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2583   DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2584
2585   label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2586   DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2587
2588   application.SendNotification();
2589   application.Render();
2590
2591   // Create a tap event to touch the text label.
2592   TestGenerateTap(application, 5.0f, 25.0f, 100);
2593   application.SendNotification();
2594   application.Render();
2595
2596   // Update clicked color
2597   label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2598   DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2599
2600   application.SendNotification();
2601   application.Render();
2602
2603   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2604   DALI_TEST_CHECK(anchorClickedSignal);
2605
2606   END_TEST;
2607 }
2608
2609 // Positive test for the anchorClicked signal.
2610 int UtcDaliToolkitTextlabelAnchorClicked(void)
2611 {
2612   ToolkitTestApplication application;
2613   tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2614   TextLabel label = TextLabel::New();
2615   DALI_TEST_CHECK(label);
2616
2617   application.GetScene().Add(label);
2618
2619   // connect to the anchor clicked signal.
2620   ConnectionTracker* testTracker = new ConnectionTracker();
2621   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2622   bool anchorClickedSignal = false;
2623   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2624
2625   gAnchorClickedCallBackCalled = false;
2626   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2627   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2628   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2629   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2630   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2631
2632   application.SendNotification();
2633   application.Render();
2634
2635   // Create a tap event to touch the text label.
2636   TestGenerateTap(application, 5.0f, 25.0f, 100);
2637   application.SendNotification();
2638   application.Render();
2639
2640   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2641   DALI_TEST_CHECK(anchorClickedSignal);
2642
2643   // reset
2644   gAnchorClickedCallBackCalled = false;
2645   anchorClickedSignal          = false;
2646   label.SetProperty(TextLabel::Property::TEXT, "");
2647   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2648
2649   application.SendNotification();
2650   application.Render();
2651
2652   // sets anchor text
2653   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2654   label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2655   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2656   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2657   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2658
2659   application.SendNotification();
2660   application.Render();
2661
2662   // Create a tap event to touch the text label.
2663   TestGenerateTap(application, 5.0f, 25.0f, 200);
2664   application.SendNotification();
2665   application.Render();
2666
2667   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2668   DALI_TEST_CHECK(anchorClickedSignal);
2669
2670   gAnchorClickedCallBackNotCalled = true;
2671   // Tap the outside of anchor, callback should not be called.
2672   TestGenerateTap(application, 150.f, 100.f, 300);
2673   application.SendNotification();
2674   application.Render();
2675
2676   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2677
2678   END_TEST;
2679 }
2680
2681 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2682 {
2683   ToolkitTestApplication application;
2684   tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2685
2686   //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2687
2688   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2689   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2690   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2691
2692   // Create a text editor
2693   TextLabel textLabel = TextLabel::New();
2694   //Set size to avoid automatic eliding
2695   textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2696   //Set very large font-size using point-size
2697   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2698   //Specify font-family
2699   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2700   //Set text to check if appear or not
2701   textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2702
2703   application.GetScene().Add(textLabel);
2704
2705   application.SendNotification();
2706   application.Render();
2707   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2708   Vector3 naturalSize = textLabel.GetNaturalSize();
2709
2710   DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2711   DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2712
2713   END_TEST;
2714 }
2715
2716 int UtcDaliTextLabelHyphenWrapMode(void)
2717 {
2718   ToolkitTestApplication application;
2719   tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2720
2721   int       lineCount = 0;
2722   TextLabel label     = TextLabel::New();
2723   label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2724   label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2725   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2726   application.GetScene().Add(label);
2727   application.SendNotification();
2728   application.Render();
2729
2730   label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2731   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2732   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2733
2734   application.SendNotification();
2735   application.Render();
2736
2737   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2738   /*
2739     text will be :
2740     Hi Exp-
2741     erimen
2742   */
2743   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2744
2745   label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2746   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2747   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2748
2749   application.SendNotification();
2750   application.Render();
2751
2752   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2753   /*
2754     text will be :
2755     Hi
2756     Experi-
2757     men
2758   */
2759   DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2760
2761   END_TEST;
2762 }
2763
2764 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2765 {
2766   ToolkitTestApplication application;
2767
2768   tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2769
2770   int lineCountBefore = 0;
2771   int lineCountAfter  = 0;
2772
2773   // Create a text editor
2774   TextLabel textLabel = TextLabel::New();
2775   //Set very large font-size using point-size
2776   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2777   //Specify font-family
2778   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2779   //Specify size
2780   textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2781   //Set text longer than width of textLabel
2782   textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2783   //Set line wrap mode Character
2784   textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2785   textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2786
2787   application.GetScene().Add(textLabel);
2788
2789   application.SendNotification();
2790   application.Render();
2791
2792   lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2793
2794   textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2795   lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2796
2797   // When the text changed, the Line-count should be updated according to new text.
2798   // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2799   DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2800   DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2801
2802   END_TEST;
2803 }
2804
2805 int utcDaliTextLabelGeometryRTL(void)
2806 {
2807   ToolkitTestApplication application;
2808   tet_infoline(" utcDaliTextLabelGeometryRTL");
2809
2810   TextLabel label = TextLabel::New();
2811   DALI_TEST_CHECK(label);
2812
2813   application.GetScene().Add(label);
2814
2815   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2816   label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2817   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2818   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2819   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2820   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2821   label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2822   // Avoid a crash when core load gl resources.
2823   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2824
2825   // Render and notify
2826   application.SendNotification();
2827   application.Render();
2828
2829   unsigned int expectedCount = 4;
2830   unsigned int startIndex    = 3;
2831   unsigned int endIndex      = 24;
2832
2833   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2834   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2835
2836   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2837   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2838
2839   Vector<Vector2> expectedSizes;
2840   Vector<Vector2> expectedPositions;
2841
2842   expectedPositions.PushBack(Vector2(25, 0));
2843   expectedSizes.PushBack(Vector2(34, 25));
2844
2845   expectedPositions.PushBack(Vector2(-1, 25));
2846   expectedSizes.PushBack(Vector2(53, 25));
2847
2848   expectedPositions.PushBack(Vector2(-1, 50));
2849   expectedSizes.PushBack(Vector2(60, 25));
2850
2851   expectedPositions.PushBack(Vector2(75, 75));
2852   expectedSizes.PushBack(Vector2(37, 25));
2853
2854   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2855
2856   END_TEST;
2857 }
2858
2859 int utcDaliTextLabelGeometryGlyphMiddle(void)
2860 {
2861   ToolkitTestApplication application;
2862   tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2863
2864   TextLabel label = TextLabel::New();
2865   DALI_TEST_CHECK(label);
2866
2867   application.GetScene().Add(label);
2868
2869   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2870   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2871   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2872   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2873   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2874   label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2875
2876   // Avoid a crash when core load gl resources.
2877   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2878
2879   // Render and notify
2880   application.SendNotification();
2881   application.Render();
2882
2883   unsigned int expectedCount = 1;
2884   unsigned int startIndex    = 1;
2885   unsigned int endIndex      = 13;
2886
2887   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2888   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2889
2890   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2891   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2892
2893   Vector<Vector2> expectedSizes;
2894   Vector<Vector2> expectedPositions;
2895
2896   expectedPositions.PushBack(Vector2(6, 0));
2897   expectedSizes.PushBack(Vector2(125, 25));
2898
2899   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2900
2901   END_TEST;
2902 }
2903
2904 int utcDaliTextLabelGeometryOneGlyph(void)
2905 {
2906   ToolkitTestApplication application;
2907   tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2908
2909   TextLabel label = TextLabel::New();
2910   DALI_TEST_CHECK(label);
2911
2912   application.GetScene().Add(label);
2913
2914   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2915   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2916   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2917   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2918   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2919   label.SetProperty(TextLabel::Property::TEXT, "H");
2920
2921   // Avoid a crash when core load gl resources.
2922   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2923
2924   // Render and notify
2925   application.SendNotification();
2926   application.Render();
2927
2928   unsigned int expectedCount = 1;
2929   unsigned int startIndex    = 0;
2930   unsigned int endIndex      = 0;
2931
2932   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2933   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2934
2935   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2936   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2937
2938   Vector<Vector2> expectedSizes;
2939   Vector<Vector2> expectedPositions;
2940
2941   expectedPositions.PushBack(Vector2(-2, 0));
2942   expectedSizes.PushBack(Vector2(16, 25));
2943
2944   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2945
2946   positionsList.Clear();
2947   sizeList.Clear();
2948
2949   startIndex = 2;
2950   endIndex   = 0;
2951
2952   positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2953   sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2954
2955   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2956
2957   END_TEST;
2958 }
2959
2960 int utcDaliTextLabelGeometryNullPtr(void)
2961 {
2962   ToolkitTestApplication application;
2963   tet_infoline("utcDaliTextLabelGeometryNullPtr");
2964
2965   TextLabel label = TextLabel::New();
2966   DALI_TEST_CHECK(label);
2967
2968   application.GetScene().Add(label);
2969
2970   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2971   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2972   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2973   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2974   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2975   label.SetProperty(TextLabel::Property::TEXT, "");
2976
2977   // Avoid a crash when core load gl resources.
2978   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2979
2980   unsigned int expectedCount = 0;
2981   unsigned int startIndex    = 0;
2982   unsigned int endIndex      = 0;
2983
2984   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2985   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2986
2987   // Render and notify
2988   application.SendNotification();
2989   application.Render();
2990
2991   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2992   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2993
2994   END_TEST;
2995 }
2996
2997 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2998 {
2999   ToolkitTestApplication application;
3000   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
3001   TextLabel textLabel = TextLabel::New();
3002
3003   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
3004   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3005
3006   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
3007   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3008   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3009
3010   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
3011   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3012   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3013
3014   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
3015   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3016   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3017
3018   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
3019   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
3020   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3021
3022   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
3023   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
3024   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3025
3026   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
3027   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
3028   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3029
3030   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3031   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
3032   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3033
3034   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3035   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
3036   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3037
3038   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3039   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
3040   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3041
3042   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3043   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
3044   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3045
3046   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3047   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
3048   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3049
3050   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3051   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
3052   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3053
3054   END_TEST;
3055 }
3056
3057 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
3058 {
3059   ToolkitTestApplication application;
3060   tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
3061
3062   TextLabel textLabel = TextLabel::New();
3063   textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
3064   textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
3065   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3066   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
3067
3068   application.GetScene().Add(textLabel);
3069   application.SendNotification();
3070   application.Render();
3071
3072   Property::Map strikethroughMapSet;
3073   Property::Map strikethroughMapGet;
3074
3075   strikethroughMapSet.Insert("enable", true);
3076   strikethroughMapSet.Insert("color", Color::RED);
3077   strikethroughMapSet.Insert("height", 2.0f);
3078
3079   // Check the strikethrough property
3080   textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
3081   strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
3082   textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
3083   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3084   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
3085
3086   // Render and notify
3087   application.SendNotification();
3088   application.Render();
3089
3090   strikethroughMapSet.Clear();
3091   strikethroughMapGet.Clear();
3092
3093   END_TEST;
3094 }
3095
3096 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
3097 {
3098   ToolkitTestApplication application;
3099   tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
3100
3101   TextLabel label = TextLabel::New();
3102   label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3103   label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3104   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3105   label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3106   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3107   label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3108   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3109
3110   TextLabel labelSingleLineParagraph = TextLabel::New();
3111   labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3112   labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3113   labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3114   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");
3115   labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3116   labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3117   labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3118
3119   TextLabel labelMultiLineParagraph = TextLabel::New();
3120   labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3121   labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3122   labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3123   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");
3124   labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3125   labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3126   labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3127
3128   application.GetScene().Add(label);
3129   application.GetScene().Add(labelSingleLineParagraph);
3130   application.GetScene().Add(labelMultiLineParagraph);
3131   application.SendNotification();
3132   application.Render();
3133
3134   Vector3 naturalSize               = label.GetNaturalSize();
3135   Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3136   Vector3 relativeMultiNaturalSize  = labelMultiLineParagraph.GetNaturalSize();
3137
3138   float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3139
3140   //no effect of relative line size for paragraph with single line
3141   DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3142
3143   DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3144
3145   END_TEST;
3146 }
3147
3148 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3149 {
3150   ToolkitTestApplication application;
3151   tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3152
3153   TextLabel label = TextLabel::New();
3154   label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3155   label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3156   label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3157
3158   application.GetScene().Add(label);
3159   application.SendNotification();
3160   application.Render();
3161
3162   Vector3 naturalSize = label.GetNaturalSize();
3163
3164   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3165
3166   application.SendNotification();
3167   application.Render();
3168
3169   Vector3 relativeNaturalSize = label.GetNaturalSize();
3170
3171   DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3172
3173   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3174
3175   application.SendNotification();
3176   application.Render();
3177
3178   relativeNaturalSize = label.GetNaturalSize();
3179
3180   DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3181   END_TEST;
3182 }
3183
3184 int UtcDaliTextLabelCharacterSpacing(void)
3185 {
3186   ToolkitTestApplication application;
3187   tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3188
3189   TextLabel textLabel = TextLabel::New();
3190
3191   textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3192
3193   application.GetScene().Add(textLabel);
3194   application.SendNotification();
3195   application.Render();
3196
3197   textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3198   textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3199   DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3200
3201   application.SendNotification();
3202   application.Render();
3203
3204   END_TEST;
3205 }
3206
3207 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3208 {
3209   ToolkitTestApplication application;
3210   tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3211
3212   TextLabel label = TextLabel::New();
3213
3214   float lineSpacing = -20.f;
3215
3216   label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3217   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3218   label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3219   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3220   label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3221
3222   application.GetScene().Add(label);
3223   application.SendNotification();
3224   application.Render();
3225
3226   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3227   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, 0, 123);
3228
3229   Vector2 lastLinePos  = positionsList[positionsList.Size() - 1];
3230   Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3231
3232   DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3233   DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3234
3235   application.SendNotification();
3236   application.Render();
3237
3238   END_TEST;
3239 }
3240
3241 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3242 {
3243   ToolkitTestApplication application;
3244   tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3245
3246   TextLabel label = TextLabel::New();
3247
3248   float lineSpacing = -20.f;
3249
3250   label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3251   label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3252   label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3253   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3254   label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3255   label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3256
3257   application.GetScene().Add(label);
3258   application.SendNotification();
3259   application.Render();
3260
3261   Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3262
3263   int lineCount = sizeList.Size();
3264   DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3265
3266   application.SendNotification();
3267   application.Render();
3268
3269   END_TEST;
3270 }
3271
3272 int UtcDaliToolkitTextlabelParagraphTag(void)
3273 {
3274   ToolkitTestApplication application;
3275   tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3276   TextLabel labelNewlineSeparator = TextLabel::New();
3277   TextLabel labelParagraphTag     = TextLabel::New();
3278   DALI_TEST_CHECK(labelNewlineSeparator);
3279   DALI_TEST_CHECK(labelParagraphTag);
3280
3281   application.GetScene().Add(labelNewlineSeparator);
3282   application.GetScene().Add(labelParagraphTag);
3283
3284   //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3285   labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3286   labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3287   labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3288   labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3289   labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3290   labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3291   labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3292
3293   labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3294   labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3295   labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3296   labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3297   labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3298   labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3299   labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3300
3301   application.SendNotification();
3302   application.Render();
3303
3304   Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3305   Vector3 textNaturalSizeParagraphTag     = labelParagraphTag.GetNaturalSize();
3306
3307   DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3308
3309   application.SendNotification();
3310   application.Render();
3311
3312   END_TEST;
3313 }
3314
3315 int utcDaliTextLabelGetTextBoundingRectangle(void)
3316 {
3317   ToolkitTestApplication application;
3318   tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3319
3320   TextLabel label = TextLabel::New();
3321   DALI_TEST_CHECK(label);
3322
3323   application.GetScene().Add(label);
3324
3325   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3326   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3327   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3328   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3329   label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3330
3331   // Avoid a crash when core load gl resources.
3332   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3333
3334   // Render and notify
3335   application.SendNotification();
3336   application.Render();
3337
3338   unsigned int startIndex    = 0;
3339   unsigned int endIndex      = 15;
3340
3341   Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3342   Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3343
3344   TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
3345
3346   END_TEST;
3347 }
3348
3349 int utcDaliTextLabelRemoveFrontInset(void)
3350 {
3351   ToolkitTestApplication application;
3352   tet_infoline(" utcDaliTextLabelRemoveFrontInset");
3353
3354   TextLabel label = TextLabel::New();
3355   DALI_TEST_CHECK(label);
3356
3357   application.GetScene().Add(label);
3358   application.SendNotification();
3359   application.Render();
3360
3361   DevelTextLabel::SetRemoveFrontInset(label, false);
3362   DALI_TEST_CHECK(!DevelTextLabel::IsRemoveFrontInset(label));
3363
3364   END_TEST;
3365 }
3366
3367 int utcDaliTextLabelRemoveBackInset(void)
3368 {
3369   ToolkitTestApplication application;
3370   tet_infoline(" utcDaliTextLabelRemoveBackInset");
3371
3372   TextLabel label = TextLabel::New();
3373   DALI_TEST_CHECK(label);
3374
3375   application.GetScene().Add(label);
3376   application.SendNotification();
3377   application.Render();
3378
3379   DevelTextLabel::SetRemoveBackInset(label, false);
3380   DALI_TEST_CHECK(!DevelTextLabel::IsRemoveBackInset(label));
3381
3382   END_TEST;
3383 }