[dali_2.3.6] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / utc-Dali-TextLabel.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <stdlib.h>
19 #include <unistd.h>
20 #include <iostream>
21
22 #include <dali-toolkit-test-suite-utils.h>
23 #include <dali-toolkit/dali-toolkit.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-label-devel.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-style-properties-devel.h>
26 #include <dali-toolkit/devel-api/text/bitmap-font.h>
27 #include <dali-toolkit/devel-api/text/rendering-backend.h>
28 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
29 #include <dali-toolkit/devel-api/text/text-utils-devel.h>
30 #include <dali/devel-api/adaptor-framework/image-loading.h>
31 #include <dali/devel-api/text-abstraction/bitmap-font.h>
32 #include <dali/devel-api/text-abstraction/font-client.h>
33 #include "test-text-geometry-utils.h"
34
35 using namespace Dali;
36 using namespace Toolkit;
37
38 void dali_textlabel_startup(void)
39 {
40   test_return_value = TET_UNDEF;
41 }
42
43 void dali_textlabel_cleanup(void)
44 {
45   test_return_value = TET_PASS;
46 }
47
48 namespace
49 {
50 const char* const PROPERTY_NAME_RENDERING_BACKEND        = "renderingBackend";
51 const char* const PROPERTY_NAME_TEXT                     = "text";
52 const char* const PROPERTY_NAME_FONT_FAMILY              = "fontFamily";
53 const char* const PROPERTY_NAME_FONT_STYLE               = "fontStyle";
54 const char* const PROPERTY_NAME_POINT_SIZE               = "pointSize";
55 const char* const PROPERTY_NAME_MULTI_LINE               = "multiLine";
56 const char* const PROPERTY_NAME_HORIZONTAL_ALIGNMENT     = "horizontalAlignment";
57 const char* const PROPERTY_NAME_VERTICAL_ALIGNMENT       = "verticalAlignment";
58 const char* const PROPERTY_NAME_TEXT_COLOR               = "textColor";
59 const char* const PROPERTY_NAME_ENABLE_MARKUP            = "enableMarkup";
60 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL       = "enableAutoScroll";
61 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED = "autoScrollSpeed";
62 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS = "autoScrollLoopCount";
63 const char* const PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP   = "autoScrollGap";
64
65 const char* const PROPERTY_NAME_LINE_SPACING  = "lineSpacing";
66 const char* const PROPERTY_NAME_UNDERLINE     = "underline";
67 const char* const PROPERTY_NAME_SHADOW        = "shadow";
68 const char* const PROPERTY_NAME_EMBOSS        = "emboss";
69 const char* const PROPERTY_NAME_OUTLINE       = "outline";
70 const char* const PROPERTY_NAME_BACKGROUND    = "textBackground";
71 const char* const PROPERTY_NAME_STRIKETHROUGH = "strikethrough";
72
73 const char* const PROPERTY_NAME_PIXEL_SIZE             = "pixelSize";
74 const char* const PROPERTY_NAME_ELLIPSIS               = "ellipsis";
75 const char* const PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY = "autoScrollLoopDelay";
76 const char* const PROPERTY_NAME_FONT_SIZE_SCALE        = "fontSizeScale";
77 const char* const PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE = "enableFontSizeScale";
78
79 const char* const PROPERTY_NAME_ELLIPSIS_POSITION    = "ellipsisPosition";
80 const char* const PROPERTY_NAME_ANCHOR_COLOR         = "anchorColor";
81 const char* const PROPERTY_NAME_ANCHOR_CLICKED_COLOR = "anchorClickedColor";
82
83 const 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 UtcDaliToolkitTextlabelFastTextFitStressTest(void)
2093 {
2094   ToolkitTestApplication application;
2095   tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
2096   TextLabel label = TextLabel::New();
2097   label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2098   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2099
2100   // connect to the text git changed signal.
2101   ConnectionTracker* testTracker = new ConnectionTracker();
2102   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2103   bool textFitChangedSignal = false;
2104   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2105   gTextFitChangedCallBackCalled = false;
2106
2107   application.GetScene().Add(label);
2108
2109   // check text label width at range [100, 299]
2110   for(int i=100; i<300; i++)
2111   {
2112     Vector2   size((float)i, 200.f);
2113     label.SetProperty(Actor::Property::SIZE, size);
2114
2115     // check point size with veryvery big range
2116     Property::Map textFitMapSet;
2117     textFitMapSet["enable"]       = true;
2118     textFitMapSet["minSize"]      = 10.f;
2119     textFitMapSet["maxSize"]      = 10000.f;
2120     textFitMapSet["stepSize"]     = -1.0f;
2121     textFitMapSet["fontSizeType"] = "pointSize";
2122
2123     label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2124
2125     application.SendNotification();
2126     application.Render();
2127   }
2128
2129   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2130   DALI_TEST_CHECK(textFitChangedSignal);
2131
2132   END_TEST;
2133 }
2134
2135 int UtcDaliToolkitTextlabelTextFitMultiLine(void)
2136 {
2137   ToolkitTestApplication application;
2138   tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
2139   TextLabel label = TextLabel::New();
2140   Vector2   size(500.0f, 100.0f);
2141   label.SetProperty(Actor::Property::SIZE, size);
2142   label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
2143   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2144
2145   // connect to the text git changed signal.
2146   ConnectionTracker* testTracker = new ConnectionTracker();
2147   DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2148   bool textFitChangedSignal = false;
2149   label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2150   gTextFitChangedCallBackCalled = false;
2151
2152   Property::Map textFitMapSet;
2153   textFitMapSet["enable"]       = true;
2154   textFitMapSet["minSize"]      = 10.f;
2155   textFitMapSet["maxSize"]      = 100.f;
2156   textFitMapSet["stepSize"]     = -1.0f;
2157   textFitMapSet["fontSizeType"] = "pointSize";
2158
2159   label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2160   label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2161
2162   application.GetScene().Add(label);
2163
2164   application.SendNotification();
2165   application.Render();
2166
2167   float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
2168   DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
2169
2170   DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2171   DALI_TEST_CHECK(textFitChangedSignal);
2172
2173   END_TEST;
2174 }
2175
2176 int UtcDaliToolkitTextlabelTextFitArray(void)
2177 {
2178   ToolkitTestApplication application;
2179   tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2180   TextLabel label = TextLabel::New();
2181   Vector2   size(300.0f, 80.0f);
2182   label.SetProperty(Actor::Property::SIZE, size);
2183   label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2184   label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2185   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2186   application.GetScene().Add(label);
2187
2188   // make sorted options.
2189   std::vector<DevelTextLabel::FitOption> fitOptions;
2190   fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2191   fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2192   fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2193   fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2194   fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2195   fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2196   fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2197
2198   DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2199
2200   application.SendNotification();
2201   application.Render();
2202
2203   bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2204   DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2205
2206   std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2207   size_t numberOfFitOptions = getFitOptions.size();
2208   DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2209
2210   const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2211   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2212
2213   std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2214   DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2215
2216   application.SendNotification();
2217   application.Render();
2218
2219   enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2220   DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2221
2222   const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2223   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2224
2225   // make unsorted options.
2226   std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2227   unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2228   unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2229   unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2230   unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2231
2232   DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2233
2234   application.SendNotification();
2235   application.Render();
2236
2237   DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2238
2239   END_TEST;
2240 }
2241
2242 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2243 {
2244   ToolkitTestApplication application;
2245   tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2246
2247   DevelText::BitmapFontDescription fontDescription;
2248   fontDescription.name = "Digits";
2249   fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2250
2251   TextAbstraction::BitmapFont bitmapFont;
2252   DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2253
2254   TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2255   fontClient.GetFontId(bitmapFont);
2256
2257   TextLabel label = TextLabel::New();
2258   label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2259   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2260   label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2261   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2262   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2263
2264   Property::Map underlineMapSet;
2265   underlineMapSet.Clear();
2266   underlineMapSet.Insert("enable", true);
2267   underlineMapSet.Insert("color", Color::RED);
2268   underlineMapSet.Insert("height", 1);
2269   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2270   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2271
2272   Property::Map strikethroughMapSet;
2273   strikethroughMapSet.Clear();
2274   strikethroughMapSet.Insert("enable", true);
2275   strikethroughMapSet.Insert("color", Color::RED);
2276   strikethroughMapSet.Insert("height", 2.0f);
2277   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2278   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2279
2280   application.GetScene().Add(label);
2281
2282   application.SendNotification();
2283   application.Render();
2284
2285   const int maxTextureSize = Dali::GetMaxTextureSize();
2286   // Whether the rendered text is greater than maxTextureSize
2287   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2288
2289   // Check if the number of renderers is greater than 1.
2290   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2291
2292   //DASHED
2293   underlineMapSet.Clear();
2294   underlineMapSet.Insert("enable", false);
2295   underlineMapSet.Insert("color", Color::BLUE);
2296   underlineMapSet.Insert("height", 0);
2297   underlineMapSet.Insert("type", Text::Underline::DASHED);
2298   underlineMapSet.Insert("dashWidth", 2);
2299   underlineMapSet.Insert("dashGap", 1);
2300   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2301   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2302
2303   application.GetScene().Add(label);
2304
2305   application.SendNotification();
2306   application.Render();
2307
2308   // Whether the rendered text is greater than maxTextureSize
2309   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2310
2311   // Check if the number of renderers is greater than 1.
2312   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2313
2314   //DOUBLE
2315   underlineMapSet.Clear();
2316   underlineMapSet.Insert("enable", false);
2317   underlineMapSet.Insert("color", Color::BLUE);
2318   underlineMapSet.Insert("height", 0);
2319   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2320   underlineMapSet.Insert("dashWidth", 2);
2321   underlineMapSet.Insert("dashGap", 1);
2322   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2323   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2324
2325   application.GetScene().Add(label);
2326
2327   application.SendNotification();
2328   application.Render();
2329
2330   // Whether the rendered text is greater than maxTextureSize
2331   DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2332
2333   // Check if the number of renderers is greater than 1.
2334   DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2335
2336   // Coverage test for case of layoutSize is bigger than maxTextureSize
2337   float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2338   label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2339   application.SendNotification();
2340   application.Render();
2341
2342   END_TEST;
2343 }
2344
2345 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2346 {
2347   ToolkitTestApplication application;
2348   tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2349
2350   TextLabel label = TextLabel::New();
2351   label.SetProperty(TextLabel::Property::TEXT, "Test");
2352   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2353   //Exeeding BufferWidth
2354   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2355   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2356   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2357
2358   application.GetScene().Add(label);
2359   application.SendNotification();
2360   application.Render();
2361
2362   Property::Map strikethroughMapSet;
2363   strikethroughMapSet.Clear();
2364   strikethroughMapSet.Insert("enable", true);
2365   strikethroughMapSet.Insert("color", Color::BLUE);
2366   strikethroughMapSet.Insert("height", 2.0f);
2367   label.SetProperty(TextLabel::Property::TEXT, "Test1");
2368   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2369   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2370   application.GetScene().Add(label);
2371   application.SendNotification();
2372   application.Render();
2373   // Check if the number of renderers is 1.
2374   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2375
2376   label = TextLabel::New();
2377   label.SetProperty(TextLabel::Property::TEXT, "Test");
2378   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2379
2380   //Exeeding BufferHeight
2381   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2382   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2383   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2384
2385   application.GetScene().Add(label);
2386   application.SendNotification();
2387   application.Render();
2388
2389   strikethroughMapSet.Clear();
2390   strikethroughMapSet.Insert("enable", true);
2391   strikethroughMapSet.Insert("color", Color::BLUE);
2392   strikethroughMapSet.Insert("height", 2.0f);
2393   label.SetProperty(TextLabel::Property::TEXT, "Test2");
2394   label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2395   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2396   application.GetScene().Add(label);
2397   application.SendNotification();
2398   application.Render();
2399   // Check if the number of renderers is 1.
2400   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2401
2402   END_TEST;
2403 }
2404
2405 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2406 {
2407   ToolkitTestApplication application;
2408   tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2409
2410   TextLabel label = TextLabel::New();
2411   label.SetProperty(TextLabel::Property::TEXT, "Test");
2412   label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2413   //Exeeding BufferWidth
2414   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2415   label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2416   label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2417
2418   application.GetScene().Add(label);
2419   application.SendNotification();
2420   application.Render();
2421
2422   Property::Map underlineMapSet;
2423
2424   //SOLID
2425   underlineMapSet.Clear();
2426   underlineMapSet.Insert("enable", true);
2427   underlineMapSet.Insert("color", Color::BLUE);
2428   underlineMapSet.Insert("height", 1);
2429   underlineMapSet.Insert("type", Text::Underline::SOLID);
2430   underlineMapSet.Insert("dashWidth", 2);
2431   underlineMapSet.Insert("dashGap", 1);
2432   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2433   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2434
2435   application.GetScene().Add(label);
2436
2437   application.SendNotification();
2438   application.Render();
2439
2440   // Check if the number of renderers is 1.
2441   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2442
2443   //DASHED
2444   underlineMapSet.Clear();
2445   underlineMapSet.Insert("enable", true);
2446   underlineMapSet.Insert("color", Color::BLUE);
2447   underlineMapSet.Insert("height", 1);
2448   underlineMapSet.Insert("type", Text::Underline::DASHED);
2449   underlineMapSet.Insert("dashWidth", 2);
2450   underlineMapSet.Insert("dashGap", 1);
2451   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2452   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2453
2454   application.GetScene().Add(label);
2455
2456   application.SendNotification();
2457   application.Render();
2458
2459   // Check if the number of renderers is 1.
2460   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2461
2462   //DOUBLE
2463   underlineMapSet.Clear();
2464   underlineMapSet.Insert("enable", true);
2465   underlineMapSet.Insert("color", Color::BLUE);
2466   underlineMapSet.Insert("height", 1);
2467   underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2468   underlineMapSet.Insert("dashWidth", 2);
2469   underlineMapSet.Insert("dashGap", 1);
2470   label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2471   label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2472
2473   application.GetScene().Add(label);
2474
2475   application.SendNotification();
2476   application.Render();
2477
2478   // Check if the number of renderers is 1.
2479   DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2480
2481   END_TEST;
2482 }
2483
2484 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2485 {
2486   ToolkitTestApplication application;
2487   tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2488
2489   Vector2 size(300.0f, 100.0f);
2490
2491   Dali::Toolkit::DevelText::RendererParameters textParameters;
2492   textParameters.text              = "This is a sample text to get the last index.";
2493   textParameters.layout            = "multiLine";
2494   textParameters.fontSize          = 20.f;
2495   textParameters.textWidth         = 300u;
2496   textParameters.textHeight        = 100u;
2497   textParameters.ellipsisEnabled   = true;
2498   Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2499
2500   DALI_TEST_CHECK(!indexArray.Empty());
2501   DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2502
2503   END_TEST;
2504 }
2505
2506 int UtcDaliToolkitTextlabelFontSizeScale(void)
2507 {
2508   ToolkitTestApplication application;
2509   tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2510
2511   TextLabel label = TextLabel::New();
2512   label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2513   label.SetProperty(TextLabel::Property::TEXT, "Test");
2514   Vector3 nonScaledSize = label.GetNaturalSize();
2515
2516   TextLabel labelScaled = TextLabel::New();
2517   labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2518   labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2519   labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2520   Vector3 scaledSize = labelScaled.GetNaturalSize();
2521
2522   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2523
2524   label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2525   label.SetProperty(TextLabel::Property::TEXT, "Test");
2526   nonScaledSize = label.GetNaturalSize();
2527
2528   labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2529   labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2530   labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2531   scaledSize = labelScaled.GetNaturalSize();
2532
2533   DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2534
2535   END_TEST;
2536 }
2537
2538 int UtcDaliToolkitTextlabelAnchorColor(void)
2539 {
2540   ToolkitTestApplication application;
2541   tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2542   TextLabel label = TextLabel::New();
2543   DALI_TEST_CHECK(label);
2544
2545   application.GetScene().Add(label);
2546
2547   // connect to the anchor clicked signal.
2548   ConnectionTracker* testTracker = new ConnectionTracker();
2549   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2550   bool anchorClickedSignal = false;
2551   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2552
2553   gAnchorClickedCallBackCalled = false;
2554   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2555   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2556   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2557   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2558   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2559
2560   // Check that anchor color can be properly set
2561   label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2562   DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2563
2564   label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2565   DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2566
2567   application.SendNotification();
2568   application.Render();
2569
2570   // Create a tap event to touch the text label.
2571   TestGenerateTap(application, 5.0f, 25.0f, 100);
2572   application.SendNotification();
2573   application.Render();
2574
2575   // Update clicked color
2576   label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2577   DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2578
2579   application.SendNotification();
2580   application.Render();
2581
2582   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2583   DALI_TEST_CHECK(anchorClickedSignal);
2584
2585   END_TEST;
2586 }
2587
2588 // Positive test for the anchorClicked signal.
2589 int UtcDaliToolkitTextlabelAnchorClicked(void)
2590 {
2591   ToolkitTestApplication application;
2592   tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2593   TextLabel label = TextLabel::New();
2594   DALI_TEST_CHECK(label);
2595
2596   application.GetScene().Add(label);
2597
2598   // connect to the anchor clicked signal.
2599   ConnectionTracker* testTracker = new ConnectionTracker();
2600   DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2601   bool anchorClickedSignal = false;
2602   label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2603
2604   gAnchorClickedCallBackCalled = false;
2605   label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2606   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2607   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2608   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2609   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2610
2611   application.SendNotification();
2612   application.Render();
2613
2614   // Create a tap event to touch the text label.
2615   TestGenerateTap(application, 5.0f, 25.0f, 100);
2616   application.SendNotification();
2617   application.Render();
2618
2619   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2620   DALI_TEST_CHECK(anchorClickedSignal);
2621
2622   // reset
2623   gAnchorClickedCallBackCalled = false;
2624   anchorClickedSignal          = false;
2625   label.SetProperty(TextLabel::Property::TEXT, "");
2626   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2627
2628   application.SendNotification();
2629   application.Render();
2630
2631   // sets anchor text
2632   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2633   label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2634   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2635   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2636   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2637
2638   application.SendNotification();
2639   application.Render();
2640
2641   // Create a tap event to touch the text label.
2642   TestGenerateTap(application, 5.0f, 25.0f, 200);
2643   application.SendNotification();
2644   application.Render();
2645
2646   DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2647   DALI_TEST_CHECK(anchorClickedSignal);
2648
2649   gAnchorClickedCallBackNotCalled = true;
2650   // Tap the outside of anchor, callback should not be called.
2651   TestGenerateTap(application, 150.f, 100.f, 300);
2652   application.SendNotification();
2653   application.Render();
2654
2655   DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2656
2657   END_TEST;
2658 }
2659
2660 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2661 {
2662   ToolkitTestApplication application;
2663   tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2664
2665   //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2666
2667   // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2668   const uint32_t lessThanWidth  = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2669   const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2670
2671   // Create a text editor
2672   TextLabel textLabel = TextLabel::New();
2673   //Set size to avoid automatic eliding
2674   textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2675   //Set very large font-size using point-size
2676   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2677   //Specify font-family
2678   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2679   //Set text to check if appear or not
2680   textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2681
2682   application.GetScene().Add(textLabel);
2683
2684   application.SendNotification();
2685   application.Render();
2686   //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2687   Vector3 naturalSize = textLabel.GetNaturalSize();
2688
2689   DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2690   DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2691
2692   END_TEST;
2693 }
2694
2695 int UtcDaliTextLabelHyphenWrapMode(void)
2696 {
2697   ToolkitTestApplication application;
2698   tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2699
2700   int       lineCount = 0;
2701   TextLabel label     = TextLabel::New();
2702   label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2703   label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2704   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2705   application.GetScene().Add(label);
2706   application.SendNotification();
2707   application.Render();
2708
2709   label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2710   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2711   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2712
2713   application.SendNotification();
2714   application.Render();
2715
2716   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2717   /*
2718     text will be :
2719     Hi Exp-
2720     erimen
2721   */
2722   DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2723
2724   label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2725   label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2726   DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2727
2728   application.SendNotification();
2729   application.Render();
2730
2731   lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2732   /*
2733     text will be :
2734     Hi
2735     Experi-
2736     men
2737   */
2738   DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2739
2740   END_TEST;
2741 }
2742
2743 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2744 {
2745   ToolkitTestApplication application;
2746
2747   tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2748
2749   int lineCountBefore = 0;
2750   int lineCountAfter  = 0;
2751
2752   // Create a text editor
2753   TextLabel textLabel = TextLabel::New();
2754   //Set very large font-size using point-size
2755   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2756   //Specify font-family
2757   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2758   //Specify size
2759   textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2760   //Set text longer than width of textLabel
2761   textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2762   //Set line wrap mode Character
2763   textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2764   textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2765
2766   application.GetScene().Add(textLabel);
2767
2768   application.SendNotification();
2769   application.Render();
2770
2771   lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2772
2773   textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2774   lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2775
2776   // When the text changed, the Line-count should be updated according to new text.
2777   // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2778   DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2779   DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2780
2781   END_TEST;
2782 }
2783
2784 int utcDaliTextLabelGeometryRTL(void)
2785 {
2786   ToolkitTestApplication application;
2787   tet_infoline(" utcDaliTextLabelGeometryRTL");
2788
2789   TextLabel label = TextLabel::New();
2790   DALI_TEST_CHECK(label);
2791
2792   application.GetScene().Add(label);
2793
2794   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2795   label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2796   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2797   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2798   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2799   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2800   label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2801   // Avoid a crash when core load gl resources.
2802   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2803
2804   // Render and notify
2805   application.SendNotification();
2806   application.Render();
2807
2808   unsigned int expectedCount = 4;
2809   unsigned int startIndex    = 3;
2810   unsigned int endIndex      = 24;
2811
2812   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2813   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2814
2815   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2816   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2817
2818   Vector<Vector2> expectedSizes;
2819   Vector<Vector2> expectedPositions;
2820
2821   expectedPositions.PushBack(Vector2(25, 0));
2822   expectedSizes.PushBack(Vector2(34, 25));
2823
2824   expectedPositions.PushBack(Vector2(-1, 25));
2825   expectedSizes.PushBack(Vector2(53, 25));
2826
2827   expectedPositions.PushBack(Vector2(-1, 50));
2828   expectedSizes.PushBack(Vector2(60, 25));
2829
2830   expectedPositions.PushBack(Vector2(75, 75));
2831   expectedSizes.PushBack(Vector2(37, 25));
2832
2833   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2834
2835   END_TEST;
2836 }
2837
2838 int utcDaliTextLabelGeometryGlyphMiddle(void)
2839 {
2840   ToolkitTestApplication application;
2841   tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2842
2843   TextLabel label = TextLabel::New();
2844   DALI_TEST_CHECK(label);
2845
2846   application.GetScene().Add(label);
2847
2848   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2849   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2850   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2851   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2852   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2853   label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2854
2855   // Avoid a crash when core load gl resources.
2856   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2857
2858   // Render and notify
2859   application.SendNotification();
2860   application.Render();
2861
2862   unsigned int expectedCount = 1;
2863   unsigned int startIndex    = 1;
2864   unsigned int endIndex      = 13;
2865
2866   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2867   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2868
2869   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2870   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2871
2872   Vector<Vector2> expectedSizes;
2873   Vector<Vector2> expectedPositions;
2874
2875   expectedPositions.PushBack(Vector2(6, 0));
2876   expectedSizes.PushBack(Vector2(125, 25));
2877
2878   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2879
2880   END_TEST;
2881 }
2882
2883 int utcDaliTextLabelGeometryOneGlyph(void)
2884 {
2885   ToolkitTestApplication application;
2886   tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2887
2888   TextLabel label = TextLabel::New();
2889   DALI_TEST_CHECK(label);
2890
2891   application.GetScene().Add(label);
2892
2893   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2894   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2895   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2896   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2897   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2898   label.SetProperty(TextLabel::Property::TEXT, "H");
2899
2900   // Avoid a crash when core load gl resources.
2901   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2902
2903   // Render and notify
2904   application.SendNotification();
2905   application.Render();
2906
2907   unsigned int expectedCount = 1;
2908   unsigned int startIndex    = 0;
2909   unsigned int endIndex      = 0;
2910
2911   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2912   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2913
2914   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2915   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2916
2917   Vector<Vector2> expectedSizes;
2918   Vector<Vector2> expectedPositions;
2919
2920   expectedPositions.PushBack(Vector2(-2, 0));
2921   expectedSizes.PushBack(Vector2(16, 25));
2922
2923   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2924
2925   positionsList.Clear();
2926   sizeList.Clear();
2927
2928   startIndex = 2;
2929   endIndex   = 0;
2930
2931   positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2932   sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2933
2934   TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2935
2936   END_TEST;
2937 }
2938
2939 int utcDaliTextLabelGeometryNullPtr(void)
2940 {
2941   ToolkitTestApplication application;
2942   tet_infoline("utcDaliTextLabelGeometryNullPtr");
2943
2944   TextLabel label = TextLabel::New();
2945   DALI_TEST_CHECK(label);
2946
2947   application.GetScene().Add(label);
2948
2949   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2950   label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2951   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2952   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2953   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2954   label.SetProperty(TextLabel::Property::TEXT, "");
2955
2956   // Avoid a crash when core load gl resources.
2957   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2958
2959   unsigned int expectedCount = 0;
2960   unsigned int startIndex    = 0;
2961   unsigned int endIndex      = 0;
2962
2963   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2964   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2965
2966   // Render and notify
2967   application.SendNotification();
2968   application.Render();
2969
2970   DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2971   DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2972
2973   END_TEST;
2974 }
2975
2976 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2977 {
2978   ToolkitTestApplication application;
2979   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2980   TextLabel textLabel = TextLabel::New();
2981
2982   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2983   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2984
2985   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2986   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2987   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2988
2989   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2990   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2991   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2992
2993   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2994   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2995   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2996
2997   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2998   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2999   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3000
3001   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
3002   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
3003   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3004
3005   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
3006   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
3007   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3008
3009   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3010   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
3011   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3012
3013   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3014   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
3015   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3016
3017   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3018   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
3019   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3020
3021   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3022   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
3023   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3024
3025   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3026   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
3027   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3028
3029   tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3030   textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
3031   DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3032
3033   END_TEST;
3034 }
3035
3036 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
3037 {
3038   ToolkitTestApplication application;
3039   tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
3040
3041   TextLabel textLabel = TextLabel::New();
3042   textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
3043   textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
3044   textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3045   textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
3046
3047   application.GetScene().Add(textLabel);
3048   application.SendNotification();
3049   application.Render();
3050
3051   Property::Map strikethroughMapSet;
3052   Property::Map strikethroughMapGet;
3053
3054   strikethroughMapSet.Insert("enable", true);
3055   strikethroughMapSet.Insert("color", Color::RED);
3056   strikethroughMapSet.Insert("height", 2.0f);
3057
3058   // Check the strikethrough property
3059   textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
3060   strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
3061   textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
3062   DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3063   DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
3064
3065   // Render and notify
3066   application.SendNotification();
3067   application.Render();
3068
3069   strikethroughMapSet.Clear();
3070   strikethroughMapGet.Clear();
3071
3072   END_TEST;
3073 }
3074
3075 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
3076 {
3077   ToolkitTestApplication application;
3078   tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
3079
3080   TextLabel label = TextLabel::New();
3081   label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3082   label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3083   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3084   label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3085   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3086   label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3087   label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3088
3089   TextLabel labelSingleLineParagraph = TextLabel::New();
3090   labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3091   labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3092   labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3093   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");
3094   labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3095   labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3096   labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3097
3098   TextLabel labelMultiLineParagraph = TextLabel::New();
3099   labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3100   labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3101   labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3102   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");
3103   labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3104   labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3105   labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3106
3107   application.GetScene().Add(label);
3108   application.GetScene().Add(labelSingleLineParagraph);
3109   application.GetScene().Add(labelMultiLineParagraph);
3110   application.SendNotification();
3111   application.Render();
3112
3113   Vector3 naturalSize               = label.GetNaturalSize();
3114   Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3115   Vector3 relativeMultiNaturalSize  = labelMultiLineParagraph.GetNaturalSize();
3116
3117   float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3118
3119   //no effect of relative line size for paragraph with single line
3120   DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3121
3122   DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3123
3124   END_TEST;
3125 }
3126
3127 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3128 {
3129   ToolkitTestApplication application;
3130   tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3131
3132   TextLabel label = TextLabel::New();
3133   label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3134   label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3135   label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3136
3137   application.GetScene().Add(label);
3138   application.SendNotification();
3139   application.Render();
3140
3141   Vector3 naturalSize = label.GetNaturalSize();
3142
3143   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3144
3145   application.SendNotification();
3146   application.Render();
3147
3148   Vector3 relativeNaturalSize = label.GetNaturalSize();
3149
3150   DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3151
3152   label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3153
3154   application.SendNotification();
3155   application.Render();
3156
3157   relativeNaturalSize = label.GetNaturalSize();
3158
3159   DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3160   END_TEST;
3161 }
3162
3163 int UtcDaliTextLabelCharacterSpacing(void)
3164 {
3165   ToolkitTestApplication application;
3166   tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3167
3168   TextLabel textLabel = TextLabel::New();
3169
3170   textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3171
3172   application.GetScene().Add(textLabel);
3173   application.SendNotification();
3174   application.Render();
3175
3176   textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3177   textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3178   DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3179
3180   application.SendNotification();
3181   application.Render();
3182
3183   END_TEST;
3184 }
3185
3186 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3187 {
3188   ToolkitTestApplication application;
3189   tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3190
3191   TextLabel label = TextLabel::New();
3192
3193   float lineSpacing = -20.f;
3194
3195   label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3196   label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3197   label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3198   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3199   label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3200
3201   application.GetScene().Add(label);
3202   application.SendNotification();
3203   application.Render();
3204
3205   Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3206   Vector<Vector2> sizeList      = DevelTextLabel::GetTextSize(label, 0, 123);
3207
3208   Vector2 lastLinePos  = positionsList[positionsList.Size() - 1];
3209   Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3210
3211   DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3212   DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3213
3214   application.SendNotification();
3215   application.Render();
3216
3217   END_TEST;
3218 }
3219
3220 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3221 {
3222   ToolkitTestApplication application;
3223   tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3224
3225   TextLabel label = TextLabel::New();
3226
3227   float lineSpacing = -20.f;
3228
3229   label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3230   label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3231   label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3232   label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3233   label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3234   label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3235
3236   application.GetScene().Add(label);
3237   application.SendNotification();
3238   application.Render();
3239
3240   Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3241
3242   int lineCount = sizeList.Size();
3243   DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3244
3245   application.SendNotification();
3246   application.Render();
3247
3248   END_TEST;
3249 }
3250
3251 int UtcDaliToolkitTextlabelParagraphTag(void)
3252 {
3253   ToolkitTestApplication application;
3254   tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3255   TextLabel labelNewlineSeparator = TextLabel::New();
3256   TextLabel labelParagraphTag     = TextLabel::New();
3257   DALI_TEST_CHECK(labelNewlineSeparator);
3258   DALI_TEST_CHECK(labelParagraphTag);
3259
3260   application.GetScene().Add(labelNewlineSeparator);
3261   application.GetScene().Add(labelParagraphTag);
3262
3263   //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3264   labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3265   labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3266   labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3267   labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3268   labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3269   labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3270   labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3271
3272   labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3273   labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3274   labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3275   labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3276   labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3277   labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3278   labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3279
3280   application.SendNotification();
3281   application.Render();
3282
3283   Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3284   Vector3 textNaturalSizeParagraphTag     = labelParagraphTag.GetNaturalSize();
3285
3286   DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3287
3288   application.SendNotification();
3289   application.Render();
3290
3291   END_TEST;
3292 }
3293
3294 int utcDaliTextLabelGetTextBoundingRectangle(void)
3295 {
3296   ToolkitTestApplication application;
3297   tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3298
3299   TextLabel label = TextLabel::New();
3300   DALI_TEST_CHECK(label);
3301
3302   application.GetScene().Add(label);
3303
3304   label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3305   label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3306   label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3307   label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3308   label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3309
3310   // Avoid a crash when core load gl resources.
3311   application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3312
3313   // Render and notify
3314   application.SendNotification();
3315   application.Render();
3316
3317   unsigned int startIndex    = 0;
3318   unsigned int endIndex      = 15;
3319
3320   Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3321   Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3322
3323   TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
3324
3325   END_TEST;
3326 }