2 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
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"
36 using namespace Toolkit;
38 void dali_textlabel_startup(void)
40 test_return_value = TET_UNDEF;
43 void dali_textlabel_cleanup(void)
45 test_return_value = TET_PASS;
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";
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";
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";
79 const char* const PROPERTY_NAME_ELLIPSIS_POSITION = "ellipsisPosition";
80 const char* const PROPERTY_NAME_ANCHOR_COLOR = "anchorColor";
81 const char* const PROPERTY_NAME_ANCHOR_CLICKED_COLOR = "anchorClickedColor";
83 const char* const PROPERTY_NAME_REMOVE_FRONT_INSET = "removeFrontInset";
84 const char* const PROPERTY_NAME_REMOVE_BACK_INSET = "removeBackInset";
85 const char* const PROPERTY_NAME_REMOVE_CUTOUT = "cutout";
87 const std::string DEFAULT_FONT_DIR("/resources/fonts");
88 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
90 static bool gAnchorClickedCallBackCalled;
91 static bool gAnchorClickedCallBackNotCalled;
93 static bool gTextFitChangedCallBackCalled;
95 struct CallbackFunctor
97 CallbackFunctor(bool* callbackFlag)
98 : mCallbackFlag(callbackFlag)
104 *mCallbackFlag = true;
109 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
111 tet_infoline(" TestAnchorClickedCallback");
113 gAnchorClickedCallBackNotCalled = false;
115 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
117 gAnchorClickedCallBackCalled = true;
121 static void TestTextFitChangedCallback(TextLabel control)
123 tet_infoline(" TestTextFitChangedCallback");
124 gTextFitChangedCallBackCalled = true;
127 bool DaliTestCheckMaps(const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>())
129 const Property::Map::SizeType size = mapGet.Count();
131 if(size == mapSet.Count())
133 for(unsigned int index = 0u; index < size; ++index)
135 const KeyValuePair& valueGet = mapGet.GetKeyValue(index);
137 // Find the keys of the 'get' map
138 Property::Index indexKey = valueGet.first.indexKey;
139 std::string stringKey = valueGet.first.stringKey;
141 if(!indexConversionTable.empty())
143 if(stringKey.empty())
145 stringKey = indexConversionTable[indexKey];
148 if((indexKey == Property::INVALID_INDEX) && !stringKey.empty())
150 Property::Index index = 0u;
151 for(auto key : indexConversionTable)
163 const Property::Value* const valueSet = mapSet.Find(indexKey, stringKey);
165 if(nullptr != valueSet)
167 if((valueSet->GetType() == Dali::Property::STRING) && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
169 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
172 else if((valueSet->GetType() == Dali::Property::BOOLEAN) && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
174 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
177 else if((valueSet->GetType() == Dali::Property::INTEGER) && (valueGet.second.Get<int>() != valueSet->Get<int>()))
179 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
182 else if((valueSet->GetType() == Dali::Property::FLOAT) && (valueGet.second.Get<float>() != valueSet->Get<float>()))
184 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
187 else if((valueSet->GetType() == Dali::Property::VECTOR2) && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
189 Vector2 vector2Get = valueGet.second.Get<Vector2>();
190 Vector2 vector2Set = valueSet->Get<Vector2>();
191 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
194 else if((valueSet->GetType() == Dali::Property::VECTOR4) && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
196 Vector4 vector4Get = valueGet.second.Get<Vector4>();
197 Vector4 vector4Set = valueSet->Get<Vector4>();
198 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);
204 if(valueGet.first.type == Property::Key::INDEX)
206 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
210 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
222 int UtcDaliToolkitTextLabelConstructorP(void)
224 ToolkitTestApplication application;
225 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
227 DALI_TEST_CHECK(!textLabel);
231 int UtcDaliToolkitTextLabelNewP(void)
233 ToolkitTestApplication application;
234 tet_infoline(" UtcDaliToolkitTextLabelNewP");
235 TextLabel textLabel = TextLabel::New("Test Text");
236 DALI_TEST_CHECK(textLabel);
240 int UtcDaliToolkitTextLabelDownCastP(void)
242 ToolkitTestApplication application;
243 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
244 TextLabel textLabel1 = TextLabel::New();
245 BaseHandle object(textLabel1);
247 TextLabel textLabel2 = TextLabel::DownCast(object);
248 DALI_TEST_CHECK(textLabel2);
250 TextLabel textLabel3 = DownCast<TextLabel>(object);
251 DALI_TEST_CHECK(textLabel3);
255 int UtcDaliToolkitTextLabelDownCastN(void)
257 ToolkitTestApplication application;
258 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
259 BaseHandle uninitializedObject;
260 TextLabel textLabel1 = TextLabel::DownCast(uninitializedObject);
261 DALI_TEST_CHECK(!textLabel1);
263 TextLabel textLabel2 = DownCast<TextLabel>(uninitializedObject);
264 DALI_TEST_CHECK(!textLabel2);
268 int UtcDaliToolkitTextLabelCopyConstructorP(void)
270 ToolkitTestApplication application;
271 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
272 TextLabel textLabel = TextLabel::New();
273 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
275 TextLabel copy(textLabel);
276 DALI_TEST_CHECK(copy);
277 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
281 int UtcDaliTextLabelMoveConstructor(void)
283 ToolkitTestApplication application;
285 TextLabel textLabel = TextLabel::New();
286 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
287 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
289 TextLabel moved = std::move(textLabel);
290 DALI_TEST_CHECK(moved);
291 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
292 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
293 DALI_TEST_CHECK(!textLabel);
298 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
300 ToolkitTestApplication application;
301 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
302 TextLabel textLabel = TextLabel::New();
303 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
305 TextLabel copy = textLabel;
306 DALI_TEST_CHECK(copy);
307 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
311 int UtcDaliTextLabelMoveAssignment(void)
313 ToolkitTestApplication application;
315 TextLabel textLabel = TextLabel::New();
316 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
317 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
320 moved = std::move(textLabel);
321 DALI_TEST_CHECK(moved);
322 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
323 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
324 DALI_TEST_CHECK(!textLabel);
329 // Positive test case for a method
330 int UtcDaliToolkitTextLabelGetPropertyP(void)
332 ToolkitTestApplication application;
333 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
334 TextLabel label = TextLabel::New("Test Text");
335 DALI_TEST_CHECK(label);
337 // Check Property Indices are correct
338 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextLabel::Property::RENDERING_BACKEND);
339 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextLabel::Property::TEXT);
340 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextLabel::Property::FONT_FAMILY);
341 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextLabel::Property::FONT_STYLE);
342 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextLabel::Property::POINT_SIZE);
343 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_MULTI_LINE) == TextLabel::Property::MULTI_LINE);
344 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextLabel::Property::HORIZONTAL_ALIGNMENT);
345 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextLabel::Property::VERTICAL_ALIGNMENT);
346 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextLabel::Property::TEXT_COLOR);
347 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP);
348 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL) == TextLabel::Property::ENABLE_AUTO_SCROLL);
349 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED) == TextLabel::Property::AUTO_SCROLL_SPEED);
350 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT);
351 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP) == TextLabel::Property::AUTO_SCROLL_GAP);
352 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextLabel::Property::LINE_SPACING);
353 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextLabel::Property::UNDERLINE);
354 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextLabel::Property::SHADOW);
355 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextLabel::Property::EMBOSS);
356 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextLabel::Property::OUTLINE);
357 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextLabel::Property::BACKGROUND);
358 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextLabel::Property::PIXEL_SIZE);
359 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextLabel::Property::ELLIPSIS);
360 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY);
361 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextLabel::Property::FONT_SIZE_SCALE);
362 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE);
363 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS_POSITION) == DevelTextLabel::Property::ELLIPSIS_POSITION);
364 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextLabel::Property::STRIKETHROUGH);
365 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_COLOR) == DevelTextLabel::Property::ANCHOR_COLOR);
366 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_CLICKED_COLOR) == DevelTextLabel::Property::ANCHOR_CLICKED_COLOR);
367 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_FRONT_INSET) == DevelTextLabel::Property::REMOVE_FRONT_INSET);
368 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_BACK_INSET) == DevelTextLabel::Property::REMOVE_BACK_INSET);
369 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_REMOVE_CUTOUT) == DevelTextLabel::Property::CUTOUT);
374 int UtcDaliToolkitTextLabelSetPropertyP(void)
376 ToolkitTestApplication application;
377 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
378 TextLabel label = TextLabel::New();
379 DALI_TEST_CHECK(label);
381 application.GetScene().Add(label);
383 // Note - we can't check the defaults since the stylesheets are platform-specific
384 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
385 DALI_TEST_EQUALS((DevelText::RenderingType)label.GetProperty<int>(DevelTextLabel::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
387 // Check that text can be correctly reset
388 label.SetProperty(TextLabel::Property::TEXT, "Setting Text");
389 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
391 // Check font properties.
392 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Setting font family");
393 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
395 Property::Map fontStyleMapSet;
396 Property::Map fontStyleMapGet;
398 fontStyleMapSet.Insert("weight", "bold");
399 fontStyleMapSet.Insert("width", "condensed");
400 fontStyleMapSet.Insert("slant", "italic");
401 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
403 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
404 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
405 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
407 // Check the old font style format.
408 fontStyleMapSet.Clear();
409 fontStyleMapSet.Insert("weight", "thin");
410 fontStyleMapSet.Insert("width", "expanded");
411 fontStyleMapSet.Insert("slant", "oblique");
412 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
414 label.SetProperty(TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}");
415 std::string getFontStyle = label.GetProperty<std::string>(TextLabel::Property::FONT_STYLE);
416 DALI_TEST_EQUALS(getFontStyle, strFontStyle, TEST_LOCATION);
418 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
419 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
421 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f);
422 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
423 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f);
425 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, false);
426 DALI_TEST_EQUALS(label.GetProperty<bool>(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
427 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, true);
430 fontStyleMapSet.Clear();
431 fontStyleMapSet.Insert("weight", "normal");
432 fontStyleMapSet.Insert("slant", "oblique");
434 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
435 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
436 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
437 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
439 fontStyleMapSet.Clear();
440 fontStyleMapSet.Insert("slant", "roman");
442 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
443 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
444 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
446 // Replace 'roman' for 'normal'.
447 Property::Value* slantValue = fontStyleMapGet.Find("slant");
448 if(NULL != slantValue)
450 if("normal" == slantValue->Get<std::string>())
452 fontStyleMapGet["slant"] = "roman";
455 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
457 fontStyleMapSet.Clear();
459 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
460 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
461 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
462 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
465 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
466 DALI_TEST_EQUALS(label.GetProperty<bool>(TextLabel::Property::MULTI_LINE), true, TEST_LOCATION);
468 // Check that the Alignment properties can be correctly set
469 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
470 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::HORIZONTAL_ALIGNMENT), "CENTER", TEST_LOCATION);
471 label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
472 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
474 // Check that text color can be properly set
475 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
476 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Color::BLUE, TEST_LOCATION);
478 // Check that anchor color can be properly set
479 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
480 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
482 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
483 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
485 Property::Map strikethroughMapSet;
486 Property::Map strikethroughMapGet;
488 strikethroughMapSet.Insert("enable", false);
489 strikethroughMapSet.Insert("color", Color::BLUE);
490 strikethroughMapSet.Insert("height", 2.0f);
492 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
494 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
495 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
496 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
498 Property::Map underlineMapSet;
499 Property::Map underlineMapGet;
501 underlineMapSet.Insert("enable", false);
502 underlineMapSet.Insert("color", Color::BLUE);
503 underlineMapSet.Insert("height", 0);
504 underlineMapSet.Insert("type", Text::Underline::SOLID);
505 underlineMapSet.Insert("dashWidth", 2);
506 underlineMapSet.Insert("dashGap", 1);
508 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
510 application.SendNotification();
511 application.Render();
513 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
514 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
515 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
518 underlineMapSet.Clear();
519 underlineMapGet.Clear();
521 underlineMapSet.Insert("enable", false);
522 underlineMapSet.Insert("color", Color::BLUE);
523 underlineMapSet.Insert("height", 0);
524 underlineMapSet.Insert("type", Text::Underline::DASHED);
525 underlineMapSet.Insert("dashWidth", 2);
526 underlineMapSet.Insert("dashGap", 1);
528 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
530 application.SendNotification();
531 application.Render();
533 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
534 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
535 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
538 underlineMapSet.Clear();
539 underlineMapGet.Clear();
541 underlineMapSet.Insert("enable", false);
542 underlineMapSet.Insert("color", Color::BLUE);
543 underlineMapSet.Insert("height", 0);
544 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
545 underlineMapSet.Insert("dashWidth", 2);
546 underlineMapSet.Insert("dashGap", 1);
548 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
550 application.SendNotification();
551 application.Render();
553 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
554 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
555 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
557 TextLabel label2 = TextLabel::New("New text");
558 DALI_TEST_CHECK(label2);
559 DALI_TEST_EQUALS(label2.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("New text"), TEST_LOCATION);
561 // Check the enable markup property.
562 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
563 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
564 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
566 // Check the text property when markup is enabled
567 label.SetProperty(TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>");
568 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
570 // Check for incomplete marks.
571 label.SetProperty(TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>");
572 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
575 application.SendNotification();
576 application.Render();
580 tet_result(TET_FAIL);
583 // Check autoscroll properties
584 const int SCROLL_SPEED = 80;
585 const int SCROLL_LOOPS = 4;
586 const float SCROLL_GAP = 50.0f;
587 const float SCROLL_LOOP_DELAY = 0.3f;
588 const std::string STOP_IMMEDIATE = std::string("IMMEDIATE");
589 const std::string STOP_FINISH_LOOP = std::string("FINISH_LOOP");
591 label.SetProperty(TextLabel::Property::MULTI_LINE, false); // Autoscroll only supported in single line
592 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
593 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
594 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
595 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED);
596 DALI_TEST_EQUALS(SCROLL_SPEED, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_SPEED), TEST_LOCATION);
597 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS);
598 DALI_TEST_EQUALS(SCROLL_LOOPS, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT), TEST_LOCATION);
599 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP);
600 DALI_TEST_EQUALS(SCROLL_GAP, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_GAP), TEST_LOCATION);
601 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY);
602 DALI_TEST_EQUALS(SCROLL_LOOP_DELAY, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY), TEST_LOCATION);
604 //Check autoscroll stop type property
605 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
606 DALI_TEST_EQUALS(STOP_IMMEDIATE, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
608 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
609 DALI_TEST_EQUALS(STOP_FINISH_LOOP, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
611 // test natural size with multi-line and line spacing
613 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
614 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
615 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
616 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
617 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
619 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
620 // The height of the text when multi-line is enabled will be larger
621 DALI_TEST_CHECK(oneLineNaturalSize.width > multiLineNaturalSize.width);
622 DALI_TEST_CHECK(oneLineNaturalSize.height < multiLineNaturalSize.height);
624 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
625 // Everything else will remain the same
626 int lineSpacing = 20;
627 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
628 Vector3 expectedAfterLineSpacingApplied(multiLineNaturalSize);
629 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
630 DALI_TEST_EQUALS(expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION);
633 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
635 TextLabel label3 = TextLabel::New("Some text here end there end here");
636 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
637 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
638 Vector3 textNaturalSize = label3.GetNaturalSize();
639 int lineSpacing = 20;
640 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
641 Vector3 expectedNaturalSizeWithLineSpacing(textNaturalSize);
642 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
643 DALI_TEST_EQUALS(expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION);
645 // Check the line spacing property
646 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
647 label.SetProperty(TextLabel::Property::LINE_SPACING, 10.f);
648 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
650 // Check the strikethrough property
651 strikethroughMapSet.Clear();
652 strikethroughMapSet.Insert("enable", true);
653 strikethroughMapSet.Insert("color", Color::RED);
654 strikethroughMapSet.Insert("height", 2.0f);
656 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
658 application.SendNotification();
659 application.Render();
661 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
662 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
663 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
665 // Check the transparent strikethrough property for coverage.
666 strikethroughMapSet.Clear();
667 strikethroughMapSet.Insert("enable", true);
668 strikethroughMapSet.Insert("color", Color::TRANSPARENT);
669 strikethroughMapSet.Insert("height", 2.0f);
671 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
673 application.SendNotification();
674 application.Render();
676 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
677 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
678 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
680 strikethroughMapSet.Clear();
681 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::ENABLE, true);
682 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED);
683 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::HEIGHT, 2.0f);
685 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
687 application.SendNotification();
688 application.Render();
690 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
691 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
692 std::vector<std::string> strikethroughIndicesConversionTable = {"enable", "color", "height"};
693 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet, strikethroughIndicesConversionTable), true, TEST_LOCATION);
695 strikethroughMapSet.Clear();
697 Property::Map strikethroughDisabledMapGet;
698 strikethroughDisabledMapGet.Insert("enable", false);
699 strikethroughDisabledMapGet.Insert("color", Color::RED);
700 strikethroughDisabledMapGet.Insert("height", 2.0f);
702 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
704 application.SendNotification();
705 application.Render();
707 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
708 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughDisabledMapGet.Count(), TEST_LOCATION);
709 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughDisabledMapGet), true, TEST_LOCATION);
711 // Check the underline property
712 underlineMapSet.Clear();
713 underlineMapSet.Insert("enable", true);
714 underlineMapSet.Insert("color", Color::RED);
715 underlineMapSet.Insert("height", 1);
716 underlineMapSet.Insert("type", Text::Underline::SOLID);
717 underlineMapSet.Insert("dashWidth", 2);
718 underlineMapSet.Insert("dashGap", 1);
720 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
722 application.SendNotification();
723 application.Render();
725 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
726 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
727 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
729 underlineMapSet.Clear();
730 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
731 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
732 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
733 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
734 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
735 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
737 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
739 application.SendNotification();
740 application.Render();
742 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
743 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
744 std::vector<std::string> underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
745 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
747 underlineMapSet.Clear();
749 Property::Map underlineDisabledMapGet;
750 underlineDisabledMapGet.Insert("enable", false);
751 underlineDisabledMapGet.Insert("color", Color::GREEN);
752 underlineDisabledMapGet.Insert("height", 2);
753 underlineDisabledMapGet.Insert("type", Text::Underline::SOLID);
754 underlineDisabledMapGet.Insert("dashWidth", 2);
755 underlineDisabledMapGet.Insert("dashGap", 1);
757 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
759 application.SendNotification();
760 application.Render();
762 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
763 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
764 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
766 // Check the dashed underline property
767 underlineMapSet.Clear();
768 underlineMapSet.Insert("enable", true);
769 underlineMapSet.Insert("color", Color::RED);
770 underlineMapSet.Insert("height", 1);
771 underlineMapSet.Insert("type", Text::Underline::DASHED);
772 underlineMapSet.Insert("dashWidth", 2);
773 underlineMapSet.Insert("dashGap", 1);
775 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
777 application.SendNotification();
778 application.Render();
780 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
781 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
782 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
784 underlineMapSet.Clear();
785 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
786 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
787 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
788 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
789 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
790 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
792 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
794 application.SendNotification();
795 application.Render();
797 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
798 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
799 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
800 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
802 underlineMapSet.Clear();
804 underlineDisabledMapGet.Clear();
805 underlineDisabledMapGet.Insert("enable", false);
806 underlineDisabledMapGet.Insert("color", Color::GREEN);
807 underlineDisabledMapGet.Insert("height", 2);
808 underlineDisabledMapGet.Insert("type", Text::Underline::DASHED);
809 underlineDisabledMapGet.Insert("dashWidth", 2);
810 underlineDisabledMapGet.Insert("dashGap", 1);
812 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
814 application.SendNotification();
815 application.Render();
817 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
818 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
819 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
821 // Check the double underline property
822 underlineMapSet.Clear();
823 underlineMapSet.Insert("enable", true);
824 underlineMapSet.Insert("color", Color::RED);
825 underlineMapSet.Insert("height", 1);
826 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
827 underlineMapSet.Insert("dashWidth", 2);
828 underlineMapSet.Insert("dashGap", 1);
830 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
832 application.SendNotification();
833 application.Render();
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);
839 // Check the transparent double underline property for coverage.
840 underlineMapSet.Clear();
841 underlineMapSet.Insert("enable", true);
842 underlineMapSet.Insert("color", Color::TRANSPARENT);
843 underlineMapSet.Insert("height", 1);
844 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
845 underlineMapSet.Insert("dashWidth", 2);
846 underlineMapSet.Insert("dashGap", 1);
848 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
850 application.SendNotification();
851 application.Render();
853 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
854 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
855 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
857 underlineMapSet.Clear();
858 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
859 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
860 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
861 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DOUBLE);
862 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
863 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
865 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
867 application.SendNotification();
868 application.Render();
870 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
871 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
872 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
873 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
875 underlineMapSet.Clear();
877 underlineDisabledMapGet.Clear();
878 underlineDisabledMapGet.Insert("enable", false);
879 underlineDisabledMapGet.Insert("color", Color::GREEN);
880 underlineDisabledMapGet.Insert("height", 2);
881 underlineDisabledMapGet.Insert("type", Text::Underline::DOUBLE);
882 underlineDisabledMapGet.Insert("dashWidth", 2);
883 underlineDisabledMapGet.Insert("dashGap", 1);
885 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
887 application.SendNotification();
888 application.Render();
890 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
891 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
892 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
894 // Check the shadow property
896 Property::Map shadowMapSet;
897 Property::Map shadowMapGet;
899 shadowMapSet.Insert("color", Color::GREEN);
900 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
901 shadowMapSet.Insert("blurRadius", 5.0f);
903 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
905 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
906 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
907 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
909 shadowMapSet.Clear();
911 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
912 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0");
913 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
915 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
917 // Replace the offset (string) by a vector2
918 shadowMapSet.Clear();
919 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
920 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, Vector2(3.0, 3.0));
921 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
923 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
924 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
925 std::vector<std::string> shadowIndicesConversionTable = {"color", "offset", "blurRadius"};
926 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet, shadowIndicesConversionTable), true, TEST_LOCATION);
928 shadowMapSet.Clear();
929 Property::Map shadowDisabledMapGet;
930 shadowDisabledMapGet.Insert("color", Color::BLUE);
931 shadowDisabledMapGet.Insert("offset", Vector2(0.0f, 0.0f));
932 shadowDisabledMapGet.Insert("blurRadius", 3.0f);
934 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
936 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
937 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION);
938 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowDisabledMapGet), true, TEST_LOCATION);
940 // Check the emboss property
941 label.SetProperty(TextLabel::Property::EMBOSS, "Emboss properties");
942 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
944 // Check the outline property
946 // Test string type first
947 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
948 label.SetProperty(TextLabel::Property::OUTLINE, "Outline properties");
949 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
951 // Then test the property map type
952 Property::Map outlineMapSet;
953 Property::Map outlineMapGet;
955 outlineMapSet["color"] = Color::RED;
956 outlineMapSet["width"] = 2.0f;
957 outlineMapSet["offset"] = Vector2(2.0f, 2.0f);
958 outlineMapSet["blurRadius"] = 3.0f;
959 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
961 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
962 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
963 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
965 outlineMapSet.Clear();
966 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
967 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
968 outlineMapSet[Toolkit::DevelText::Outline::Property::OFFSET] = Vector2(3.0f, 3.0f);
969 outlineMapSet[Toolkit::DevelText::Outline::Property::BLUR_RADIUS] = 4.0f;
971 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
973 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
974 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
975 std::vector<std::string> outlineIndicesConversionTable = {"color", "width", "offset", "blurRadius"};
976 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
978 // Check the background property
979 Property::Map backgroundMapSet;
980 Property::Map backgroundMapGet;
982 backgroundMapSet["enable"] = true;
983 backgroundMapSet["color"] = Color::RED;
984 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
986 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
987 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
988 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
990 // Check the transparent background property for coverage
991 backgroundMapSet.Clear();
992 backgroundMapSet["enable"] = true;
993 backgroundMapSet["color"] = Color::TRANSPARENT;
994 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
996 application.SendNotification();
997 application.Render();
999 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
1000 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
1001 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
1003 backgroundMapSet.Clear();
1004 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
1005 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
1006 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
1008 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
1009 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
1010 std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
1011 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
1013 // Check the pixel size of font
1014 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
1015 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1017 // Check the ellipsis property
1018 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1019 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1020 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1022 // Check the layout direction property
1023 label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1024 DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1026 // Check the line size property
1027 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1028 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1029 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1031 application.SendNotification();
1032 application.Render();
1034 // Check Remove Front/Back Inset Property
1035 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1036 label.SetProperty(DevelTextLabel::Property::REMOVE_FRONT_INSET, false);
1037 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_FRONT_INSET));
1039 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1040 label.SetProperty(DevelTextLabel::Property::REMOVE_BACK_INSET, false);
1041 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::REMOVE_BACK_INSET));
1043 application.SendNotification();
1044 application.Render();
1046 // Check cutout Property
1047 DALI_TEST_CHECK(!label.GetProperty<bool>(DevelTextLabel::Property::CUTOUT));
1048 label.SetProperty(DevelTextLabel::Property::CUTOUT, true);
1049 DALI_TEST_CHECK(label.GetProperty<bool>(DevelTextLabel::Property::CUTOUT));
1051 application.SendNotification();
1052 application.Render();
1057 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1059 ToolkitTestApplication application;
1060 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1061 TextLabel label = TextLabel::New("Test Text");
1062 DALI_TEST_CHECK(label);
1064 // Avoid a crash when core load gl resources.
1065 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1067 application.GetScene().Add(label);
1069 // Turn on all the effects
1070 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1071 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1073 Property::Map underlineMap;
1074 underlineMap.Insert("enable", true);
1075 underlineMap.Insert("color", Color::RED);
1076 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1078 Property::Map shadowMap;
1079 shadowMap.Insert("color", Color::BLUE);
1080 shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1081 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1083 Property::Map strikethroughMap;
1084 strikethroughMap.Insert("enable", true);
1085 strikethroughMap.Insert("color", Color::GREEN);
1086 strikethroughMap.Insert("height", 2.0f);
1087 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1091 // Render some text with the shared atlas backend
1092 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1093 application.SendNotification();
1094 application.Render();
1098 tet_result(TET_FAIL);
1103 // Render some text with the shared atlas backend
1104 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1105 application.SendNotification();
1106 application.Render();
1110 tet_result(TET_FAIL);
1115 int UtcDaliToolkitTextLabelLanguagesP(void)
1117 ToolkitTestApplication application;
1118 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1119 TextLabel label = TextLabel::New();
1120 DALI_TEST_CHECK(label);
1122 application.GetScene().Add(label);
1124 const std::string scripts(
1125 " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1126 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1127 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1128 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1129 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1130 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1132 label.SetProperty(TextLabel::Property::TEXT, scripts);
1133 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1135 application.SendNotification();
1136 application.Render();
1141 int UtcDaliToolkitTextLabelEmojisP(void)
1143 ToolkitTestApplication application;
1144 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1145 TextLabel label = TextLabel::New();
1146 DALI_TEST_CHECK(label);
1148 application.GetScene().Add(label);
1150 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1152 char* pathNamePtr = get_current_dir_name();
1153 const std::string pathName(pathNamePtr);
1156 TextAbstraction::FontDescription fontDescription;
1157 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1158 fontDescription.family = "BreezeColorEmoji";
1159 fontDescription.width = TextAbstraction::FontWidth::NONE;
1160 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1161 fontDescription.slant = TextAbstraction::FontSlant::NONE;
1163 fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1165 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>";
1166 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1167 label.SetProperty(TextLabel::Property::TEXT, emojis);
1169 Property::Map shadowMap;
1170 shadowMap.Insert("color", "green");
1171 shadowMap.Insert("offset", "2 2");
1172 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1174 application.SendNotification();
1175 application.Render();
1177 // EMOJI + ZWJ + EMOJI case for coverage.
1178 const std::string emojiWithZWJ = "👩‍🔬";
1179 label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1181 application.SendNotification();
1182 application.Render();
1184 // EMOJI Sequences case for coverage.
1185 std::string emojiSequences =
1186 "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font
1187 "Text VS15 ☪︎\n" //text presentation sequence and selector
1188 "Color VS16 ☪️\n" //emoji presentation sequence and selector
1189 "Default ☪ \n" //default presentation
1190 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
1191 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
1192 "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ
1193 "LeftRightArrowText↔︎\n" // text presentation sequence and selector
1194 "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector
1195 "SouthKoreaFlag🇰🇷\n" // emoji flag sequence
1196 "JordanFlag🇯🇴\n" // emoji flag sequence
1197 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag
1198 "Runner 🏃‍➡️ \n"
1199 "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone
1200 "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag
1201 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
1202 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
1203 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
1204 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
1205 "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs
1206 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
1207 "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1208 "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1209 "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15
1210 "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16
1214 label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1215 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1216 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1217 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1219 application.SendNotification();
1220 application.Render();
1224 int UtcDaliToolkitTextlabelScrollingP(void)
1226 ToolkitTestApplication application;
1227 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1228 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1229 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
1231 DALI_TEST_CHECK(labelImmediate);
1232 DALI_TEST_CHECK(labelFinished);
1233 // Avoid a crash when core load gl resources.
1234 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1235 application.GetScene().Add(labelImmediate);
1236 // Turn on all the effects
1237 labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1238 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1239 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1240 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1241 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1243 application.GetScene().Add(labelFinished);
1244 // Turn on all the effects
1245 labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1246 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1247 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1248 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1249 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1253 // Render some text with the shared atlas backend
1254 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1255 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1257 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1258 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1260 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1261 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1262 application.SendNotification();
1263 application.Render();
1265 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1266 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1267 application.SendNotification();
1268 application.Render();
1272 tet_result(TET_FAIL);
1278 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1280 ToolkitTestApplication application;
1281 TextLabel labelShort = TextLabel::New("Some text to scroll");
1282 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!");
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);
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);
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();
1314 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1315 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1316 application.SendNotification();
1317 application.Render();
1321 tet_result(TET_FAIL);
1327 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1329 ToolkitTestApplication application;
1330 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1331 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
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, "CENTER");
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);
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, "CENTER");
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);
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();
1363 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1364 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1365 application.SendNotification();
1366 application.Render();
1370 tet_result(TET_FAIL);
1376 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1378 ToolkitTestApplication application;
1379 TextLabel labelShort = TextLabel::New("Some text to scroll");
1380 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!");
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);
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);
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();
1412 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1413 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1414 application.SendNotification();
1415 application.Render();
1419 tet_result(TET_FAIL);
1425 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1427 ToolkitTestApplication application;
1428 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1429 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1431 DALI_TEST_CHECK(labelShort);
1432 DALI_TEST_CHECK(labelLong);
1433 // Avoid a crash when core load gl resources.
1434 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1435 application.GetScene().Add(labelShort);
1436 // Turn on all the effects
1437 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1438 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1439 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1440 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1441 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1442 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1444 application.GetScene().Add(labelLong);
1445 // Turn on all the effects
1446 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1447 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1448 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1449 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1450 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1451 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1455 // Render some text with the shared atlas backend
1456 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1457 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1458 application.SendNotification();
1459 application.Render();
1461 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1462 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1463 application.SendNotification();
1464 application.Render();
1468 tet_result(TET_FAIL);
1474 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1476 ToolkitTestApplication application;
1477 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1478 TextLabel label = TextLabel::New("Some text to scroll");
1479 DALI_TEST_CHECK(label);
1480 // Avoid a crash when core load gl resources.
1481 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1482 application.GetScene().Add(label);
1483 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1484 // Turn on all the effects
1485 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1486 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1487 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1488 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1491 application.SendNotification();
1492 application.Render();
1494 unsigned int actorCount1 = label.GetChildCount();
1495 tet_printf("Initial actor count is(%d)\n", actorCount1);
1499 // Render some text with the shared atlas backend
1500 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1501 application.SendNotification();
1502 application.Render(2000);
1504 unsigned int actorCount1 = label.GetChildCount();
1505 tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1507 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1510 application.SendNotification();
1511 application.Render();
1513 unsigned int actorCount2 = label.GetChildCount();
1514 tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1516 DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1520 tet_result(TET_FAIL);
1526 int UtcDaliToolkitTextlabelScrollingN(void)
1528 ToolkitTestApplication application;
1529 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1531 TextLabel label = TextLabel::New("Some text to scroll");
1532 DALI_TEST_CHECK(label);
1534 application.GetScene().Add(label);
1536 // Avoid a crash when core load gl resources.
1537 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1539 // The text scrolling works only on single line text.
1540 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1542 // Turn on all the effects.
1543 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1544 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1545 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1547 // Enable the auto scrolling effect.
1548 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1550 // The auto scrolling shouldn't be enabled.
1551 const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1552 DALI_TEST_CHECK(!enabled);
1554 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1555 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
1556 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
1557 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1562 application.SendNotification();
1563 application.Render(1000);
1565 application.GetScene().Remove(label);
1566 application.SendNotification();
1567 application.Render();
1569 DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1571 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1572 application.GetScene().Add(label);
1574 application.SendNotification();
1575 application.Render();
1577 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1579 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
1580 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1582 application.SendNotification();
1583 application.Render();
1585 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1589 tet_result(TET_FAIL);
1595 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1597 ToolkitTestApplication application;
1598 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1600 TextLabel label = TextLabel::New("Some text to scroll");
1601 DALI_TEST_CHECK(label);
1603 application.GetScene().Add(label);
1605 // Avoid a crash when core load gl resources.
1606 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1608 // Turn on all the effects.
1609 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1610 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1611 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1615 // Enable the auto scrolling effect.
1616 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1617 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1619 // Disable the ellipsis
1620 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1623 application.SendNotification();
1624 application.Render();
1626 // Stop auto scrolling
1627 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1629 // Check the ellipsis property
1630 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1634 tet_result(TET_FAIL);
1640 int UtcDaliToolkitTextlabelEllipsis(void)
1642 ToolkitTestApplication application;
1643 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1645 TextLabel label = TextLabel::New("Hello world");
1646 DALI_TEST_CHECK(label);
1648 // Avoid a crash when core load gl resources.
1649 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1651 application.GetScene().Add(label);
1653 // Turn on all the effects
1654 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1655 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1656 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1661 application.SendNotification();
1662 application.Render();
1666 tet_result(TET_FAIL);
1669 label.SetProperty(TextLabel::Property::TEXT, "Hello world ");
1670 label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1671 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1676 application.SendNotification();
1677 application.Render();
1681 tet_result(TET_FAIL);
1684 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1685 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1686 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1691 application.SendNotification();
1692 application.Render();
1696 tet_result(TET_FAIL);
1702 int UtcDaliToolkitTextlabelTextWrapMode(void)
1704 ToolkitTestApplication application;
1705 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1709 TextLabel label = TextLabel::New();
1710 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1711 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1712 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1714 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1715 application.GetScene().Add(label);
1717 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1718 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1720 application.SendNotification();
1721 application.Render();
1723 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1724 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1726 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1727 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1729 application.SendNotification();
1730 application.Render();
1732 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1733 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1735 application.SendNotification();
1736 application.Render();
1738 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1739 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1741 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1742 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1744 application.SendNotification();
1745 application.Render();
1747 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1748 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1750 tet_infoline("Ensure invalid string does not change wrapping mode");
1751 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1752 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1757 int UtcDaliToolkitTextLabelColorComponents(void)
1759 ToolkitTestApplication application;
1761 TextLabel label = TextLabel::New();
1762 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1763 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1764 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1765 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1766 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1768 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1769 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1770 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1771 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1772 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1774 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1775 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1776 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1777 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1778 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1780 label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1781 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1782 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1784 // Test a transparent text - Rendering should be skipped.
1785 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1786 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1788 application.GetScene().Add(label);
1790 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1791 drawTrace.Enable(true);
1793 application.SendNotification();
1794 application.Render();
1796 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1798 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1802 application.SendNotification();
1803 application.Render();
1805 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1807 label.SetProperty(DevelTextLabel::Property::CUTOUT, true);
1811 application.SendNotification();
1812 application.Render();
1814 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // When cutout is enabled, should not be skipped
1816 label.SetProperty(DevelTextLabel::Property::CUTOUT, false);
1817 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1821 application.SendNotification();
1822 application.Render();
1824 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1829 int UtcDaliToolkitTextlabelTextStyle01(void)
1831 ToolkitTestApplication application;
1832 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1834 TextLabel label = TextLabel::New();
1835 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1836 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1837 label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1838 application.GetScene().Add(label);
1840 Property::Map outlineMapSet;
1841 Property::Map outlineMapGet;
1843 outlineMapSet["color"] = Color::BLUE;
1844 outlineMapSet["width"] = 2.0f;
1845 outlineMapSet["offset"] = "2 2";
1846 outlineMapSet["blurRadius"] = "3";
1847 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1849 application.SendNotification();
1850 application.Render();
1852 Property::Map shadowMapSet;
1853 shadowMapSet.Insert("color", "green");
1854 shadowMapSet.Insert("offset", "2 2");
1855 shadowMapSet.Insert("blurRadius", "3");
1856 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1858 outlineMapSet["color"] = Color::RED;
1859 outlineMapSet["width"] = 0.0f;
1860 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1862 application.SendNotification();
1863 application.Render();
1865 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1867 Property::Value* colorValue = outlineMapGet.Find("color");
1869 bool colorMatched(false);
1873 Property::Type valueType = colorValue->GetType();
1875 if(Property::STRING == valueType)
1877 std::string stringValue;
1878 colorValue->Get(stringValue);
1879 if(stringValue == "red")
1881 colorMatched = true;
1884 else if(Property::VECTOR4 == valueType)
1886 Vector4 colorVector4;
1887 colorValue->Get(colorVector4);
1888 if(colorVector4 == Color::RED)
1890 colorMatched = true;
1895 DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1900 int UtcDaliToolkitTextlabelMultiline(void)
1902 ToolkitTestApplication application;
1903 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1905 TextLabel label = TextLabel::New();
1906 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1907 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1908 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1909 application.GetScene().Add(label);
1911 application.SendNotification();
1912 application.Render();
1914 int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1915 DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1917 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1919 application.SendNotification();
1920 application.Render();
1922 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1923 DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1928 int UtcDaliToolkitTextlabelTextDirection(void)
1930 ToolkitTestApplication application;
1931 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1933 TextLabel label = TextLabel::New();
1934 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1936 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1937 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1938 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1939 application.GetScene().Add(label);
1942 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1945 label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1946 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1948 // Test RTL text starting with weak character
1949 label.SetProperty(TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1950 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1952 // Test RTL text string with emoji and weak character
1953 label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1954 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1959 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1961 ToolkitTestApplication application;
1962 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1964 TextLabel label = TextLabel::New();
1966 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1967 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1968 label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1969 label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1970 application.GetScene().Add(label);
1971 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1973 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1974 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1976 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1977 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1982 int UtcDaliToolkitTextLabelBitmapFont(void)
1984 ToolkitTestApplication application;
1985 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1987 DevelText::BitmapFontDescription fontDescription;
1988 fontDescription.name = "Digits";
1989 fontDescription.underlinePosition = 0.f;
1990 fontDescription.underlineThickness = 0.f;
1992 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1993 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1994 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1995 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1996 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1997 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1998 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1999 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
2000 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
2001 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
2002 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
2004 TextAbstraction::BitmapFont bitmapFont;
2005 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2007 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2008 fontClient.GetFontId(bitmapFont);
2010 TextLabel label = TextLabel::New();
2012 label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
2013 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2015 // 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.
2016 DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2018 application.GetScene().Add(label);
2020 application.SendNotification();
2021 application.Render();
2023 // The text has been rendered if the height of the text-label is the height of the line.
2024 DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
2029 int ConvertPointToPixel(float point)
2031 unsigned int horizontalDpi = 0u;
2032 unsigned int verticalDpi = 0u;
2033 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2034 fontClient.GetDpi(horizontalDpi, verticalDpi);
2036 return (point * 72.f) / static_cast<float>(horizontalDpi);
2039 int UtcDaliToolkitTextlabelTextFit(void)
2041 ToolkitTestApplication application;
2042 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
2043 TextLabel label = TextLabel::New();
2044 Vector2 size(460.0f, 100.0f);
2045 label.SetProperty(Actor::Property::SIZE, size);
2046 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2048 // connect to the text git changed signal.
2049 ConnectionTracker* testTracker = new ConnectionTracker();
2050 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2051 bool textFitChangedSignal = false;
2052 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2053 gTextFitChangedCallBackCalled = false;
2056 Property::Map textFitMapSet;
2057 textFitMapSet["enable"] = true;
2058 textFitMapSet["minSize"] = 10.f;
2059 textFitMapSet["maxSize"] = 100.f;
2060 textFitMapSet["stepSize"] = -1.f;
2061 textFitMapSet["fontSizeType"] = "pointSize";
2063 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2064 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2066 application.GetScene().Add(label);
2068 application.SendNotification();
2069 application.Render();
2071 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2072 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2074 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2075 DALI_TEST_CHECK(textFitChangedSignal);
2078 textFitMapSet.Clear();
2079 textFitMapSet["enable"] = true;
2080 textFitMapSet["minSize"] = ConvertPointToPixel(10.f);
2081 textFitMapSet["maxSize"] = ConvertPointToPixel(100.f);
2082 textFitMapSet["stepSize"] = ConvertPointToPixel(1.f);
2083 textFitMapSet["fontSizeType"] = "pixelSize";
2085 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2087 application.SendNotification();
2088 application.Render();
2090 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2095 int UtcDaliToolkitTextlabelTextFitStressTest(void)
2097 ToolkitTestApplication application;
2098 tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
2099 TextLabel label = TextLabel::New();
2100 Vector2 size(460.0f, 100.0f);
2101 label.SetProperty(Actor::Property::SIZE, size);
2102 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2104 // connect to the text git changed signal.
2105 ConnectionTracker* testTracker = new ConnectionTracker();
2106 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2107 bool textFitChangedSignal = false;
2108 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2109 gTextFitChangedCallBackCalled = false;
2111 // check point size with veryvery big range
2112 Property::Map textFitMapSet;
2113 textFitMapSet["enable"] = true;
2114 textFitMapSet["minSize"] = 10.f;
2115 textFitMapSet["maxSize"] = 10000.f;
2116 textFitMapSet["stepSize"] = -1.0f;
2117 textFitMapSet["fontSizeType"] = "pointSize";
2119 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2120 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2122 application.GetScene().Add(label);
2124 application.SendNotification();
2125 application.Render();
2127 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2128 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2130 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2131 DALI_TEST_CHECK(textFitChangedSignal);
2136 int UtcDaliToolkitTextlabelFastTextFitStressTest(void)
2138 ToolkitTestApplication application;
2139 tet_infoline(" UtcDaliToolkitTextlabelFastTextFitStressTest");
2140 TextLabel label = TextLabel::New();
2141 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2142 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2144 // connect to the text git changed signal.
2145 ConnectionTracker* testTracker = new ConnectionTracker();
2146 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2147 bool textFitChangedSignal = false;
2148 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2149 gTextFitChangedCallBackCalled = false;
2151 application.GetScene().Add(label);
2153 // check text label width at range [100, 299]
2154 for(int i=100; i<300; i++)
2156 Vector2 size((float)i, 200.f);
2157 label.SetProperty(Actor::Property::SIZE, size);
2159 // check point size with veryvery big range
2160 Property::Map textFitMapSet;
2161 textFitMapSet["enable"] = true;
2162 textFitMapSet["minSize"] = 10.f;
2163 textFitMapSet["maxSize"] = 10000.f;
2164 textFitMapSet["stepSize"] = -1.0f;
2165 textFitMapSet["fontSizeType"] = "pointSize";
2167 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2169 application.SendNotification();
2170 application.Render();
2173 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2174 DALI_TEST_CHECK(textFitChangedSignal);
2179 int UtcDaliToolkitTextlabelTextFitMultiLine(void)
2181 ToolkitTestApplication application;
2182 tet_infoline(" UtcDaliToolkitTextlabelTextFitMultiLine");
2183 TextLabel label = TextLabel::New();
2184 Vector2 size(500.0f, 100.0f);
2185 label.SetProperty(Actor::Property::SIZE, size);
2186 label.SetProperty(TextLabel::Property::TEXT, "Hello world\nHello world");
2187 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2189 // connect to the text git changed signal.
2190 ConnectionTracker* testTracker = new ConnectionTracker();
2191 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2192 bool textFitChangedSignal = false;
2193 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2194 gTextFitChangedCallBackCalled = false;
2196 Property::Map textFitMapSet;
2197 textFitMapSet["enable"] = true;
2198 textFitMapSet["minSize"] = 10.f;
2199 textFitMapSet["maxSize"] = 100.f;
2200 textFitMapSet["stepSize"] = -1.0f;
2201 textFitMapSet["fontSizeType"] = "pointSize";
2203 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2204 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2206 application.GetScene().Add(label);
2208 application.SendNotification();
2209 application.Render();
2211 float textFitFontSize = (label.GetProperty(Dali::Toolkit::DevelTextLabel::Property::TEXT_FIT).Get<Property::Map>())["fontSize"].Get<float>();
2212 DALI_TEST_EQUALS(textFitFontSize, 14.f, TEST_LOCATION);
2214 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2215 DALI_TEST_CHECK(textFitChangedSignal);
2220 int UtcDaliToolkitTextlabelTextFitArray(void)
2222 ToolkitTestApplication application;
2223 tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2224 TextLabel label = TextLabel::New();
2225 Vector2 size(300.0f, 80.0f);
2226 label.SetProperty(Actor::Property::SIZE, size);
2227 label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2228 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2229 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2230 application.GetScene().Add(label);
2232 // make sorted options.
2233 std::vector<DevelTextLabel::FitOption> fitOptions;
2234 fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2235 fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2236 fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2237 fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2238 fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2239 fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2240 fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2242 DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2244 application.SendNotification();
2245 application.Render();
2247 bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2248 DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2250 std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2251 size_t numberOfFitOptions = getFitOptions.size();
2252 DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2254 const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2255 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2257 std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2258 DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2260 application.SendNotification();
2261 application.Render();
2263 enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2264 DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2266 const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2267 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2269 // make unsorted options.
2270 std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2271 unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2272 unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2273 unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2274 unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2276 DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2278 application.SendNotification();
2279 application.Render();
2281 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2286 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2288 ToolkitTestApplication application;
2289 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2291 DevelText::BitmapFontDescription fontDescription;
2292 fontDescription.name = "Digits";
2293 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2295 TextAbstraction::BitmapFont bitmapFont;
2296 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2298 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2299 fontClient.GetFontId(bitmapFont);
2301 TextLabel label = TextLabel::New();
2302 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2303 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2304 label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2305 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2306 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2308 Property::Map underlineMapSet;
2309 underlineMapSet.Clear();
2310 underlineMapSet.Insert("enable", true);
2311 underlineMapSet.Insert("color", Color::RED);
2312 underlineMapSet.Insert("height", 1);
2313 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2314 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2316 Property::Map strikethroughMapSet;
2317 strikethroughMapSet.Clear();
2318 strikethroughMapSet.Insert("enable", true);
2319 strikethroughMapSet.Insert("color", Color::RED);
2320 strikethroughMapSet.Insert("height", 2.0f);
2321 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2322 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2324 application.GetScene().Add(label);
2326 application.SendNotification();
2327 application.Render();
2329 const int maxTextureSize = Dali::GetMaxTextureSize();
2330 // Whether the rendered text is greater than maxTextureSize
2331 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2333 // Check if the number of renderers is greater than 1.
2334 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2337 underlineMapSet.Clear();
2338 underlineMapSet.Insert("enable", false);
2339 underlineMapSet.Insert("color", Color::BLUE);
2340 underlineMapSet.Insert("height", 0);
2341 underlineMapSet.Insert("type", Text::Underline::DASHED);
2342 underlineMapSet.Insert("dashWidth", 2);
2343 underlineMapSet.Insert("dashGap", 1);
2344 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2345 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2347 application.GetScene().Add(label);
2349 application.SendNotification();
2350 application.Render();
2352 // Whether the rendered text is greater than maxTextureSize
2353 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2355 // Check if the number of renderers is greater than 1.
2356 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2359 underlineMapSet.Clear();
2360 underlineMapSet.Insert("enable", false);
2361 underlineMapSet.Insert("color", Color::BLUE);
2362 underlineMapSet.Insert("height", 0);
2363 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2364 underlineMapSet.Insert("dashWidth", 2);
2365 underlineMapSet.Insert("dashGap", 1);
2366 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2367 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2369 application.GetScene().Add(label);
2371 application.SendNotification();
2372 application.Render();
2374 // Whether the rendered text is greater than maxTextureSize
2375 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2377 // Check if the number of renderers is greater than 1.
2378 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2380 // Coverage test for case of layoutSize is bigger than maxTextureSize
2381 float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2382 label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2383 application.SendNotification();
2384 application.Render();
2389 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2391 ToolkitTestApplication application;
2392 tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2394 TextLabel label = TextLabel::New();
2395 label.SetProperty(TextLabel::Property::TEXT, "Test");
2396 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2397 //Exeeding BufferWidth
2398 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2399 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2400 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2402 application.GetScene().Add(label);
2403 application.SendNotification();
2404 application.Render();
2406 Property::Map strikethroughMapSet;
2407 strikethroughMapSet.Clear();
2408 strikethroughMapSet.Insert("enable", true);
2409 strikethroughMapSet.Insert("color", Color::BLUE);
2410 strikethroughMapSet.Insert("height", 2.0f);
2411 label.SetProperty(TextLabel::Property::TEXT, "Test1");
2412 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2413 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2414 application.GetScene().Add(label);
2415 application.SendNotification();
2416 application.Render();
2417 // Check if the number of renderers is 1.
2418 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2420 label = TextLabel::New();
2421 label.SetProperty(TextLabel::Property::TEXT, "Test");
2422 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2424 //Exeeding BufferHeight
2425 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2426 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2427 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2429 application.GetScene().Add(label);
2430 application.SendNotification();
2431 application.Render();
2433 strikethroughMapSet.Clear();
2434 strikethroughMapSet.Insert("enable", true);
2435 strikethroughMapSet.Insert("color", Color::BLUE);
2436 strikethroughMapSet.Insert("height", 2.0f);
2437 label.SetProperty(TextLabel::Property::TEXT, "Test2");
2438 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2439 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2440 application.GetScene().Add(label);
2441 application.SendNotification();
2442 application.Render();
2443 // Check if the number of renderers is 1.
2444 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2449 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2451 ToolkitTestApplication application;
2452 tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2454 TextLabel label = TextLabel::New();
2455 label.SetProperty(TextLabel::Property::TEXT, "Test");
2456 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2457 //Exeeding BufferWidth
2458 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2459 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2460 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2462 application.GetScene().Add(label);
2463 application.SendNotification();
2464 application.Render();
2466 Property::Map underlineMapSet;
2469 underlineMapSet.Clear();
2470 underlineMapSet.Insert("enable", true);
2471 underlineMapSet.Insert("color", Color::BLUE);
2472 underlineMapSet.Insert("height", 1);
2473 underlineMapSet.Insert("type", Text::Underline::SOLID);
2474 underlineMapSet.Insert("dashWidth", 2);
2475 underlineMapSet.Insert("dashGap", 1);
2476 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2477 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2479 application.GetScene().Add(label);
2481 application.SendNotification();
2482 application.Render();
2484 // Check if the number of renderers is 1.
2485 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2488 underlineMapSet.Clear();
2489 underlineMapSet.Insert("enable", true);
2490 underlineMapSet.Insert("color", Color::BLUE);
2491 underlineMapSet.Insert("height", 1);
2492 underlineMapSet.Insert("type", Text::Underline::DASHED);
2493 underlineMapSet.Insert("dashWidth", 2);
2494 underlineMapSet.Insert("dashGap", 1);
2495 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2496 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2498 application.GetScene().Add(label);
2500 application.SendNotification();
2501 application.Render();
2503 // Check if the number of renderers is 1.
2504 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2507 underlineMapSet.Clear();
2508 underlineMapSet.Insert("enable", true);
2509 underlineMapSet.Insert("color", Color::BLUE);
2510 underlineMapSet.Insert("height", 1);
2511 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2512 underlineMapSet.Insert("dashWidth", 2);
2513 underlineMapSet.Insert("dashGap", 1);
2514 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2515 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2517 application.GetScene().Add(label);
2519 application.SendNotification();
2520 application.Render();
2522 // Check if the number of renderers is 1.
2523 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2528 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2530 ToolkitTestApplication application;
2531 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2533 Vector2 size(300.0f, 100.0f);
2535 Dali::Toolkit::DevelText::RendererParameters textParameters;
2536 textParameters.text = "This is a sample text to get the last index.";
2537 textParameters.layout = "multiLine";
2538 textParameters.fontSize = 20.f;
2539 textParameters.textWidth = 300u;
2540 textParameters.textHeight = 100u;
2541 textParameters.ellipsisEnabled = true;
2542 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2544 DALI_TEST_CHECK(!indexArray.Empty());
2545 DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2550 int UtcDaliToolkitTextlabelFontSizeScale(void)
2552 ToolkitTestApplication application;
2553 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2555 TextLabel label = TextLabel::New();
2556 label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2557 label.SetProperty(TextLabel::Property::TEXT, "Test");
2558 Vector3 nonScaledSize = label.GetNaturalSize();
2560 TextLabel labelScaled = TextLabel::New();
2561 labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2562 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2563 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2564 Vector3 scaledSize = labelScaled.GetNaturalSize();
2566 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2568 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2569 label.SetProperty(TextLabel::Property::TEXT, "Test");
2570 nonScaledSize = label.GetNaturalSize();
2572 labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2573 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2574 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2575 scaledSize = labelScaled.GetNaturalSize();
2577 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2582 int UtcDaliToolkitTextlabelAnchorColor(void)
2584 ToolkitTestApplication application;
2585 tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2586 TextLabel label = TextLabel::New();
2587 DALI_TEST_CHECK(label);
2589 application.GetScene().Add(label);
2591 // connect to the anchor clicked signal.
2592 ConnectionTracker* testTracker = new ConnectionTracker();
2593 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2594 bool anchorClickedSignal = false;
2595 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2597 gAnchorClickedCallBackCalled = false;
2598 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2599 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2600 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2601 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2602 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2604 // Check that anchor color can be properly set
2605 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2606 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2608 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2609 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2611 application.SendNotification();
2612 application.Render();
2614 // Create a tap event to touch the text label.
2615 TestGenerateTap(application, 5.0f, 25.0f, 100);
2616 application.SendNotification();
2617 application.Render();
2619 // Update clicked color
2620 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2621 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2623 application.SendNotification();
2624 application.Render();
2626 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2627 DALI_TEST_CHECK(anchorClickedSignal);
2632 // Positive test for the anchorClicked signal.
2633 int UtcDaliToolkitTextlabelAnchorClicked(void)
2635 ToolkitTestApplication application;
2636 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2637 TextLabel label = TextLabel::New();
2638 DALI_TEST_CHECK(label);
2640 application.GetScene().Add(label);
2642 // connect to the anchor clicked signal.
2643 ConnectionTracker* testTracker = new ConnectionTracker();
2644 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2645 bool anchorClickedSignal = false;
2646 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2648 gAnchorClickedCallBackCalled = false;
2649 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2650 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2651 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2652 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2653 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2655 application.SendNotification();
2656 application.Render();
2658 // Create a tap event to touch the text label.
2659 TestGenerateTap(application, 5.0f, 25.0f, 100);
2660 application.SendNotification();
2661 application.Render();
2663 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2664 DALI_TEST_CHECK(anchorClickedSignal);
2667 gAnchorClickedCallBackCalled = false;
2668 anchorClickedSignal = false;
2669 label.SetProperty(TextLabel::Property::TEXT, "");
2670 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2672 application.SendNotification();
2673 application.Render();
2676 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2677 label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2678 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2679 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2680 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2682 application.SendNotification();
2683 application.Render();
2685 // Create a tap event to touch the text label.
2686 TestGenerateTap(application, 5.0f, 25.0f, 200);
2687 application.SendNotification();
2688 application.Render();
2690 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2691 DALI_TEST_CHECK(anchorClickedSignal);
2693 gAnchorClickedCallBackNotCalled = true;
2694 // Tap the outside of anchor, callback should not be called.
2695 TestGenerateTap(application, 150.f, 100.f, 300);
2696 application.SendNotification();
2697 application.Render();
2699 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2704 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2706 ToolkitTestApplication application;
2707 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2709 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2711 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2712 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2713 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2715 // Create a text editor
2716 TextLabel textLabel = TextLabel::New();
2717 //Set size to avoid automatic eliding
2718 textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2719 //Set very large font-size using point-size
2720 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2721 //Specify font-family
2722 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2723 //Set text to check if appear or not
2724 textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2726 application.GetScene().Add(textLabel);
2728 application.SendNotification();
2729 application.Render();
2730 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2731 Vector3 naturalSize = textLabel.GetNaturalSize();
2733 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2734 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2739 int UtcDaliTextLabelHyphenWrapMode(void)
2741 ToolkitTestApplication application;
2742 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2745 TextLabel label = TextLabel::New();
2746 label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2747 label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2748 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2749 application.GetScene().Add(label);
2750 application.SendNotification();
2751 application.Render();
2753 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2754 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2755 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2757 application.SendNotification();
2758 application.Render();
2760 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2766 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2768 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2769 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2770 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2772 application.SendNotification();
2773 application.Render();
2775 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2782 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2787 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2789 ToolkitTestApplication application;
2791 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2793 int lineCountBefore = 0;
2794 int lineCountAfter = 0;
2796 // Create a text editor
2797 TextLabel textLabel = TextLabel::New();
2798 //Set very large font-size using point-size
2799 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2800 //Specify font-family
2801 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2803 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2804 //Set text longer than width of textLabel
2805 textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2806 //Set line wrap mode Character
2807 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2808 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2810 application.GetScene().Add(textLabel);
2812 application.SendNotification();
2813 application.Render();
2815 lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2817 textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2818 lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2820 // When the text changed, the Line-count should be updated according to new text.
2821 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2822 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2823 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2828 int utcDaliTextLabelGeometryRTL(void)
2830 ToolkitTestApplication application;
2831 tet_infoline(" utcDaliTextLabelGeometryRTL");
2833 TextLabel label = TextLabel::New();
2834 DALI_TEST_CHECK(label);
2836 application.GetScene().Add(label);
2838 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2839 label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2840 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2841 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2842 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2843 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2844 label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2845 // Avoid a crash when core load gl resources.
2846 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2848 // Render and notify
2849 application.SendNotification();
2850 application.Render();
2852 unsigned int expectedCount = 4;
2853 unsigned int startIndex = 3;
2854 unsigned int endIndex = 24;
2856 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2857 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2859 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2860 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2862 Vector<Vector2> expectedSizes;
2863 Vector<Vector2> expectedPositions;
2865 expectedPositions.PushBack(Vector2(25, 0));
2866 expectedSizes.PushBack(Vector2(34, 25));
2868 expectedPositions.PushBack(Vector2(-1, 25));
2869 expectedSizes.PushBack(Vector2(53, 25));
2871 expectedPositions.PushBack(Vector2(-1, 50));
2872 expectedSizes.PushBack(Vector2(60, 25));
2874 expectedPositions.PushBack(Vector2(75, 75));
2875 expectedSizes.PushBack(Vector2(37, 25));
2877 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2882 int utcDaliTextLabelGeometryGlyphMiddle(void)
2884 ToolkitTestApplication application;
2885 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2887 TextLabel label = TextLabel::New();
2888 DALI_TEST_CHECK(label);
2890 application.GetScene().Add(label);
2892 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2893 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2894 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2895 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2896 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2897 label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2899 // Avoid a crash when core load gl resources.
2900 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2902 // Render and notify
2903 application.SendNotification();
2904 application.Render();
2906 unsigned int expectedCount = 1;
2907 unsigned int startIndex = 1;
2908 unsigned int endIndex = 13;
2910 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2911 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2913 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2914 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2916 Vector<Vector2> expectedSizes;
2917 Vector<Vector2> expectedPositions;
2919 expectedPositions.PushBack(Vector2(6, 0));
2920 expectedSizes.PushBack(Vector2(125, 25));
2922 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2927 int utcDaliTextLabelGeometryOneGlyph(void)
2929 ToolkitTestApplication application;
2930 tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2932 TextLabel label = TextLabel::New();
2933 DALI_TEST_CHECK(label);
2935 application.GetScene().Add(label);
2937 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2938 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2939 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2940 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2941 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2942 label.SetProperty(TextLabel::Property::TEXT, "H");
2944 // Avoid a crash when core load gl resources.
2945 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2947 // Render and notify
2948 application.SendNotification();
2949 application.Render();
2951 unsigned int expectedCount = 1;
2952 unsigned int startIndex = 0;
2953 unsigned int endIndex = 0;
2955 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2956 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2958 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2959 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2961 Vector<Vector2> expectedSizes;
2962 Vector<Vector2> expectedPositions;
2964 expectedPositions.PushBack(Vector2(-2, 0));
2965 expectedSizes.PushBack(Vector2(16, 25));
2967 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2969 positionsList.Clear();
2975 positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2976 sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2978 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2983 int utcDaliTextLabelGeometryNullPtr(void)
2985 ToolkitTestApplication application;
2986 tet_infoline("utcDaliTextLabelGeometryNullPtr");
2988 TextLabel label = TextLabel::New();
2989 DALI_TEST_CHECK(label);
2991 application.GetScene().Add(label);
2993 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2994 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2995 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2996 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2997 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2998 label.SetProperty(TextLabel::Property::TEXT, "");
3000 // Avoid a crash when core load gl resources.
3001 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3003 unsigned int expectedCount = 0;
3004 unsigned int startIndex = 0;
3005 unsigned int endIndex = 0;
3007 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
3008 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
3010 // Render and notify
3011 application.SendNotification();
3012 application.Render();
3014 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
3015 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
3020 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
3022 ToolkitTestApplication application;
3023 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
3024 TextLabel textLabel = TextLabel::New();
3026 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
3027 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3029 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
3030 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
3031 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3033 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
3034 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
3035 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3037 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
3038 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
3039 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3041 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
3042 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
3043 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3045 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
3046 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
3047 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3049 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
3050 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
3051 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3053 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
3054 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
3055 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3057 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
3058 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
3059 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3061 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
3062 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
3063 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3065 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
3066 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
3067 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
3069 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
3070 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
3071 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
3073 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
3074 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
3075 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
3080 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
3082 ToolkitTestApplication application;
3083 tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
3085 TextLabel textLabel = TextLabel::New();
3086 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
3087 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
3088 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3089 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
3091 application.GetScene().Add(textLabel);
3092 application.SendNotification();
3093 application.Render();
3095 Property::Map strikethroughMapSet;
3096 Property::Map strikethroughMapGet;
3098 strikethroughMapSet.Insert("enable", true);
3099 strikethroughMapSet.Insert("color", Color::RED);
3100 strikethroughMapSet.Insert("height", 2.0f);
3102 // Check the strikethrough property
3103 textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
3104 strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
3105 textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
3106 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
3107 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
3109 // Render and notify
3110 application.SendNotification();
3111 application.Render();
3113 strikethroughMapSet.Clear();
3114 strikethroughMapGet.Clear();
3119 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
3121 ToolkitTestApplication application;
3122 tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
3124 TextLabel label = TextLabel::New();
3125 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3126 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3127 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3128 label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3129 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3130 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3131 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3133 TextLabel labelSingleLineParagraph = TextLabel::New();
3134 labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3135 labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3136 labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3137 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");
3138 labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3139 labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3140 labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3142 TextLabel labelMultiLineParagraph = TextLabel::New();
3143 labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3144 labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3145 labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3146 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");
3147 labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3148 labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3149 labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3151 application.GetScene().Add(label);
3152 application.GetScene().Add(labelSingleLineParagraph);
3153 application.GetScene().Add(labelMultiLineParagraph);
3154 application.SendNotification();
3155 application.Render();
3157 Vector3 naturalSize = label.GetNaturalSize();
3158 Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3159 Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize();
3161 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3163 //no effect of relative line size for paragraph with single line
3164 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3166 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3171 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3173 ToolkitTestApplication application;
3174 tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3176 TextLabel label = TextLabel::New();
3177 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3178 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3179 label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3181 application.GetScene().Add(label);
3182 application.SendNotification();
3183 application.Render();
3185 Vector3 naturalSize = label.GetNaturalSize();
3187 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3189 application.SendNotification();
3190 application.Render();
3192 Vector3 relativeNaturalSize = label.GetNaturalSize();
3194 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3196 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3198 application.SendNotification();
3199 application.Render();
3201 relativeNaturalSize = label.GetNaturalSize();
3203 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3207 int UtcDaliTextLabelCharacterSpacing(void)
3209 ToolkitTestApplication application;
3210 tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3212 TextLabel textLabel = TextLabel::New();
3214 textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3216 application.GetScene().Add(textLabel);
3217 application.SendNotification();
3218 application.Render();
3220 textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3221 textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3222 DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3224 application.SendNotification();
3225 application.Render();
3230 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3232 ToolkitTestApplication application;
3233 tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3235 TextLabel label = TextLabel::New();
3237 float lineSpacing = -20.f;
3239 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3240 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3241 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3242 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3243 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3245 application.GetScene().Add(label);
3246 application.SendNotification();
3247 application.Render();
3249 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3250 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3252 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
3253 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3255 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3256 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3258 application.SendNotification();
3259 application.Render();
3264 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3266 ToolkitTestApplication application;
3267 tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3269 TextLabel label = TextLabel::New();
3271 float lineSpacing = -20.f;
3273 label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3274 label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3275 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3276 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3277 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3278 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3280 application.GetScene().Add(label);
3281 application.SendNotification();
3282 application.Render();
3284 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3286 int lineCount = sizeList.Size();
3287 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3289 application.SendNotification();
3290 application.Render();
3295 int UtcDaliToolkitTextlabelParagraphTag(void)
3297 ToolkitTestApplication application;
3298 tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3299 TextLabel labelNewlineSeparator = TextLabel::New();
3300 TextLabel labelParagraphTag = TextLabel::New();
3301 DALI_TEST_CHECK(labelNewlineSeparator);
3302 DALI_TEST_CHECK(labelParagraphTag);
3304 application.GetScene().Add(labelNewlineSeparator);
3305 application.GetScene().Add(labelParagraphTag);
3307 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3308 labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3309 labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3310 labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3311 labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3312 labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3313 labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3314 labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3316 labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3317 labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3318 labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3319 labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3320 labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3321 labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3322 labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3324 application.SendNotification();
3325 application.Render();
3327 Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3328 Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize();
3330 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3332 application.SendNotification();
3333 application.Render();
3338 int utcDaliTextLabelGetTextBoundingRectangle(void)
3340 ToolkitTestApplication application;
3341 tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3343 TextLabel label = TextLabel::New();
3344 DALI_TEST_CHECK(label);
3346 application.GetScene().Add(label);
3348 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3349 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3350 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3351 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3352 label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3354 // Avoid a crash when core load gl resources.
3355 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3357 // Render and notify
3358 application.SendNotification();
3359 application.Render();
3361 unsigned int startIndex = 0;
3362 unsigned int endIndex = 15;
3364 Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3365 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3367 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);
3372 int utcDaliTextLabelRemoveFrontInset(void)
3374 ToolkitTestApplication application;
3375 tet_infoline(" utcDaliTextLabelRemoveFrontInset");
3377 TextLabel label = TextLabel::New();
3378 DALI_TEST_CHECK(label);
3380 application.GetScene().Add(label);
3381 application.SendNotification();
3382 application.Render();
3384 DevelTextLabel::SetRemoveFrontInset(label, false);
3385 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveFrontInset(label));
3390 int utcDaliTextLabelRemoveBackInset(void)
3392 ToolkitTestApplication application;
3393 tet_infoline(" utcDaliTextLabelRemoveBackInset");
3395 TextLabel label = TextLabel::New();
3396 DALI_TEST_CHECK(label);
3398 application.GetScene().Add(label);
3399 application.SendNotification();
3400 application.Render();
3402 DevelTextLabel::SetRemoveBackInset(label, false);
3403 DALI_TEST_CHECK(!DevelTextLabel::IsRemoveBackInset(label));