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