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