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