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 std::string DEFAULT_FONT_DIR("/resources/fonts");
84 const unsigned int EMOJI_FONT_SIZE = 3840u; // 60 * 64
86 static bool gAnchorClickedCallBackCalled;
87 static bool gAnchorClickedCallBackNotCalled;
89 static bool gTextFitChangedCallBackCalled;
91 struct CallbackFunctor
93 CallbackFunctor(bool* callbackFlag)
94 : mCallbackFlag(callbackFlag)
100 *mCallbackFlag = true;
105 static void TestAnchorClickedCallback(TextLabel control, const char* href, unsigned int hrefLength)
107 tet_infoline(" TestAnchorClickedCallback");
109 gAnchorClickedCallBackNotCalled = false;
111 if(!strcmp(href, "https://www.tizen.org") && hrefLength == strlen(href))
113 gAnchorClickedCallBackCalled = true;
117 static void TestTextFitChangedCallback(TextLabel control)
119 tet_infoline(" TestTextFitChangedCallback");
120 gTextFitChangedCallBackCalled = true;
123 bool DaliTestCheckMaps(const Property::Map& mapGet, const Property::Map& mapSet, const std::vector<std::string>& indexConversionTable = std::vector<std::string>())
125 const Property::Map::SizeType size = mapGet.Count();
127 if(size == mapSet.Count())
129 for(unsigned int index = 0u; index < size; ++index)
131 const KeyValuePair& valueGet = mapGet.GetKeyValue(index);
133 // Find the keys of the 'get' map
134 Property::Index indexKey = valueGet.first.indexKey;
135 std::string stringKey = valueGet.first.stringKey;
137 if(!indexConversionTable.empty())
139 if(stringKey.empty())
141 stringKey = indexConversionTable[indexKey];
144 if((indexKey == Property::INVALID_INDEX) && !stringKey.empty())
146 Property::Index index = 0u;
147 for(auto key : indexConversionTable)
159 const Property::Value* const valueSet = mapSet.Find(indexKey, stringKey);
161 if(nullptr != valueSet)
163 if((valueSet->GetType() == Dali::Property::STRING) && (valueGet.second.Get<std::string>() != valueSet->Get<std::string>()))
165 tet_printf("Value got : [%s], expected : [%s]", valueGet.second.Get<std::string>().c_str(), valueSet->Get<std::string>().c_str());
168 else if((valueSet->GetType() == Dali::Property::BOOLEAN) && (valueGet.second.Get<bool>() != valueSet->Get<bool>()))
170 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<bool>(), valueSet->Get<bool>());
173 else if((valueSet->GetType() == Dali::Property::INTEGER) && (valueGet.second.Get<int>() != valueSet->Get<int>()))
175 tet_printf("Value got : [%d], expected : [%d]", valueGet.second.Get<int>(), valueSet->Get<int>());
178 else if((valueSet->GetType() == Dali::Property::FLOAT) && (valueGet.second.Get<float>() != valueSet->Get<float>()))
180 tet_printf("Value got : [%f], expected : [%f]", valueGet.second.Get<float>(), valueSet->Get<float>());
183 else if((valueSet->GetType() == Dali::Property::VECTOR2) && (valueGet.second.Get<Vector2>() != valueSet->Get<Vector2>()))
185 Vector2 vector2Get = valueGet.second.Get<Vector2>();
186 Vector2 vector2Set = valueSet->Get<Vector2>();
187 tet_printf("Value got : [%f, %f], expected : [%f, %f]", vector2Get.x, vector2Get.y, vector2Set.x, vector2Set.y);
190 else if((valueSet->GetType() == Dali::Property::VECTOR4) && (valueGet.second.Get<Vector4>() != valueSet->Get<Vector4>()))
192 Vector4 vector4Get = valueGet.second.Get<Vector4>();
193 Vector4 vector4Set = valueSet->Get<Vector4>();
194 tet_printf("Value got : [%f, %f, %f, %f], expected : [%f, %f, %f, %f]", vector4Get.r, vector4Get.g, vector4Get.b, vector4Get.a, vector4Set.r, vector4Set.g, vector4Set.b, vector4Set.a);
200 if(valueGet.first.type == Property::Key::INDEX)
202 tet_printf(" The key %d doesn't exist.", valueGet.first.indexKey);
206 tet_printf(" The key %s doesn't exist.", valueGet.first.stringKey.c_str());
218 int UtcDaliToolkitTextLabelConstructorP(void)
220 ToolkitTestApplication application;
221 tet_infoline(" UtcDaliToolkitTextLabelConstructorP");
223 DALI_TEST_CHECK(!textLabel);
227 int UtcDaliToolkitTextLabelNewP(void)
229 ToolkitTestApplication application;
230 tet_infoline(" UtcDaliToolkitTextLabelNewP");
231 TextLabel textLabel = TextLabel::New("Test Text");
232 DALI_TEST_CHECK(textLabel);
236 int UtcDaliToolkitTextLabelDownCastP(void)
238 ToolkitTestApplication application;
239 tet_infoline(" UtcDaliToolkitTextLabelDownCastP");
240 TextLabel textLabel1 = TextLabel::New();
241 BaseHandle object(textLabel1);
243 TextLabel textLabel2 = TextLabel::DownCast(object);
244 DALI_TEST_CHECK(textLabel2);
246 TextLabel textLabel3 = DownCast<TextLabel>(object);
247 DALI_TEST_CHECK(textLabel3);
251 int UtcDaliToolkitTextLabelDownCastN(void)
253 ToolkitTestApplication application;
254 tet_infoline(" UtcDaliToolkitTextLabelDownCastN");
255 BaseHandle uninitializedObject;
256 TextLabel textLabel1 = TextLabel::DownCast(uninitializedObject);
257 DALI_TEST_CHECK(!textLabel1);
259 TextLabel textLabel2 = DownCast<TextLabel>(uninitializedObject);
260 DALI_TEST_CHECK(!textLabel2);
264 int UtcDaliToolkitTextLabelCopyConstructorP(void)
266 ToolkitTestApplication application;
267 tet_infoline(" UtcDaliToolkitTextLabelCopyConstructorP");
268 TextLabel textLabel = TextLabel::New();
269 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
271 TextLabel copy(textLabel);
272 DALI_TEST_CHECK(copy);
273 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
277 int UtcDaliTextLabelMoveConstructor(void)
279 ToolkitTestApplication application;
281 TextLabel textLabel = TextLabel::New();
282 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
283 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
285 TextLabel moved = std::move(textLabel);
286 DALI_TEST_CHECK(moved);
287 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
288 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
289 DALI_TEST_CHECK(!textLabel);
294 int UtcDaliToolkitTextLabelAssignmentOperatorP(void)
296 ToolkitTestApplication application;
297 tet_infoline(" UtcDaliToolkitTextLabelAssingmentOperatorP");
298 TextLabel textLabel = TextLabel::New();
299 textLabel.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
301 TextLabel copy = textLabel;
302 DALI_TEST_CHECK(copy);
303 DALI_TEST_CHECK(copy.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR) == textLabel.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR));
307 int UtcDaliTextLabelMoveAssignment(void)
309 ToolkitTestApplication application;
311 TextLabel textLabel = TextLabel::New();
312 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
313 DALI_TEST_CHECK(textLabel.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
316 moved = std::move(textLabel);
317 DALI_TEST_CHECK(moved);
318 DALI_TEST_EQUALS(1, moved.GetBaseObject().ReferenceCount(), TEST_LOCATION);
319 DALI_TEST_CHECK(moved.GetProperty<std::string>(TextLabel::Property::TEXT) == "Test");
320 DALI_TEST_CHECK(!textLabel);
325 // Positive test case for a method
326 int UtcDaliToolkitTextLabelGetPropertyP(void)
328 ToolkitTestApplication application;
329 tet_infoline(" UtcDaliToolkitTextLabelGetPropertyP");
330 TextLabel label = TextLabel::New("Test Text");
331 DALI_TEST_CHECK(label);
333 // Check Property Indices are correct
334 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_RENDERING_BACKEND) == DevelTextLabel::Property::RENDERING_BACKEND);
335 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT) == TextLabel::Property::TEXT);
336 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_FAMILY) == TextLabel::Property::FONT_FAMILY);
337 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_STYLE) == TextLabel::Property::FONT_STYLE);
338 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_POINT_SIZE) == TextLabel::Property::POINT_SIZE);
339 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_MULTI_LINE) == TextLabel::Property::MULTI_LINE);
340 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_HORIZONTAL_ALIGNMENT) == TextLabel::Property::HORIZONTAL_ALIGNMENT);
341 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_VERTICAL_ALIGNMENT) == TextLabel::Property::VERTICAL_ALIGNMENT);
342 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_TEXT_COLOR) == TextLabel::Property::TEXT_COLOR);
343 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_MARKUP) == TextLabel::Property::ENABLE_MARKUP);
344 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL) == TextLabel::Property::ENABLE_AUTO_SCROLL);
345 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_SPEED) == TextLabel::Property::AUTO_SCROLL_SPEED);
346 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_LOOPS) == TextLabel::Property::AUTO_SCROLL_LOOP_COUNT);
347 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_AUTO_SCROLL_GAP) == TextLabel::Property::AUTO_SCROLL_GAP);
348 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_LINE_SPACING) == TextLabel::Property::LINE_SPACING);
349 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_UNDERLINE) == TextLabel::Property::UNDERLINE);
350 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_SHADOW) == TextLabel::Property::SHADOW);
351 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_EMBOSS) == TextLabel::Property::EMBOSS);
352 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_OUTLINE) == TextLabel::Property::OUTLINE);
353 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_BACKGROUND) == DevelTextLabel::Property::BACKGROUND);
354 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_PIXEL_SIZE) == TextLabel::Property::PIXEL_SIZE);
355 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS) == TextLabel::Property::ELLIPSIS);
356 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_AUTO_SCROLL_LOOP_DELAY) == TextLabel::Property::AUTO_SCROLL_LOOP_DELAY);
357 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_FONT_SIZE_SCALE) == DevelTextLabel::Property::FONT_SIZE_SCALE);
358 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ENABLE_FONT_SIZE_SCALE) == DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE);
359 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ELLIPSIS_POSITION) == DevelTextLabel::Property::ELLIPSIS_POSITION);
360 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_STRIKETHROUGH) == DevelTextLabel::Property::STRIKETHROUGH);
361 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_COLOR) == DevelTextLabel::Property::ANCHOR_COLOR);
362 DALI_TEST_CHECK(label.GetPropertyIndex(PROPERTY_NAME_ANCHOR_CLICKED_COLOR) == DevelTextLabel::Property::ANCHOR_CLICKED_COLOR);
367 int UtcDaliToolkitTextLabelSetPropertyP(void)
369 ToolkitTestApplication application;
370 tet_infoline(" UtcDaliToolkitTextLabelSetPropertyP");
371 TextLabel label = TextLabel::New();
372 DALI_TEST_CHECK(label);
374 application.GetScene().Add(label);
376 // Note - we can't check the defaults since the stylesheets are platform-specific
377 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
378 DALI_TEST_EQUALS((DevelText::RenderingType)label.GetProperty<int>(DevelTextLabel::Property::RENDERING_BACKEND), DevelText::RENDERING_SHARED_ATLAS, TEST_LOCATION);
380 // Check that text can be correctly reset
381 label.SetProperty(TextLabel::Property::TEXT, "Setting Text");
382 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("Setting Text"), TEST_LOCATION);
384 // Check font properties.
385 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Setting font family");
386 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::FONT_FAMILY), std::string("Setting font family"), TEST_LOCATION);
388 Property::Map fontStyleMapSet;
389 Property::Map fontStyleMapGet;
391 fontStyleMapSet.Insert("weight", "bold");
392 fontStyleMapSet.Insert("width", "condensed");
393 fontStyleMapSet.Insert("slant", "italic");
394 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
396 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
397 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
398 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
400 // Check the old font style format.
401 fontStyleMapSet.Clear();
402 fontStyleMapSet.Insert("weight", "thin");
403 fontStyleMapSet.Insert("width", "expanded");
404 fontStyleMapSet.Insert("slant", "oblique");
405 const std::string strFontStyle = "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}";
407 label.SetProperty(TextLabel::Property::FONT_STYLE, "{\"weight\":\"thin\",\"width\":\"expanded\",\"slant\":\"oblique\"}");
408 std::string getFontStyle = label.GetProperty<std::string>(TextLabel::Property::FONT_STYLE);
409 DALI_TEST_EQUALS(getFontStyle, strFontStyle, TEST_LOCATION);
411 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
412 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::POINT_SIZE), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
414 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 2.5f);
415 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::FONT_SIZE_SCALE), 2.5f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
416 label.SetProperty(DevelTextLabel::Property::FONT_SIZE_SCALE, 1.0f);
418 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, false);
419 DALI_TEST_EQUALS(label.GetProperty<bool>(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE), false, TEST_LOCATION);
420 label.SetProperty(DevelTextLabel::Property::ENABLE_FONT_SIZE_SCALE, true);
423 fontStyleMapSet.Clear();
424 fontStyleMapSet.Insert("weight", "normal");
425 fontStyleMapSet.Insert("slant", "oblique");
427 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
428 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
429 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
430 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
432 fontStyleMapSet.Clear();
433 fontStyleMapSet.Insert("slant", "roman");
435 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
436 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
437 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
439 // Replace 'roman' for 'normal'.
440 Property::Value* slantValue = fontStyleMapGet.Find("slant");
441 if(NULL != slantValue)
443 if("normal" == slantValue->Get<std::string>())
445 fontStyleMapGet["slant"] = "roman";
448 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
450 fontStyleMapSet.Clear();
452 label.SetProperty(TextLabel::Property::FONT_STYLE, fontStyleMapSet);
453 fontStyleMapGet = label.GetProperty<Property::Map>(TextLabel::Property::FONT_STYLE);
454 DALI_TEST_EQUALS(fontStyleMapGet.Count(), fontStyleMapSet.Count(), TEST_LOCATION);
455 DALI_TEST_EQUALS(DaliTestCheckMaps(fontStyleMapGet, fontStyleMapSet), true, TEST_LOCATION);
458 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
459 DALI_TEST_EQUALS(label.GetProperty<bool>(TextLabel::Property::MULTI_LINE), true, TEST_LOCATION);
461 // Check that the Alignment properties can be correctly set
462 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
463 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::HORIZONTAL_ALIGNMENT), "CENTER", TEST_LOCATION);
464 label.SetProperty(TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER");
465 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::VERTICAL_ALIGNMENT), "CENTER", TEST_LOCATION);
467 // Check that text color can be properly set
468 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
469 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Color::BLUE, TEST_LOCATION);
471 // Check that anchor color can be properly set
472 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
473 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
475 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
476 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
478 Property::Map strikethroughMapSet;
479 Property::Map strikethroughMapGet;
481 strikethroughMapSet.Insert("enable", false);
482 strikethroughMapSet.Insert("color", Color::BLUE);
483 strikethroughMapSet.Insert("height", 2.0f);
485 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
487 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
488 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
489 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
491 Property::Map underlineMapSet;
492 Property::Map underlineMapGet;
494 underlineMapSet.Insert("enable", false);
495 underlineMapSet.Insert("color", Color::BLUE);
496 underlineMapSet.Insert("height", 0);
497 underlineMapSet.Insert("type", Text::Underline::SOLID);
498 underlineMapSet.Insert("dashWidth", 2);
499 underlineMapSet.Insert("dashGap", 1);
501 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
503 application.SendNotification();
504 application.Render();
506 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
507 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
508 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
511 underlineMapSet.Clear();
512 underlineMapGet.Clear();
514 underlineMapSet.Insert("enable", false);
515 underlineMapSet.Insert("color", Color::BLUE);
516 underlineMapSet.Insert("height", 0);
517 underlineMapSet.Insert("type", Text::Underline::DASHED);
518 underlineMapSet.Insert("dashWidth", 2);
519 underlineMapSet.Insert("dashGap", 1);
521 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
523 application.SendNotification();
524 application.Render();
526 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
527 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
528 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
531 underlineMapSet.Clear();
532 underlineMapGet.Clear();
534 underlineMapSet.Insert("enable", false);
535 underlineMapSet.Insert("color", Color::BLUE);
536 underlineMapSet.Insert("height", 0);
537 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
538 underlineMapSet.Insert("dashWidth", 2);
539 underlineMapSet.Insert("dashGap", 1);
541 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
543 application.SendNotification();
544 application.Render();
546 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
547 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
548 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
550 TextLabel label2 = TextLabel::New("New text");
551 DALI_TEST_CHECK(label2);
552 DALI_TEST_EQUALS(label2.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("New text"), TEST_LOCATION);
554 // Check the enable markup property.
555 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
556 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
557 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_MARKUP));
559 // Check the text property when markup is enabled
560 label.SetProperty(TextLabel::Property::TEXT, "<color value='white'>Markup</color><color value='cyan'>Text</color>");
561 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
563 // Check for incomplete marks.
564 label.SetProperty(TextLabel::Property::TEXT, "<color='white'><i>Markup</i><b>Text</b></color>");
565 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), std::string("MarkupText"), TEST_LOCATION);
568 application.SendNotification();
569 application.Render();
573 tet_result(TET_FAIL);
576 // Check autoscroll properties
577 const int SCROLL_SPEED = 80;
578 const int SCROLL_LOOPS = 4;
579 const float SCROLL_GAP = 50.0f;
580 const float SCROLL_LOOP_DELAY = 0.3f;
581 const std::string STOP_IMMEDIATE = std::string("IMMEDIATE");
582 const std::string STOP_FINISH_LOOP = std::string("FINISH_LOOP");
584 label.SetProperty(TextLabel::Property::MULTI_LINE, false); // Autoscroll only supported in single line
585 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
586 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
587 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ENABLE_AUTO_SCROLL));
588 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, SCROLL_SPEED);
589 DALI_TEST_EQUALS(SCROLL_SPEED, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_SPEED), TEST_LOCATION);
590 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, SCROLL_LOOPS);
591 DALI_TEST_EQUALS(SCROLL_LOOPS, label.GetProperty<int>(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT), TEST_LOCATION);
592 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, SCROLL_GAP);
593 DALI_TEST_EQUALS(SCROLL_GAP, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_GAP), TEST_LOCATION);
594 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY, SCROLL_LOOP_DELAY);
595 DALI_TEST_EQUALS(SCROLL_LOOP_DELAY, label.GetProperty<float>(TextLabel::Property::AUTO_SCROLL_LOOP_DELAY), TEST_LOCATION);
597 //Check autoscroll stop type property
598 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
599 DALI_TEST_EQUALS(STOP_IMMEDIATE, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
601 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
602 DALI_TEST_EQUALS(STOP_FINISH_LOOP, label.GetProperty<std::string>(TextLabel::Property::AUTO_SCROLL_STOP_MODE), TEST_LOCATION);
604 // test natural size with multi-line and line spacing
606 TextLabel label3 = TextLabel::New("Some text here\nend there\nend here");
607 Vector3 oneLineNaturalSize = label3.GetNaturalSize();
608 label3.SetProperty(TextLabel::Property::MULTI_LINE, true);
609 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
610 Vector3 multiLineNaturalSize = label3.GetNaturalSize();
612 // The width of the text when multi-line is enabled will be smaller (lines separated on '\n')
613 // The height of the text when multi-line is enabled will be larger
614 DALI_TEST_CHECK(oneLineNaturalSize.width > multiLineNaturalSize.width);
615 DALI_TEST_CHECK(oneLineNaturalSize.height < multiLineNaturalSize.height);
617 // Change line spacing, meaning height will increase by 3 times the amount specified as we have three lines
618 // Everything else will remain the same
619 int lineSpacing = 20;
620 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
621 Vector3 expectedAfterLineSpacingApplied(multiLineNaturalSize);
622 expectedAfterLineSpacingApplied.height += 3 * lineSpacing;
623 DALI_TEST_EQUALS(expectedAfterLineSpacingApplied, label3.GetNaturalSize(), TEST_LOCATION);
626 // single line, line spacing must not affect natural size of the text, only add the spacing to the height
628 TextLabel label3 = TextLabel::New("Some text here end there end here");
629 label3.SetProperty(TextLabel::Property::MULTI_LINE, false);
630 label3.SetProperty(TextLabel::Property::LINE_SPACING, 0);
631 Vector3 textNaturalSize = label3.GetNaturalSize();
632 int lineSpacing = 20;
633 label3.SetProperty(TextLabel::Property::LINE_SPACING, lineSpacing);
634 Vector3 expectedNaturalSizeWithLineSpacing(textNaturalSize);
635 expectedNaturalSizeWithLineSpacing.height += lineSpacing;
636 DALI_TEST_EQUALS(expectedNaturalSizeWithLineSpacing, label3.GetNaturalSize(), TEST_LOCATION);
638 // Check the line spacing property
639 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
640 label.SetProperty(TextLabel::Property::LINE_SPACING, 10.f);
641 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::LINE_SPACING), 10.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
643 // Check the strikethrough property
644 strikethroughMapSet.Clear();
645 strikethroughMapSet.Insert("enable", true);
646 strikethroughMapSet.Insert("color", Color::RED);
647 strikethroughMapSet.Insert("height", 2.0f);
649 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
651 application.SendNotification();
652 application.Render();
654 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
655 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
656 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
658 // Check the transparent strikethrough property for coverage.
659 strikethroughMapSet.Clear();
660 strikethroughMapSet.Insert("enable", true);
661 strikethroughMapSet.Insert("color", Color::TRANSPARENT);
662 strikethroughMapSet.Insert("height", 2.0f);
664 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
666 application.SendNotification();
667 application.Render();
669 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
670 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
671 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
673 strikethroughMapSet.Clear();
674 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::ENABLE, true);
675 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::COLOR, Color::RED);
676 strikethroughMapSet.Insert(Toolkit::DevelText::Strikethrough::Property::HEIGHT, 2.0f);
678 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
680 application.SendNotification();
681 application.Render();
683 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
684 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
685 std::vector<std::string> strikethroughIndicesConversionTable = {"enable", "color", "height"};
686 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet, strikethroughIndicesConversionTable), true, TEST_LOCATION);
688 strikethroughMapSet.Clear();
690 Property::Map strikethroughDisabledMapGet;
691 strikethroughDisabledMapGet.Insert("enable", false);
692 strikethroughDisabledMapGet.Insert("color", Color::RED);
693 strikethroughDisabledMapGet.Insert("height", 2.0f);
695 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
697 application.SendNotification();
698 application.Render();
700 strikethroughMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
701 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughDisabledMapGet.Count(), TEST_LOCATION);
702 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughDisabledMapGet), true, TEST_LOCATION);
704 // Check the underline property
705 underlineMapSet.Clear();
706 underlineMapSet.Insert("enable", true);
707 underlineMapSet.Insert("color", Color::RED);
708 underlineMapSet.Insert("height", 1);
709 underlineMapSet.Insert("type", Text::Underline::SOLID);
710 underlineMapSet.Insert("dashWidth", 2);
711 underlineMapSet.Insert("dashGap", 1);
713 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
715 application.SendNotification();
716 application.Render();
718 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
719 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
720 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
722 underlineMapSet.Clear();
723 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
724 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
725 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
726 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
727 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
728 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
730 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
732 application.SendNotification();
733 application.Render();
735 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
736 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
737 std::vector<std::string> underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
738 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
740 underlineMapSet.Clear();
742 Property::Map underlineDisabledMapGet;
743 underlineDisabledMapGet.Insert("enable", false);
744 underlineDisabledMapGet.Insert("color", Color::GREEN);
745 underlineDisabledMapGet.Insert("height", 2);
746 underlineDisabledMapGet.Insert("type", Text::Underline::SOLID);
747 underlineDisabledMapGet.Insert("dashWidth", 2);
748 underlineDisabledMapGet.Insert("dashGap", 1);
750 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
752 application.SendNotification();
753 application.Render();
755 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
756 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
757 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
759 // Check the dashed underline property
760 underlineMapSet.Clear();
761 underlineMapSet.Insert("enable", true);
762 underlineMapSet.Insert("color", Color::RED);
763 underlineMapSet.Insert("height", 1);
764 underlineMapSet.Insert("type", Text::Underline::DASHED);
765 underlineMapSet.Insert("dashWidth", 2);
766 underlineMapSet.Insert("dashGap", 1);
768 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
770 application.SendNotification();
771 application.Render();
773 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
774 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
775 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
777 underlineMapSet.Clear();
778 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
779 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
780 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
781 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DASHED);
782 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
783 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
785 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
787 application.SendNotification();
788 application.Render();
790 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
791 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
792 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
793 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
795 underlineMapSet.Clear();
797 underlineDisabledMapGet.Clear();
798 underlineDisabledMapGet.Insert("enable", false);
799 underlineDisabledMapGet.Insert("color", Color::GREEN);
800 underlineDisabledMapGet.Insert("height", 2);
801 underlineDisabledMapGet.Insert("type", Text::Underline::DASHED);
802 underlineDisabledMapGet.Insert("dashWidth", 2);
803 underlineDisabledMapGet.Insert("dashGap", 1);
805 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
807 application.SendNotification();
808 application.Render();
810 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
811 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
812 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
814 // Check the double underline property
815 underlineMapSet.Clear();
816 underlineMapSet.Insert("enable", true);
817 underlineMapSet.Insert("color", Color::RED);
818 underlineMapSet.Insert("height", 1);
819 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
820 underlineMapSet.Insert("dashWidth", 2);
821 underlineMapSet.Insert("dashGap", 1);
823 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
825 application.SendNotification();
826 application.Render();
828 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
829 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
830 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
832 // Check the transparent double underline property for coverage.
833 underlineMapSet.Clear();
834 underlineMapSet.Insert("enable", true);
835 underlineMapSet.Insert("color", Color::TRANSPARENT);
836 underlineMapSet.Insert("height", 1);
837 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
838 underlineMapSet.Insert("dashWidth", 2);
839 underlineMapSet.Insert("dashGap", 1);
841 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
843 application.SendNotification();
844 application.Render();
846 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
847 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
848 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet), true, TEST_LOCATION);
850 underlineMapSet.Clear();
851 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::ENABLE, true);
852 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::COLOR, Color::GREEN);
853 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::HEIGHT, 2);
854 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::TYPE, Text::Underline::DOUBLE);
855 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_WIDTH, 2);
856 underlineMapSet.Insert(Toolkit::DevelText::Underline::Property::DASH_GAP, 1);
858 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
860 application.SendNotification();
861 application.Render();
863 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
864 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineMapSet.Count(), TEST_LOCATION);
865 underlineIndicesConversionTable = {"enable", "color", "height", "type", "dashWidth", "dashGap"};
866 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineMapSet, underlineIndicesConversionTable), true, TEST_LOCATION);
868 underlineMapSet.Clear();
870 underlineDisabledMapGet.Clear();
871 underlineDisabledMapGet.Insert("enable", false);
872 underlineDisabledMapGet.Insert("color", Color::GREEN);
873 underlineDisabledMapGet.Insert("height", 2);
874 underlineDisabledMapGet.Insert("type", Text::Underline::DOUBLE);
875 underlineDisabledMapGet.Insert("dashWidth", 2);
876 underlineDisabledMapGet.Insert("dashGap", 1);
878 label.SetProperty(TextLabel::Property::UNDERLINE, underlineDisabledMapGet);
880 application.SendNotification();
881 application.Render();
883 underlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::UNDERLINE);
884 DALI_TEST_EQUALS(underlineMapGet.Count(), underlineDisabledMapGet.Count(), TEST_LOCATION);
885 DALI_TEST_EQUALS(DaliTestCheckMaps(underlineMapGet, underlineDisabledMapGet), true, TEST_LOCATION);
887 // Check the shadow property
889 Property::Map shadowMapSet;
890 Property::Map shadowMapGet;
892 shadowMapSet.Insert("color", Color::GREEN);
893 shadowMapSet.Insert("offset", Vector2(2.0f, 2.0f));
894 shadowMapSet.Insert("blurRadius", 5.0f);
896 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
898 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
899 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
900 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet), true, TEST_LOCATION);
902 shadowMapSet.Clear();
904 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
905 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, "3.0 3.0");
906 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
908 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
910 // Replace the offset (string) by a vector2
911 shadowMapSet.Clear();
912 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::COLOR, Color::BLUE);
913 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::OFFSET, Vector2(3.0, 3.0));
914 shadowMapSet.Insert(Toolkit::DevelText::Shadow::Property::BLUR_RADIUS, 3.0f);
916 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
917 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowMapSet.Count(), TEST_LOCATION);
918 std::vector<std::string> shadowIndicesConversionTable = {"color", "offset", "blurRadius"};
919 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowMapSet, shadowIndicesConversionTable), true, TEST_LOCATION);
921 shadowMapSet.Clear();
922 Property::Map shadowDisabledMapGet;
923 shadowDisabledMapGet.Insert("color", Color::BLUE);
924 shadowDisabledMapGet.Insert("offset", Vector2(0.0f, 0.0f));
925 shadowDisabledMapGet.Insert("blurRadius", 3.0f);
927 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
929 shadowMapGet = label.GetProperty<Property::Map>(TextLabel::Property::SHADOW);
930 DALI_TEST_EQUALS(shadowMapGet.Count(), shadowDisabledMapGet.Count(), TEST_LOCATION);
931 DALI_TEST_EQUALS(DaliTestCheckMaps(shadowMapGet, shadowDisabledMapGet), true, TEST_LOCATION);
933 // Check the emboss property
934 label.SetProperty(TextLabel::Property::EMBOSS, "Emboss properties");
935 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::EMBOSS), std::string("Emboss properties"), TEST_LOCATION);
937 // Check the outline property
939 // Test string type first
940 // This is purely to maintain backward compatibility, but we don't support string as the outline property type.
941 label.SetProperty(TextLabel::Property::OUTLINE, "Outline properties");
942 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::OUTLINE), std::string("Outline properties"), TEST_LOCATION);
944 // Then test the property map type
945 Property::Map outlineMapSet;
946 Property::Map outlineMapGet;
948 outlineMapSet["color"] = Color::RED;
949 outlineMapSet["width"] = 2.0f;
950 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
952 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
953 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
954 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet), true, TEST_LOCATION);
956 outlineMapSet.Clear();
957 outlineMapSet[Toolkit::DevelText::Outline::Property::COLOR] = Color::BLUE;
958 outlineMapSet[Toolkit::DevelText::Outline::Property::WIDTH] = 3.0f;
959 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
961 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
962 DALI_TEST_EQUALS(outlineMapGet.Count(), outlineMapSet.Count(), TEST_LOCATION);
963 std::vector<std::string> outlineIndicesConversionTable = {"color", "width"};
964 DALI_TEST_EQUALS(DaliTestCheckMaps(outlineMapGet, outlineMapSet, outlineIndicesConversionTable), true, TEST_LOCATION);
966 // Check the background property
967 Property::Map backgroundMapSet;
968 Property::Map backgroundMapGet;
970 backgroundMapSet["enable"] = true;
971 backgroundMapSet["color"] = Color::RED;
972 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
974 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
975 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
976 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
978 // Check the transparent background property for coverage
979 backgroundMapSet.Clear();
980 backgroundMapSet["enable"] = true;
981 backgroundMapSet["color"] = Color::TRANSPARENT;
982 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
984 application.SendNotification();
985 application.Render();
987 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
988 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
989 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet), true, TEST_LOCATION);
991 backgroundMapSet.Clear();
992 backgroundMapSet[Toolkit::DevelText::Background::Property::ENABLE] = true;
993 backgroundMapSet[Toolkit::DevelText::Background::Property::COLOR] = Color::GREEN;
994 label.SetProperty(DevelTextLabel::Property::BACKGROUND, backgroundMapSet);
996 backgroundMapGet = label.GetProperty<Property::Map>(DevelTextLabel::Property::BACKGROUND);
997 DALI_TEST_EQUALS(backgroundMapGet.Count(), backgroundMapSet.Count(), TEST_LOCATION);
998 std::vector<std::string> backgroundIndicesConversionTable = {"enable", "color"};
999 DALI_TEST_EQUALS(DaliTestCheckMaps(backgroundMapGet, backgroundMapSet, backgroundIndicesConversionTable), true, TEST_LOCATION);
1001 // Check the pixel size of font
1002 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 20.f);
1003 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::PIXEL_SIZE), 20.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1005 // Check the ellipsis property
1006 DALI_TEST_CHECK(label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1007 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1008 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1010 // Check the layout direction property
1011 label.SetProperty(Actor::Property::LAYOUT_DIRECTION, LayoutDirection::RIGHT_TO_LEFT);
1012 DALI_TEST_EQUALS(label.GetProperty<int>(Actor::Property::LAYOUT_DIRECTION), static_cast<int>(LayoutDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1014 // Check the line size property
1015 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 0.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1016 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 50.f);
1017 DALI_TEST_EQUALS(label.GetProperty<float>(DevelTextLabel::Property::MIN_LINE_SIZE), 50.0f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1019 application.SendNotification();
1020 application.Render();
1025 int UtcDaliToolkitTextlabelAtlasRenderP(void)
1027 ToolkitTestApplication application;
1028 tet_infoline(" UtcDaliToolkitTextLabelAtlasRenderP");
1029 TextLabel label = TextLabel::New("Test Text");
1030 DALI_TEST_CHECK(label);
1032 // Avoid a crash when core load gl resources.
1033 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1035 application.GetScene().Add(label);
1037 // Turn on all the effects
1038 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1039 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1041 Property::Map underlineMap;
1042 underlineMap.Insert("enable", true);
1043 underlineMap.Insert("color", Color::RED);
1044 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMap);
1046 Property::Map shadowMap;
1047 shadowMap.Insert("color", Color::BLUE);
1048 shadowMap.Insert("offset", Vector2(1.0f, 1.0f));
1049 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1051 Property::Map strikethroughMap;
1052 strikethroughMap.Insert("enable", true);
1053 strikethroughMap.Insert("color", Color::GREEN);
1054 strikethroughMap.Insert("height", 2.0f);
1055 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMap);
1059 // Render some text with the shared atlas backend
1060 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_SHARED_ATLAS);
1061 application.SendNotification();
1062 application.Render();
1066 tet_result(TET_FAIL);
1071 // Render some text with the shared atlas backend
1072 label.SetProperty(DevelTextLabel::Property::RENDERING_BACKEND, DevelText::RENDERING_VECTOR_BASED);
1073 application.SendNotification();
1074 application.Render();
1078 tet_result(TET_FAIL);
1083 int UtcDaliToolkitTextLabelLanguagesP(void)
1085 ToolkitTestApplication application;
1086 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1087 TextLabel label = TextLabel::New();
1088 DALI_TEST_CHECK(label);
1090 application.GetScene().Add(label);
1092 const std::string scripts(
1093 " привет мир, γειά σου Κόσμε, Hello world, مرحبا بالعالم, שלום עולם, "
1094 "բարեւ աշխարհը, მსოფლიოში, 안녕하세요, 你好世界, ひらがな, カタカナ, "
1095 "ওহে বিশ্ব, မင်္ဂလာပါကမ္ဘာလောက, हैलो वर्ल्ड, હેલો વર્લ્ડ, ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ, ಹಲೋ ವರ್ಲ್ಡ್, "
1096 "ഹലോ വേൾഡ്, ଓଡ଼ିଆ, හෙලෝ වර්ල්ඩ්, ஹலோ உலகம், హలో వరల్డ్, "
1097 "ສະບາຍດີໂລກ, สวัสดีโลก, ជំរាបសួរពិភពលោក, "
1098 "\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84."); // these characters on the last line are emojis.
1100 label.SetProperty(TextLabel::Property::TEXT, scripts);
1101 DALI_TEST_EQUALS(label.GetProperty<std::string>(TextLabel::Property::TEXT), scripts, TEST_LOCATION);
1103 application.SendNotification();
1104 application.Render();
1109 int UtcDaliToolkitTextLabelEmojisP(void)
1111 ToolkitTestApplication application;
1112 tet_infoline(" UtcDaliToolkitTextLabelLanguagesP");
1113 TextLabel label = TextLabel::New();
1114 DALI_TEST_CHECK(label);
1116 application.GetScene().Add(label);
1118 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1120 char* pathNamePtr = get_current_dir_name();
1121 const std::string pathName(pathNamePtr);
1124 TextAbstraction::FontDescription fontDescription;
1125 fontDescription.path = pathName + DEFAULT_FONT_DIR + "/tizen/BreezeColorEmoji.ttf";
1126 fontDescription.family = "BreezeColorEmoji";
1127 fontDescription.width = TextAbstraction::FontWidth::NONE;
1128 fontDescription.weight = TextAbstraction::FontWeight::NORMAL;
1129 fontDescription.slant = TextAbstraction::FontSlant::NONE;
1131 fontClient.GetFontId(fontDescription, EMOJI_FONT_SIZE);
1133 const std::string emojis = "<font family='BreezeColorEmoji' size='60'>\xF0\x9F\x98\x81 \xF0\x9F\x98\x82 \xF0\x9F\x98\x83 \xF0\x9F\x98\x84</font>";
1134 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1135 label.SetProperty(TextLabel::Property::TEXT, emojis);
1137 Property::Map shadowMap;
1138 shadowMap.Insert("color", "green");
1139 shadowMap.Insert("offset", "2 2");
1140 label.SetProperty(TextLabel::Property::SHADOW, shadowMap);
1142 application.SendNotification();
1143 application.Render();
1145 // EMOJI + ZWJ + EMOJI case for coverage.
1146 const std::string emojiWithZWJ = "👩‍🔬";
1147 label.SetProperty(TextLabel::Property::TEXT, emojiWithZWJ);
1149 application.SendNotification();
1150 application.Render();
1152 // EMOJI Sequences case for coverage.
1153 std::string emojiSequences =
1154 "Glyphs not included in the font \n" //case for coverage when glyph is not included in the font
1155 "Text VS15 ☪︎\n" //text presentation sequence and selector
1156 "Color VS16 ☪️\n" //emoji presentation sequence and selector
1157 "Default ☪ \n" //default presentation
1158 "FamilyManWomanGirlBoy 👨‍👩‍👧‍👦\n" // emoji multi zwj sequence
1159 "WomanScientist 👩‍🔬\n" // emoji zwj sequence
1160 "WomanScientistLightSkinTone👩🏻‍🔬 \n" // emoji modifier sequence: skin tone & JWZ
1161 "LeftRightArrowText↔︎\n" // text presentation sequence and selector
1162 "LeftRightArrowEmoji↔️\n" // emoji presentation sequence and selector
1163 "SouthKoreaFlag🇰🇷\n" // emoji flag sequence
1164 "JordanFlag🇯🇴\n" // emoji flag sequence
1165 "EnglandFlag🏴󠁧󠁢󠁥󠁮󠁧󠁿\n" // emoji tag sequence like England flag
1166 "Runner 🏃‍➡️ \n"
1167 "VictoryHandMediumLightSkinTone:✌️🏼\n" // emoji modifier sequence: skin tone
1168 "RainbowFlag:🏳️‍🌈 \n" // emoji zwj sequence: Rainbow Flag
1169 "keycap# #️⃣ \n" // fully-qualified emoji keycap sequence
1170 "keycap#_text #⃣ \n" // unqualified emoji keycap sequence
1171 "keycap3 3️⃣ \n" // fully-qualified emoji keycap sequence
1172 "keycap3_text 3⃣ \n" // unqualified emoji keycap sequence
1173 "two adjacent glyphs ☪️️️☪️\n" // This line should be rendered as two adjacent glyphs
1174 "Digit 8️ 8︎ 8\n" // should be rendered according to selector
1175 "Surfing Medium Skin Female: 🏄🏼‍♀️\n" // Person Surfing + Medium Skin Tone +? Zero Width Joiner + Female Sign
1176 "SYMBOLS_NSLCL variation selector: 🅰️🅱️🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with variation selector, text vs emoji
1177 "SYMBOLS_NSLCL with VS15: 🅰︎🅱︎🅲︎🅳︎🅴︎\n" // 1F170 ~ 1F174 with VS15
1178 "SYMBOLS_NSLCL with VS16: 🅰️🅱️🅲️🅳️🅴️\n" // 1F170 ~ 1F174 with VS16
1182 label.SetProperty(TextLabel::Property::TEXT, emojiSequences);
1183 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
1184 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1185 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1187 application.SendNotification();
1188 application.Render();
1192 int UtcDaliToolkitTextlabelScrollingP(void)
1194 ToolkitTestApplication application;
1195 tet_infoline(" UtcDaliToolkitTextLabelScrollingP");
1196 TextLabel labelImmediate = TextLabel::New("Some text to scroll");
1197 TextLabel labelFinished = TextLabel::New("مرحبا بالعالم");
1199 DALI_TEST_CHECK(labelImmediate);
1200 DALI_TEST_CHECK(labelFinished);
1201 // Avoid a crash when core load gl resources.
1202 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1203 application.GetScene().Add(labelImmediate);
1204 // Turn on all the effects
1205 labelImmediate.SetProperty(TextLabel::Property::MULTI_LINE, false);
1206 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1207 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1208 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1209 labelImmediate.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1211 application.GetScene().Add(labelFinished);
1212 // Turn on all the effects
1213 labelFinished.SetProperty(TextLabel::Property::MULTI_LINE, false);
1214 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1215 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1216 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1217 labelFinished.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1221 // Render some text with the shared atlas backend
1222 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1223 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1225 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1226 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1228 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1229 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1230 application.SendNotification();
1231 application.Render();
1233 labelImmediate.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1234 labelFinished.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1235 application.SendNotification();
1236 application.Render();
1240 tet_result(TET_FAIL);
1246 int UtcDaliToolkitTextlabelScrollingCenterAlignP(void)
1248 ToolkitTestApplication application;
1249 TextLabel labelShort = TextLabel::New("Some text to scroll");
1250 TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
1252 DALI_TEST_CHECK(labelShort);
1253 DALI_TEST_CHECK(labelLong);
1254 // Avoid a crash when core load gl resources.
1255 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1256 application.GetScene().Add(labelShort);
1257 // Turn on all the effects
1258 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1259 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1260 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1261 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1262 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1263 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1265 application.GetScene().Add(labelLong);
1266 // Turn on all the effects
1267 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1268 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1269 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1270 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1271 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1272 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1276 // Render some text with the shared atlas backend
1277 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1278 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1279 application.SendNotification();
1280 application.Render();
1282 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1283 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1284 application.SendNotification();
1285 application.Render();
1289 tet_result(TET_FAIL);
1295 int UtcDaliToolkitTextlabelScrollingCenterAlignRTLP(void)
1297 ToolkitTestApplication application;
1298 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1299 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1301 DALI_TEST_CHECK(labelShort);
1302 DALI_TEST_CHECK(labelLong);
1303 // Avoid a crash when core load gl resources.
1304 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1305 application.GetScene().Add(labelShort);
1306 // Turn on all the effects
1307 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1308 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1309 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1310 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1311 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1312 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1314 application.GetScene().Add(labelLong);
1315 // Turn on all the effects
1316 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1317 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER");
1318 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1319 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1320 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1321 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1325 // Render some text with the shared atlas backend
1326 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1327 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1328 application.SendNotification();
1329 application.Render();
1331 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1332 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1333 application.SendNotification();
1334 application.Render();
1338 tet_result(TET_FAIL);
1344 int UtcDaliToolkitTextlabelScrollingEndAlignP(void)
1346 ToolkitTestApplication application;
1347 TextLabel labelShort = TextLabel::New("Some text to scroll");
1348 TextLabel labelLong = TextLabel::New("Some text to scroll that is greater than the width of the text. The quick brown fox jumps over the lazy dog. Hello World, we meet again!");
1350 DALI_TEST_CHECK(labelShort);
1351 DALI_TEST_CHECK(labelLong);
1352 // Avoid a crash when core load gl resources.
1353 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1354 application.GetScene().Add(labelShort);
1355 // Turn on all the effects
1356 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1357 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1358 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1359 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1360 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1361 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1363 application.GetScene().Add(labelLong);
1364 // Turn on all the effects
1365 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1366 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1367 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1368 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1369 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1370 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1374 // Render some text with the shared atlas backend
1375 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1376 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1377 application.SendNotification();
1378 application.Render();
1380 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1381 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1382 application.SendNotification();
1383 application.Render();
1387 tet_result(TET_FAIL);
1393 int UtcDaliToolkitTextlabelScrollingEndAlignRTLP(void)
1395 ToolkitTestApplication application;
1396 TextLabel labelShort = TextLabel::New("مرحبا بالعالم");
1397 TextLabel labelLong = TextLabel::New("لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار النشوة وتمجيد الألم نشأت بالفعل، وسأعرض لك التفاصيل لتكتشف حقيقة وأساس تلك السعادة البشرية، فلا أحد يرفض أو يكره أو يتجنب الشعور بالسعادة، ولكن بفضل هؤلاء الأشخاص الذين لا يدركون بأن السعادة لا بد أن نستشعرها بصورة أكثر عقلانية ومنطقية فيعرضهم هذا لمواجهة الظروف الأليمة، وأكرر بأنه لا يوجد من يرغب في الحب ونيل المنال ويتلذذ بالآلام، الألم هو الألم ولكن نتيجة لظروف ما قد تكمن السعاده فيما نتحمله من كد وأسي");
1399 DALI_TEST_CHECK(labelShort);
1400 DALI_TEST_CHECK(labelLong);
1401 // Avoid a crash when core load gl resources.
1402 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1403 application.GetScene().Add(labelShort);
1404 // Turn on all the effects
1405 labelShort.SetProperty(TextLabel::Property::MULTI_LINE, false);
1406 labelShort.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1407 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1408 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1409 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1410 labelShort.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1412 application.GetScene().Add(labelLong);
1413 // Turn on all the effects
1414 labelLong.SetProperty(TextLabel::Property::MULTI_LINE, false);
1415 labelLong.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, "END");
1416 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1417 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1418 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1419 labelLong.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::FINISH_LOOP);
1423 // Render some text with the shared atlas backend
1424 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1425 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1426 application.SendNotification();
1427 application.Render();
1429 labelShort.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1430 labelLong.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1431 application.SendNotification();
1432 application.Render();
1436 tet_result(TET_FAIL);
1442 int UtcDaliToolkitTextlabelScrollingInterruptedP(void)
1444 ToolkitTestApplication application;
1445 tet_infoline(" UtcDaliToolkitTextlabelScrollingInterruptedP");
1446 TextLabel label = TextLabel::New("Some text to scroll");
1447 DALI_TEST_CHECK(label);
1448 // Avoid a crash when core load gl resources.
1449 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1450 application.GetScene().Add(label);
1451 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 20.f));
1452 // Turn on all the effects
1453 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1454 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1455 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1456 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1459 application.SendNotification();
1460 application.Render();
1462 unsigned int actorCount1 = label.GetChildCount();
1463 tet_printf("Initial actor count is(%d)\n", actorCount1);
1467 // Render some text with the shared atlas backend
1468 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1469 application.SendNotification();
1470 application.Render(2000);
1472 unsigned int actorCount1 = label.GetChildCount();
1473 tet_printf("Actor count after scrolling is(%d)\n", actorCount1);
1475 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1478 application.SendNotification();
1479 application.Render();
1481 unsigned int actorCount2 = label.GetChildCount();
1482 tet_printf("After changing color the actor count is(%d)\n", actorCount2);
1484 DALI_TEST_EQUALS(actorCount1, actorCount2, TEST_LOCATION);
1488 tet_result(TET_FAIL);
1494 int UtcDaliToolkitTextlabelScrollingN(void)
1496 ToolkitTestApplication application;
1497 tet_infoline(" UtcDaliToolkitTextlabelScrollingN");
1499 TextLabel label = TextLabel::New("Some text to scroll");
1500 DALI_TEST_CHECK(label);
1502 application.GetScene().Add(label);
1504 // Avoid a crash when core load gl resources.
1505 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1507 // The text scrolling works only on single line text.
1508 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1510 // Turn on all the effects.
1511 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1512 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1513 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1515 // Enable the auto scrolling effect.
1516 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1518 // The auto scrolling shouldn't be enabled.
1519 const bool enabled = label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>();
1520 DALI_TEST_CHECK(!enabled);
1522 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1523 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 1);
1524 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 9999.0f);
1525 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1530 application.SendNotification();
1531 application.Render(1000);
1533 application.GetScene().Remove(label);
1534 application.SendNotification();
1535 application.Render();
1537 DALI_TEST_CHECK(!label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1539 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1540 application.GetScene().Add(label);
1542 application.SendNotification();
1543 application.Render();
1545 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1547 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, (Toolkit::TextLabel::AutoScrollStopMode::Type)2); // invalid type
1548 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1550 application.SendNotification();
1551 application.Render();
1553 DALI_TEST_CHECK(label.GetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL).Get<bool>());
1557 tet_result(TET_FAIL);
1563 int UtcDaliToolkitTextlabelScrollingWithEllipsis(void)
1565 ToolkitTestApplication application;
1566 tet_infoline(" UtcDaliToolkitTextlabelScrollingWithEllipsis");
1568 TextLabel label = TextLabel::New("Some text to scroll");
1569 DALI_TEST_CHECK(label);
1571 application.GetScene().Add(label);
1573 // Avoid a crash when core load gl resources.
1574 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1576 // Turn on all the effects.
1577 label.SetProperty(TextLabel::Property::AUTO_SCROLL_GAP, 50.0f);
1578 label.SetProperty(TextLabel::Property::AUTO_SCROLL_LOOP_COUNT, 3);
1579 label.SetProperty(TextLabel::Property::AUTO_SCROLL_SPEED, 80.0f);
1583 // Enable the auto scrolling effect.
1584 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, true);
1585 label.SetProperty(TextLabel::Property::AUTO_SCROLL_STOP_MODE, TextLabel::AutoScrollStopMode::IMMEDIATE);
1587 // Disable the ellipsis
1588 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
1591 application.SendNotification();
1592 application.Render();
1594 // Stop auto scrolling
1595 label.SetProperty(TextLabel::Property::ENABLE_AUTO_SCROLL, false);
1597 // Check the ellipsis property
1598 DALI_TEST_CHECK(!label.GetProperty<bool>(TextLabel::Property::ELLIPSIS));
1602 tet_result(TET_FAIL);
1608 int UtcDaliToolkitTextlabelEllipsis(void)
1610 ToolkitTestApplication application;
1611 tet_infoline(" UtcDaliToolkitTextlabelEllipsis");
1613 TextLabel label = TextLabel::New("Hello world");
1614 DALI_TEST_CHECK(label);
1616 // Avoid a crash when core load gl resources.
1617 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
1619 application.GetScene().Add(label);
1621 // Turn on all the effects
1622 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER);
1623 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER);
1624 label.SetProperty(Actor::Property::SIZE, Vector2(360.0f, 10.f));
1629 application.SendNotification();
1630 application.Render();
1634 tet_result(TET_FAIL);
1637 label.SetProperty(TextLabel::Property::TEXT, "Hello world ");
1638 label.SetProperty(DevelTextLabel::Property::IGNORE_SPACES_AFTER_TEXT, false);
1639 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1644 application.SendNotification();
1645 application.Render();
1649 tet_result(TET_FAIL);
1652 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1653 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, true);
1654 label.SetProperty(Actor::Property::SIZE, Vector2(400.0f, 10.f));
1659 application.SendNotification();
1660 application.Render();
1664 tet_result(TET_FAIL);
1670 int UtcDaliToolkitTextlabelTextWrapMode(void)
1672 ToolkitTestApplication application;
1673 tet_infoline(" UtcDaliToolkitTextlabelTextWarpMode");
1677 TextLabel label = TextLabel::New();
1678 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1679 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1680 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1682 //label.SetProperty( TextLabel::Property::POINT_SIZE, 18 );
1683 application.GetScene().Add(label);
1685 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "WORD");
1686 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1688 application.SendNotification();
1689 application.Render();
1691 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1692 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1694 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
1695 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1697 application.SendNotification();
1698 application.Render();
1700 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::WORD);
1701 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::WORD), TEST_LOCATION);
1703 application.SendNotification();
1704 application.Render();
1706 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1707 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1709 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, Text::LineWrap::CHARACTER);
1710 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1712 application.SendNotification();
1713 application.Render();
1715 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1716 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
1718 tet_infoline("Ensure invalid string does not change wrapping mode");
1719 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "InvalidWrapMode");
1720 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(Text::LineWrap::CHARACTER), TEST_LOCATION);
1725 int UtcDaliToolkitTextLabelColorComponents(void)
1727 ToolkitTestApplication application;
1729 TextLabel label = TextLabel::New();
1730 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1731 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 1.0f, TEST_LOCATION);
1732 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1733 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1734 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1736 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::GREEN);
1737 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1738 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 1.0f, TEST_LOCATION);
1739 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 0.0f, TEST_LOCATION);
1740 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1742 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1743 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_RED), 0.0f, TEST_LOCATION);
1744 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_GREEN), 0.0f, TEST_LOCATION);
1745 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_BLUE), 1.0f, TEST_LOCATION);
1746 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 1.0f, TEST_LOCATION);
1748 label.SetProperty(TextLabel::Property::TEXT_COLOR_ALPHA, 0.6f);
1749 DALI_TEST_EQUALS(label.GetProperty<float>(TextLabel::Property::TEXT_COLOR_ALPHA), 0.6f, TEST_LOCATION);
1750 DALI_TEST_EQUALS(label.GetProperty<Vector4>(TextLabel::Property::TEXT_COLOR), Vector4(0.0f, 0.0f, 1.0f, 0.6f), TEST_LOCATION);
1752 // Test a transparent text - Rendering should be skipped.
1753 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1754 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::BLUE);
1756 application.GetScene().Add(label);
1758 TraceCallStack& drawTrace = application.GetGlAbstraction().GetDrawTrace();
1759 drawTrace.Enable(true);
1761 application.SendNotification();
1762 application.Render();
1764 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered
1766 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::TRANSPARENT);
1770 application.SendNotification();
1771 application.Render();
1773 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), false, TEST_LOCATION); // Rendering should be skipped
1775 label.SetProperty(TextLabel::Property::TEXT_COLOR, Color::RED);
1779 application.SendNotification();
1780 application.Render();
1782 DALI_TEST_EQUALS(drawTrace.FindMethod("DrawArrays"), true, TEST_LOCATION); // Should be rendered again
1787 int UtcDaliToolkitTextlabelTextStyle01(void)
1789 ToolkitTestApplication application;
1790 tet_infoline(" UtcDaliToolkitTextlabelTextStyle Setting Outline after Shadow");
1792 TextLabel label = TextLabel::New();
1793 label.SetProperty(Actor::Property::SIZE, Vector2(300.0f, 300.f));
1794 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world");
1795 label.SetProperty(TextLabel::Property::POINT_SIZE, 12);
1796 application.GetScene().Add(label);
1798 Property::Map outlineMapSet;
1799 Property::Map outlineMapGet;
1801 outlineMapSet["color"] = Color::BLUE;
1802 outlineMapSet["width"] = 2.0f;
1803 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1805 application.SendNotification();
1806 application.Render();
1808 Property::Map shadowMapSet;
1809 shadowMapSet.Insert("color", "green");
1810 shadowMapSet.Insert("offset", "2 2");
1811 shadowMapSet.Insert("blurRadius", "3");
1812 label.SetProperty(TextLabel::Property::SHADOW, shadowMapSet);
1814 outlineMapSet["color"] = Color::RED;
1815 outlineMapSet["width"] = 0.0f;
1816 label.SetProperty(TextLabel::Property::OUTLINE, outlineMapSet);
1818 application.SendNotification();
1819 application.Render();
1821 outlineMapGet = label.GetProperty<Property::Map>(TextLabel::Property::OUTLINE);
1823 Property::Value* colorValue = outlineMapGet.Find("color");
1825 bool colorMatched(false);
1829 Property::Type valueType = colorValue->GetType();
1831 if(Property::STRING == valueType)
1833 std::string stringValue;
1834 colorValue->Get(stringValue);
1835 if(stringValue == "red")
1837 colorMatched = true;
1840 else if(Property::VECTOR4 == valueType)
1842 Vector4 colorVector4;
1843 colorValue->Get(colorVector4);
1844 if(colorVector4 == Color::RED)
1846 colorMatched = true;
1851 DALI_TEST_EQUALS(colorMatched, true, TEST_LOCATION);
1856 int UtcDaliToolkitTextlabelMultiline(void)
1858 ToolkitTestApplication application;
1859 tet_infoline(" UtcDaliToolkitTextlabelMultiline");
1861 TextLabel label = TextLabel::New();
1862 label.SetProperty(TextLabel::Property::TEXT, "Hello world Hello world Hello world Hello world Hello world Hello world");
1863 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1864 label.SetProperty(TextLabel::Property::MULTI_LINE, false);
1865 application.GetScene().Add(label);
1867 application.SendNotification();
1868 application.Render();
1870 int lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1871 DALI_TEST_EQUALS(lineCount, 1, TEST_LOCATION);
1873 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
1875 application.SendNotification();
1876 application.Render();
1878 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
1879 DALI_TEST_EQUALS(true, (lineCount > 1), TEST_LOCATION);
1884 int UtcDaliToolkitTextlabelTextDirection(void)
1886 ToolkitTestApplication application;
1887 tet_infoline(" UtcDaliToolkitTextlabelTextDirection");
1889 TextLabel label = TextLabel::New();
1890 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1892 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1893 label.SetProperty(TextLabel::Property::POINT_SIZE, 20);
1894 label.SetProperty(DevelTextLabel::Property::MATCH_SYSTEM_LANGUAGE_DIRECTION, false);
1895 application.GetScene().Add(label);
1898 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::LEFT_TO_RIGHT), TEST_LOCATION);
1901 label.SetProperty(TextLabel::Property::TEXT, "ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1902 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1904 // Test RTL text starting with weak character
1905 label.SetProperty(TextLabel::Property::TEXT, "()ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1906 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1908 // Test RTL text string with emoji and weak character
1909 label.SetProperty(TextLabel::Property::TEXT, "\xF0\x9F\x98\x81 () ﻡﺮﺤﺑﺍ ﺏﺎﻠﻋﺎﻠﻣ ﻡﺮﺤﺑﺍ");
1910 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::TEXT_DIRECTION), static_cast<int>(Toolkit::DevelText::TextDirection::RIGHT_TO_LEFT), TEST_LOCATION);
1915 int UtcDaliToolkitTextlabelVerticalLineAlignment(void)
1917 ToolkitTestApplication application;
1918 tet_infoline(" UtcDaliToolkitTextlabelVerticalLineAlignment");
1920 TextLabel label = TextLabel::New();
1922 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::TOP);
1923 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
1924 label.SetProperty(TextLabel::Property::POINT_SIZE, 15);
1925 label.SetProperty(TextLabel::Property::LINE_SPACING, 12);
1926 application.GetScene().Add(label);
1927 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::TOP), TEST_LOCATION);
1929 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::MIDDLE);
1930 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::MIDDLE), TEST_LOCATION);
1932 label.SetProperty(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT, DevelText::VerticalLineAlignment::BOTTOM);
1933 DALI_TEST_EQUALS(label.GetProperty<int>(DevelTextLabel::Property::VERTICAL_LINE_ALIGNMENT), static_cast<int>(Toolkit::DevelText::VerticalLineAlignment::BOTTOM), TEST_LOCATION);
1938 int UtcDaliToolkitTextLabelBitmapFont(void)
1940 ToolkitTestApplication application;
1941 tet_infoline(" UtcDaliToolkitTextLabelBitmapFont");
1943 DevelText::BitmapFontDescription fontDescription;
1944 fontDescription.name = "Digits";
1945 fontDescription.underlinePosition = 0.f;
1946 fontDescription.underlineThickness = 0.f;
1948 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 34.f, 0.f});
1949 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0031.png", "0", 34.f, 0.f});
1950 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0032.png", "1", 34.f, 0.f});
1951 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0033.png", "2", 34.f, 0.f});
1952 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0034.png", "3", 34.f, 0.f});
1953 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0035.png", "4", 34.f, 0.f});
1954 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0036.png", "5", 34.f, 0.f});
1955 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0037.png", "6", 34.f, 0.f});
1956 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0038.png", "7", 34.f, 0.f});
1957 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0039.png", "8", 34.f, 0.f});
1958 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u003a.png", "9", 34.f, 0.f});
1960 TextAbstraction::BitmapFont bitmapFont;
1961 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
1963 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1964 fontClient.GetFontId(bitmapFont);
1966 TextLabel label = TextLabel::New();
1968 label.SetProperty(TextLabel::Property::TEXT, "0123456789:");
1969 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
1971 // The text has been laid out with the bitmap font if the natural size is the sum of all the width (322) and 34 height.
1972 DALI_TEST_EQUALS(label.GetNaturalSize(), Vector3(322.f, 34.f, 0.f), Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1974 application.GetScene().Add(label);
1976 application.SendNotification();
1977 application.Render();
1979 // The text has been rendered if the height of the text-label is the height of the line.
1980 DALI_TEST_EQUALS(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height, 34.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
1985 int ConvertPointToPixel(float point)
1987 unsigned int horizontalDpi = 0u;
1988 unsigned int verticalDpi = 0u;
1989 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
1990 fontClient.GetDpi(horizontalDpi, verticalDpi);
1992 return (point * 72.f) / static_cast<float>(horizontalDpi);
1995 int UtcDaliToolkitTextlabelTextFit(void)
1997 ToolkitTestApplication application;
1998 tet_infoline(" UtcDaliToolkitTextlabelTextFit");
1999 TextLabel label = TextLabel::New();
2000 Vector2 size(460.0f, 100.0f);
2001 label.SetProperty(Actor::Property::SIZE, size);
2002 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2004 // connect to the text git changed signal.
2005 ConnectionTracker* testTracker = new ConnectionTracker();
2006 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2007 bool textFitChangedSignal = false;
2008 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2009 gTextFitChangedCallBackCalled = false;
2012 Property::Map textFitMapSet;
2013 textFitMapSet["enable"] = true;
2014 textFitMapSet["minSize"] = 10.f;
2015 textFitMapSet["maxSize"] = 100.f;
2016 textFitMapSet["stepSize"] = -1.f;
2017 textFitMapSet["fontSizeType"] = "pointSize";
2019 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2020 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2022 application.GetScene().Add(label);
2024 application.SendNotification();
2025 application.Render();
2027 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2028 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2030 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2031 DALI_TEST_CHECK(textFitChangedSignal);
2034 textFitMapSet.Clear();
2035 textFitMapSet["enable"] = true;
2036 textFitMapSet["minSize"] = ConvertPointToPixel(10.f);
2037 textFitMapSet["maxSize"] = ConvertPointToPixel(100.f);
2038 textFitMapSet["stepSize"] = ConvertPointToPixel(1.f);
2039 textFitMapSet["fontSizeType"] = "pixelSize";
2041 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2043 application.SendNotification();
2044 application.Render();
2046 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2051 int UtcDaliToolkitTextlabelTextFitStressTest(void)
2053 ToolkitTestApplication application;
2054 tet_infoline(" UtcDaliToolkitTextlabelTextFitStressTest");
2055 TextLabel label = TextLabel::New();
2056 Vector2 size(460.0f, 100.0f);
2057 label.SetProperty(Actor::Property::SIZE, size);
2058 label.SetProperty(TextLabel::Property::TEXT, "Hello world");
2060 // connect to the text git changed signal.
2061 ConnectionTracker* testTracker = new ConnectionTracker();
2062 DevelTextLabel::TextFitChangedSignal(label).Connect(&TestTextFitChangedCallback);
2063 bool textFitChangedSignal = false;
2064 label.ConnectSignal(testTracker, "textFitChanged", CallbackFunctor(&textFitChangedSignal));
2065 gTextFitChangedCallBackCalled = false;
2067 // check point size with veryvery big range
2068 Property::Map textFitMapSet;
2069 textFitMapSet["enable"] = true;
2070 textFitMapSet["minSize"] = 10.f;
2071 textFitMapSet["maxSize"] = 10000.f;
2072 textFitMapSet["stepSize"] = -1.0f;
2073 textFitMapSet["fontSizeType"] = "pointSize";
2075 label.SetProperty(Toolkit::DevelTextLabel::Property::TEXT_FIT, textFitMapSet);
2076 label.SetProperty(TextLabel::Property::POINT_SIZE, 120.f);
2078 application.GetScene().Add(label);
2080 application.SendNotification();
2081 application.Render();
2083 const Vector3 EXPECTED_NATURAL_SIZE(448.0f, 96.0f, 0.0f);
2084 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2086 DALI_TEST_CHECK(gTextFitChangedCallBackCalled);
2087 DALI_TEST_CHECK(textFitChangedSignal);
2092 int UtcDaliToolkitTextlabelTextFitArray(void)
2094 ToolkitTestApplication application;
2095 tet_infoline(" UtcDaliToolkitTextlabelTextFitArray");
2096 TextLabel label = TextLabel::New();
2097 Vector2 size(300.0f, 80.0f);
2098 label.SetProperty(Actor::Property::SIZE, size);
2099 label.SetProperty(TextLabel::Property::TEXT, "A Quick Brown Fox Jumps Over The Lazy Dog");
2100 label.SetProperty(DevelTextLabel::Property::MIN_LINE_SIZE, 80.f);
2101 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
2102 application.GetScene().Add(label);
2104 // make sorted options.
2105 std::vector<DevelTextLabel::FitOption> fitOptions;
2106 fitOptions.push_back(DevelTextLabel::FitOption(10, 12));
2107 fitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2108 fitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2109 fitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2110 fitOptions.push_back(DevelTextLabel::FitOption(20, 22));
2111 fitOptions.push_back(DevelTextLabel::FitOption(22, 24));
2112 fitOptions.push_back(DevelTextLabel::FitOption(12, 14));
2114 DevelTextLabel::SetTextFitArray(label, true, fitOptions);
2116 application.SendNotification();
2117 application.Render();
2119 bool enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2120 DALI_TEST_EQUALS(true, enable, TEST_LOCATION);
2122 std::vector<Dali::Toolkit::DevelTextLabel::FitOption> getFitOptions = Dali::Toolkit::DevelTextLabel::GetTextFitArray(label);
2123 size_t numberOfFitOptions = getFitOptions.size();
2124 DALI_TEST_EQUALS(7u, numberOfFitOptions, TEST_LOCATION);
2126 const Vector3 EXPECTED_NATURAL_SIZE(276.0f, 16.0f, 0.0f);
2127 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2129 std::vector<DevelTextLabel::FitOption> emptyFitOptions;
2130 DevelTextLabel::SetTextFitArray(label, false, emptyFitOptions);
2132 application.SendNotification();
2133 application.Render();
2135 enable = Dali::Toolkit::DevelTextLabel::IsTextFitArrayEnabled(label);
2136 DALI_TEST_EQUALS(false, enable, TEST_LOCATION);
2138 const Vector3 EXPECTED_NATURAL_SIZE_DISABLE(690.0f, 80.0f, 0.0f);
2139 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE_DISABLE, label.GetNaturalSize(), TEST_LOCATION);
2141 // make unsorted options.
2142 std::vector<DevelTextLabel::FitOption> unorderedFitOptions;
2143 unorderedFitOptions.push_back(DevelTextLabel::FitOption(4, 6));
2144 unorderedFitOptions.push_back(DevelTextLabel::FitOption(6, 8));
2145 unorderedFitOptions.push_back(DevelTextLabel::FitOption(8, 10));
2146 unorderedFitOptions.push_back(DevelTextLabel::FitOption(10, 8));
2148 DevelTextLabel::SetTextFitArray(label, true, unorderedFitOptions);
2150 application.SendNotification();
2151 application.Render();
2153 DALI_TEST_EQUALS(EXPECTED_NATURAL_SIZE, label.GetNaturalSize(), TEST_LOCATION);
2158 int UtcDaliToolkitTextlabelMaxTextureSet(void)
2160 ToolkitTestApplication application;
2161 tet_infoline(" UtcDaliToolkitTextlabelMaxTextureSet");
2163 DevelText::BitmapFontDescription fontDescription;
2164 fontDescription.name = "Digits";
2165 fontDescription.glyphs.push_back({TEST_RESOURCE_DIR "/fonts/bitmap/u0030.png", ":", 200.f, 0.f});
2167 TextAbstraction::BitmapFont bitmapFont;
2168 DevelText::CreateBitmapFont(fontDescription, bitmapFont);
2170 TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
2171 fontClient.GetFontId(bitmapFont);
2173 TextLabel label = TextLabel::New();
2174 label.SetProperty(TextLabel::Property::FONT_FAMILY, "Digits");
2175 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2176 label.SetProperty(TextLabel::Property::TEXT, ":This is a long sample text made to allow max texture size to be exceeded.");
2177 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2178 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2180 Property::Map underlineMapSet;
2181 underlineMapSet.Clear();
2182 underlineMapSet.Insert("enable", true);
2183 underlineMapSet.Insert("color", Color::RED);
2184 underlineMapSet.Insert("height", 1);
2185 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2186 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2188 Property::Map strikethroughMapSet;
2189 strikethroughMapSet.Clear();
2190 strikethroughMapSet.Insert("enable", true);
2191 strikethroughMapSet.Insert("color", Color::RED);
2192 strikethroughMapSet.Insert("height", 2.0f);
2193 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2194 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2196 application.GetScene().Add(label);
2198 application.SendNotification();
2199 application.Render();
2201 const int maxTextureSize = Dali::GetMaxTextureSize();
2202 // Whether the rendered text is greater than maxTextureSize
2203 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2205 // Check if the number of renderers is greater than 1.
2206 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2209 underlineMapSet.Clear();
2210 underlineMapSet.Insert("enable", false);
2211 underlineMapSet.Insert("color", Color::BLUE);
2212 underlineMapSet.Insert("height", 0);
2213 underlineMapSet.Insert("type", Text::Underline::DASHED);
2214 underlineMapSet.Insert("dashWidth", 2);
2215 underlineMapSet.Insert("dashGap", 1);
2216 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2217 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2219 application.GetScene().Add(label);
2221 application.SendNotification();
2222 application.Render();
2224 // Whether the rendered text is greater than maxTextureSize
2225 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2227 // Check if the number of renderers is greater than 1.
2228 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2231 underlineMapSet.Clear();
2232 underlineMapSet.Insert("enable", false);
2233 underlineMapSet.Insert("color", Color::BLUE);
2234 underlineMapSet.Insert("height", 0);
2235 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2236 underlineMapSet.Insert("dashWidth", 2);
2237 underlineMapSet.Insert("dashGap", 1);
2238 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2239 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2241 application.GetScene().Add(label);
2243 application.SendNotification();
2244 application.Render();
2246 // Whether the rendered text is greater than maxTextureSize
2247 DALI_TEST_CHECK(label.GetCurrentProperty<Vector3>(Actor::Property::SIZE).height > maxTextureSize);
2249 // Check if the number of renderers is greater than 1.
2250 DALI_TEST_CHECK(label.GetRendererCount() > 1u);
2252 // Coverage test for case of layoutSize is bigger than maxTextureSize
2253 float max_value = static_cast<float>(std::numeric_limits<uint16_t>::max());
2254 label.SetProperty(Actor::Property::SIZE, Vector2(max_value, 30.0f));
2255 application.SendNotification();
2256 application.Render();
2261 int UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight(void)
2263 ToolkitTestApplication application;
2264 tet_infoline(" UtcDaliToolkitTextlabelStrikethroughExceedsWidthAndHeight");
2266 TextLabel label = TextLabel::New();
2267 label.SetProperty(TextLabel::Property::TEXT, "Test");
2268 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2269 //Exeeding BufferWidth
2270 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2271 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2272 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2274 application.GetScene().Add(label);
2275 application.SendNotification();
2276 application.Render();
2278 Property::Map strikethroughMapSet;
2279 strikethroughMapSet.Clear();
2280 strikethroughMapSet.Insert("enable", true);
2281 strikethroughMapSet.Insert("color", Color::BLUE);
2282 strikethroughMapSet.Insert("height", 2.0f);
2283 label.SetProperty(TextLabel::Property::TEXT, "Test1");
2284 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2285 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2286 application.GetScene().Add(label);
2287 application.SendNotification();
2288 application.Render();
2289 // Check if the number of renderers is 1.
2290 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2292 label = TextLabel::New();
2293 label.SetProperty(TextLabel::Property::TEXT, "Test");
2294 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2296 //Exeeding BufferHeight
2297 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.0f));
2298 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2299 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2301 application.GetScene().Add(label);
2302 application.SendNotification();
2303 application.Render();
2305 strikethroughMapSet.Clear();
2306 strikethroughMapSet.Insert("enable", true);
2307 strikethroughMapSet.Insert("color", Color::BLUE);
2308 strikethroughMapSet.Insert("height", 2.0f);
2309 label.SetProperty(TextLabel::Property::TEXT, "Test2");
2310 label.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2311 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2312 application.GetScene().Add(label);
2313 application.SendNotification();
2314 application.Render();
2315 // Check if the number of renderers is 1.
2316 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2321 int UtcDaliToolkitTextlabelUnderlineExceedsWidth(void)
2323 ToolkitTestApplication application;
2324 tet_infoline(" UtcDaliToolkitTextlabelUnderlineExceedsWidth");
2326 TextLabel label = TextLabel::New();
2327 label.SetProperty(TextLabel::Property::TEXT, "Test");
2328 label.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2329 //Exeeding BufferWidth
2330 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 400.0f));
2331 label.SetProperty(TextLabel::Property::HORIZONTAL_ALIGNMENT, HorizontalAlignment::RIGHT);
2332 label.SetProperty(TextLabel::Property::POINT_SIZE, 200.f);
2334 application.GetScene().Add(label);
2335 application.SendNotification();
2336 application.Render();
2338 Property::Map underlineMapSet;
2341 underlineMapSet.Clear();
2342 underlineMapSet.Insert("enable", true);
2343 underlineMapSet.Insert("color", Color::BLUE);
2344 underlineMapSet.Insert("height", 1);
2345 underlineMapSet.Insert("type", Text::Underline::SOLID);
2346 underlineMapSet.Insert("dashWidth", 2);
2347 underlineMapSet.Insert("dashGap", 1);
2348 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2349 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2351 application.GetScene().Add(label);
2353 application.SendNotification();
2354 application.Render();
2356 // Check if the number of renderers is 1.
2357 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2360 underlineMapSet.Clear();
2361 underlineMapSet.Insert("enable", true);
2362 underlineMapSet.Insert("color", Color::BLUE);
2363 underlineMapSet.Insert("height", 1);
2364 underlineMapSet.Insert("type", Text::Underline::DASHED);
2365 underlineMapSet.Insert("dashWidth", 2);
2366 underlineMapSet.Insert("dashGap", 1);
2367 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2368 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2370 application.GetScene().Add(label);
2372 application.SendNotification();
2373 application.Render();
2375 // Check if the number of renderers is 1.
2376 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2379 underlineMapSet.Clear();
2380 underlineMapSet.Insert("enable", true);
2381 underlineMapSet.Insert("color", Color::BLUE);
2382 underlineMapSet.Insert("height", 1);
2383 underlineMapSet.Insert("type", Text::Underline::DOUBLE);
2384 underlineMapSet.Insert("dashWidth", 2);
2385 underlineMapSet.Insert("dashGap", 1);
2386 label.SetProperty(TextLabel::Property::UNDERLINE, underlineMapSet);
2387 label.SetProperty(Toolkit::TextLabel::Property::TEXT_COLOR, Color::BLUE);
2389 application.GetScene().Add(label);
2391 application.SendNotification();
2392 application.Render();
2394 // Check if the number of renderers is 1.
2395 DALI_TEST_EQUALS(1, label.GetRendererCount(), TEST_LOCATION);
2400 int UtcDaliToolkitTextlabelLastCharacterIndex(void)
2402 ToolkitTestApplication application;
2403 tet_infoline(" UtcDaliToolkitTextlabelLastCharacterIndex");
2405 Vector2 size(300.0f, 100.0f);
2407 Dali::Toolkit::DevelText::RendererParameters textParameters;
2408 textParameters.text = "This is a sample text to get the last index.";
2409 textParameters.layout = "multiLine";
2410 textParameters.fontSize = 20.f;
2411 textParameters.textWidth = 300u;
2412 textParameters.textHeight = 100u;
2413 textParameters.ellipsisEnabled = true;
2414 Dali::Property::Array indexArray = Dali::Toolkit::DevelText::GetLastCharacterIndex(textParameters);
2416 DALI_TEST_CHECK(!indexArray.Empty());
2417 DALI_TEST_EQUALS(indexArray.GetElementAt(0).Get<int>(), 10, TEST_LOCATION);
2422 int UtcDaliToolkitTextlabelFontSizeScale(void)
2424 ToolkitTestApplication application;
2425 tet_infoline(" UtcDaliToolkitTextlabelFontSizeScale");
2427 TextLabel label = TextLabel::New();
2428 label.SetProperty(TextLabel::Property::POINT_SIZE, 30.f);
2429 label.SetProperty(TextLabel::Property::TEXT, "Test");
2430 Vector3 nonScaledSize = label.GetNaturalSize();
2432 TextLabel labelScaled = TextLabel::New();
2433 labelScaled.SetProperty(TextLabel::Property::POINT_SIZE, 15.f);
2434 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2435 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2436 Vector3 scaledSize = labelScaled.GetNaturalSize();
2438 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2440 label.SetProperty(TextLabel::Property::PIXEL_SIZE, 30.f);
2441 label.SetProperty(TextLabel::Property::TEXT, "Test");
2442 nonScaledSize = label.GetNaturalSize();
2444 labelScaled.SetProperty(TextLabel::Property::PIXEL_SIZE, 15.f);
2445 labelScaled.SetProperty(Toolkit::DevelTextLabel::Property::FONT_SIZE_SCALE, 2.f);
2446 labelScaled.SetProperty(TextLabel::Property::TEXT, "Test");
2447 scaledSize = labelScaled.GetNaturalSize();
2449 DALI_TEST_EQUALS(nonScaledSize, scaledSize, TEST_LOCATION);
2454 int UtcDaliToolkitTextlabelAnchorColor(void)
2456 ToolkitTestApplication application;
2457 tet_infoline(" UtcDaliToolkitTextlabelAnchorColor");
2458 TextLabel label = TextLabel::New();
2459 DALI_TEST_CHECK(label);
2461 application.GetScene().Add(label);
2463 // connect to the anchor clicked signal.
2464 ConnectionTracker* testTracker = new ConnectionTracker();
2465 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2466 bool anchorClickedSignal = false;
2467 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2469 gAnchorClickedCallBackCalled = false;
2470 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2471 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2472 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2473 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2474 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2476 // Check that anchor color can be properly set
2477 label.SetProperty(DevelTextLabel::Property::ANCHOR_COLOR, Color::BLUE);
2478 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_COLOR), Color::BLUE, TEST_LOCATION);
2480 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::RED);
2481 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::RED, TEST_LOCATION);
2483 application.SendNotification();
2484 application.Render();
2486 // Create a tap event to touch the text label.
2487 TestGenerateTap(application, 5.0f, 25.0f, 100);
2488 application.SendNotification();
2489 application.Render();
2491 // Update clicked color
2492 label.SetProperty(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR, Color::BLUE);
2493 DALI_TEST_EQUALS(label.GetProperty<Vector4>(DevelTextLabel::Property::ANCHOR_CLICKED_COLOR), Color::BLUE, TEST_LOCATION);
2495 application.SendNotification();
2496 application.Render();
2498 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2499 DALI_TEST_CHECK(anchorClickedSignal);
2504 // Positive test for the anchorClicked signal.
2505 int UtcDaliToolkitTextlabelAnchorClicked(void)
2507 ToolkitTestApplication application;
2508 tet_infoline(" UtcDaliToolkitTextlabelAnchorClicked");
2509 TextLabel label = TextLabel::New();
2510 DALI_TEST_CHECK(label);
2512 application.GetScene().Add(label);
2514 // connect to the anchor clicked signal.
2515 ConnectionTracker* testTracker = new ConnectionTracker();
2516 DevelTextLabel::AnchorClickedSignal(label).Connect(&TestAnchorClickedCallback);
2517 bool anchorClickedSignal = false;
2518 label.ConnectSignal(testTracker, "anchorClicked", CallbackFunctor(&anchorClickedSignal));
2520 gAnchorClickedCallBackCalled = false;
2521 label.SetProperty(TextLabel::Property::TEXT, "<a href='https://www.tizen.org'>TIZEN</a>");
2522 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2523 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2524 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2525 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2527 application.SendNotification();
2528 application.Render();
2530 // Create a tap event to touch the text label.
2531 TestGenerateTap(application, 5.0f, 25.0f, 100);
2532 application.SendNotification();
2533 application.Render();
2535 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2536 DALI_TEST_CHECK(anchorClickedSignal);
2539 gAnchorClickedCallBackCalled = false;
2540 anchorClickedSignal = false;
2541 label.SetProperty(TextLabel::Property::TEXT, "");
2542 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, false);
2544 application.SendNotification();
2545 application.Render();
2548 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2549 label.SetProperty(TextLabel::Property::TEXT, "<a color='red' clicked-color='green' href='https://www.tizen.org'>TIZEN</a>");
2550 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
2551 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2552 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2554 application.SendNotification();
2555 application.Render();
2557 // Create a tap event to touch the text label.
2558 TestGenerateTap(application, 5.0f, 25.0f, 200);
2559 application.SendNotification();
2560 application.Render();
2562 DALI_TEST_CHECK(gAnchorClickedCallBackCalled);
2563 DALI_TEST_CHECK(anchorClickedSignal);
2565 gAnchorClickedCallBackNotCalled = true;
2566 // Tap the outside of anchor, callback should not be called.
2567 TestGenerateTap(application, 150.f, 100.f, 300);
2568 application.SendNotification();
2569 application.Render();
2571 DALI_TEST_CHECK(gAnchorClickedCallBackNotCalled);
2576 int UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize(void)
2578 ToolkitTestApplication application;
2579 tet_infoline(" UtcDaliTextLabelAtlasLimitationIsEnabledForLargeFontPointSize ");
2581 //TextLabel is not using Atlas but this is to unify font-size on text-controllers
2583 // +2: First one to handle the equal case. Second one to handle odd to even case of GetNaturalSize
2584 const uint32_t lessThanWidth = TextAbstraction::FontClient::MAX_TEXT_ATLAS_WIDTH - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2585 const uint32_t lessThanHeight = TextAbstraction::FontClient::MAX_TEXT_ATLAS_HEIGHT - TextAbstraction::FontClient::PADDING_TEXT_ATLAS_BLOCK + 2;
2587 // Create a text editor
2588 TextLabel textLabel = TextLabel::New();
2589 //Set size to avoid automatic eliding
2590 textLabel.SetProperty(Actor::Property::SIZE, Vector2(1025, 1025));
2591 //Set very large font-size using point-size
2592 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 1000);
2593 //Specify font-family
2594 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2595 //Set text to check if appear or not
2596 textLabel.SetProperty(TextLabel::Property::TEXT, "A");
2598 application.GetScene().Add(textLabel);
2600 application.SendNotification();
2601 application.Render();
2602 //Use GetNaturalSize to verify that size of block does not exceed Atlas size
2603 Vector3 naturalSize = textLabel.GetNaturalSize();
2605 DALI_TEST_GREATER(lessThanWidth, static_cast<uint32_t>(naturalSize.width), TEST_LOCATION);
2606 DALI_TEST_GREATER(lessThanHeight, static_cast<uint32_t>(naturalSize.height), TEST_LOCATION);
2611 int UtcDaliTextLabelHyphenWrapMode(void)
2613 ToolkitTestApplication application;
2614 tet_infoline(" UtcDaliTextLabelHyphenWrapMode ");
2617 TextLabel label = TextLabel::New();
2618 label.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
2619 label.SetProperty(TextLabel::Property::POINT_SIZE, 12.f);
2620 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2621 application.GetScene().Add(label);
2622 application.SendNotification();
2623 application.Render();
2625 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2626 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::HYPHENATION);
2627 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::HYPHENATION), TEST_LOCATION);
2629 application.SendNotification();
2630 application.Render();
2632 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2638 DALI_TEST_EQUALS(lineCount, 2, TEST_LOCATION);
2640 label.SetProperty(TextLabel::Property::TEXT, "Hi Experimen");
2641 label.SetProperty(TextLabel::Property::LINE_WRAP_MODE, DevelText::LineWrap::MIXED);
2642 DALI_TEST_EQUALS(label.GetProperty<int>(TextLabel::Property::LINE_WRAP_MODE), static_cast<int>(DevelText::LineWrap::MIXED), TEST_LOCATION);
2644 application.SendNotification();
2645 application.Render();
2647 lineCount = label.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2654 DALI_TEST_EQUALS(lineCount, 3, TEST_LOCATION);
2659 int utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged(void)
2661 ToolkitTestApplication application;
2663 tet_infoline(" utcDaliTextLabelGetHeightForWidthChangeLineCountWhenTextChanged ");
2665 int lineCountBefore = 0;
2666 int lineCountAfter = 0;
2668 // Create a text editor
2669 TextLabel textLabel = TextLabel::New();
2670 //Set very large font-size using point-size
2671 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2672 //Specify font-family
2673 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2675 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.f, 100.f));
2676 //Set text longer than width of textLabel
2677 textLabel.SetProperty(TextLabel::Property::TEXT, "Short text");
2678 //Set line wrap mode Character
2679 textLabel.SetProperty(TextLabel::Property::LINE_WRAP_MODE, "CHARACTER");
2680 textLabel.SetProperty(TextLabel::Property::MULTI_LINE, true);
2682 application.GetScene().Add(textLabel);
2684 application.SendNotification();
2685 application.Render();
2687 lineCountBefore = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2689 textLabel.SetProperty(TextLabel::Property::TEXT, "This is very loooooooooooooooooooooooooooooooooooong text for test");
2690 lineCountAfter = textLabel.GetProperty<int>(TextLabel::Property::LINE_COUNT);
2692 // When the text changed, the Line-count should be updated according to new text.
2693 // Because the GetHeightForWidth is called in Controller::GetLineCount(float width)
2694 DALI_TEST_EQUALS(lineCountBefore, 1, TEST_LOCATION);
2695 DALI_TEST_GREATER(lineCountAfter, 1, TEST_LOCATION);
2700 int utcDaliTextLabelGeometryRTL(void)
2702 ToolkitTestApplication application;
2703 tet_infoline(" utcDaliTextLabelGeometryRTL");
2705 TextLabel label = TextLabel::New();
2706 DALI_TEST_CHECK(label);
2708 application.GetScene().Add(label);
2710 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2711 label.SetProperty(Actor::Property::SIZE, Vector2(150.f, 100.f));
2712 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2713 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2714 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2715 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
2716 label.SetProperty(TextLabel::Property::TEXT, "line1 \nline2\nline 3\nالاخيرالسطر");
2717 // Avoid a crash when core load gl resources.
2718 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2720 // Render and notify
2721 application.SendNotification();
2722 application.Render();
2724 unsigned int expectedCount = 4;
2725 unsigned int startIndex = 3;
2726 unsigned int endIndex = 24;
2728 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2729 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2731 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2732 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2734 Vector<Vector2> expectedSizes;
2735 Vector<Vector2> expectedPositions;
2737 expectedPositions.PushBack(Vector2(25, 0));
2738 expectedSizes.PushBack(Vector2(34, 25));
2740 expectedPositions.PushBack(Vector2(-1, 25));
2741 expectedSizes.PushBack(Vector2(53, 25));
2743 expectedPositions.PushBack(Vector2(-1, 50));
2744 expectedSizes.PushBack(Vector2(60, 25));
2746 expectedPositions.PushBack(Vector2(75, 75));
2747 expectedSizes.PushBack(Vector2(37, 25));
2749 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2754 int utcDaliTextLabelGeometryGlyphMiddle(void)
2756 ToolkitTestApplication application;
2757 tet_infoline(" utcDaliTextLabelGeometryGlyphMiddle");
2759 TextLabel label = TextLabel::New();
2760 DALI_TEST_CHECK(label);
2762 application.GetScene().Add(label);
2764 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2765 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2766 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2767 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2768 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2769 label.SetProperty(TextLabel::Property::TEXT, "لا تحتوي على لا");
2771 // Avoid a crash when core load gl resources.
2772 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2774 // Render and notify
2775 application.SendNotification();
2776 application.Render();
2778 unsigned int expectedCount = 1;
2779 unsigned int startIndex = 1;
2780 unsigned int endIndex = 13;
2782 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2783 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2785 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2786 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2788 Vector<Vector2> expectedSizes;
2789 Vector<Vector2> expectedPositions;
2791 expectedPositions.PushBack(Vector2(6, 0));
2792 expectedSizes.PushBack(Vector2(125, 25));
2794 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2799 int utcDaliTextLabelGeometryOneGlyph(void)
2801 ToolkitTestApplication application;
2802 tet_infoline(" utcDaliTextLabelGeometryOneGlyph ");
2804 TextLabel label = TextLabel::New();
2805 DALI_TEST_CHECK(label);
2807 application.GetScene().Add(label);
2809 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2810 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2811 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2812 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2813 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2814 label.SetProperty(TextLabel::Property::TEXT, "H");
2816 // Avoid a crash when core load gl resources.
2817 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2819 // Render and notify
2820 application.SendNotification();
2821 application.Render();
2823 unsigned int expectedCount = 1;
2824 unsigned int startIndex = 0;
2825 unsigned int endIndex = 0;
2827 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2828 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2830 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2831 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2833 Vector<Vector2> expectedSizes;
2834 Vector<Vector2> expectedPositions;
2836 expectedPositions.PushBack(Vector2(-2, 0));
2837 expectedSizes.PushBack(Vector2(16, 25));
2839 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2841 positionsList.Clear();
2847 positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2848 sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2850 TestTextGeometryUtils::CheckGeometryResult(positionsList, sizeList, expectedPositions, expectedSizes);
2855 int utcDaliTextLabelGeometryNullPtr(void)
2857 ToolkitTestApplication application;
2858 tet_infoline("utcDaliTextLabelGeometryNullPtr");
2860 TextLabel label = TextLabel::New();
2861 DALI_TEST_CHECK(label);
2863 application.GetScene().Add(label);
2865 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
2866 label.SetProperty(Actor::Property::SIZE, Vector2(200.f, 200.f));
2867 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
2868 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
2869 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
2870 label.SetProperty(TextLabel::Property::TEXT, "");
2872 // Avoid a crash when core load gl resources.
2873 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
2875 unsigned int expectedCount = 0;
2876 unsigned int startIndex = 0;
2877 unsigned int endIndex = 0;
2879 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, startIndex, endIndex);
2880 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, startIndex, endIndex);
2882 // Render and notify
2883 application.SendNotification();
2884 application.Render();
2886 DALI_TEST_EQUALS(positionsList.Size(), expectedCount, TEST_LOCATION);
2887 DALI_TEST_EQUALS(sizeList.Size(), expectedCount, TEST_LOCATION);
2892 int UtcDaliToolkitTextlabelEllipsisPositionProperty(void)
2894 ToolkitTestApplication application;
2895 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty ");
2896 TextLabel textLabel = TextLabel::New();
2898 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Default is END");
2899 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2901 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START");
2902 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::START);
2903 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2905 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE");
2906 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::MIDDLE);
2907 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2909 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END");
2910 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, DevelText::EllipsisPosition::END);
2911 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2913 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using integer");
2914 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 1);
2915 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2917 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using integer");
2918 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 2);
2919 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2921 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using integer");
2922 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, 0);
2923 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2925 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - uppercase");
2926 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "START");
2927 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2929 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - uppercase");
2930 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "MIDDLE");
2931 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2933 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - uppercase");
2934 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "END");
2935 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2937 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to START using string - lowercase");
2938 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "start");
2939 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::START), TEST_LOCATION);
2941 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to MIDDLE using string - lowercase");
2942 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "middle");
2943 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::MIDDLE), TEST_LOCATION);
2945 tet_infoline(" UtcDaliToolkitTextlabelEllipsisPositionProperty - Change to END using string - lowercase");
2946 textLabel.SetProperty(DevelTextLabel::Property::ELLIPSIS_POSITION, "end");
2947 DALI_TEST_EQUALS(textLabel.GetProperty<int>(DevelTextLabel::Property::ELLIPSIS_POSITION), static_cast<int>(Toolkit::DevelText::EllipsisPosition::END), TEST_LOCATION);
2952 int UtcDaliToolkitTextLabelStrikethroughGeneration(void)
2954 ToolkitTestApplication application;
2955 tet_infoline(" UtcDaliToolkitTextLabelStrikethroughGeneration");
2957 TextLabel textLabel = TextLabel::New();
2958 textLabel.SetProperty(TextLabel::Property::TEXT, "Test");
2959 textLabel.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 100.f));
2960 textLabel.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2961 textLabel.SetProperty(TextLabel::Property::FONT_FAMILY, "DejaVu Sans");
2963 application.GetScene().Add(textLabel);
2964 application.SendNotification();
2965 application.Render();
2967 Property::Map strikethroughMapSet;
2968 Property::Map strikethroughMapGet;
2970 strikethroughMapSet.Insert("enable", true);
2971 strikethroughMapSet.Insert("color", Color::RED);
2972 strikethroughMapSet.Insert("height", 2.0f);
2974 // Check the strikethrough property
2975 textLabel.SetProperty(DevelTextLabel::Property::STRIKETHROUGH, strikethroughMapSet);
2976 strikethroughMapGet = textLabel.GetProperty<Property::Map>(DevelTextLabel::Property::STRIKETHROUGH);
2977 textLabel.SetProperty(TextLabel::Property::TEXT, "Test1");
2978 DALI_TEST_EQUALS(strikethroughMapGet.Count(), strikethroughMapSet.Count(), TEST_LOCATION);
2979 DALI_TEST_EQUALS(DaliTestCheckMaps(strikethroughMapGet, strikethroughMapSet), true, TEST_LOCATION);
2981 // Render and notify
2982 application.SendNotification();
2983 application.Render();
2985 strikethroughMapSet.Clear();
2986 strikethroughMapGet.Clear();
2991 int UtcDaliToolkitTextLabelMarkupRelativeLineHeight(void)
2993 ToolkitTestApplication application;
2994 tet_infoline(" UtcDaliToolkitTextLabelMarkupRelativeLineHeight");
2996 TextLabel label = TextLabel::New();
2997 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
2998 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
2999 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3000 label.SetProperty(TextLabel::Property::TEXT, "line 1\nline 2\nline 3\nline 4\nline 5");
3001 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3002 label.SetProperty(TextLabel::Property::ELLIPSIS, false);
3003 label.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3005 TextLabel labelSingleLineParagraph = TextLabel::New();
3006 labelSingleLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3007 labelSingleLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3008 labelSingleLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3009 labelSingleLineParagraph.SetProperty(TextLabel::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line 2</p>line 3<p rel-line-height=3>line 4</p>line 5");
3010 labelSingleLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3011 labelSingleLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3012 labelSingleLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3014 TextLabel labelMultiLineParagraph = TextLabel::New();
3015 labelMultiLineParagraph.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3016 labelMultiLineParagraph.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3017 labelMultiLineParagraph.SetProperty(TextLabel::Property::MULTI_LINE, true);
3018 labelMultiLineParagraph.SetProperty(TextLabel::Property::TEXT, "<p>line 1</p><p rel-line-height=0.5>line\n2</p>line 3<p rel-line-height=3>line\n4</p>line 5");
3019 labelMultiLineParagraph.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 1.0f);
3020 labelMultiLineParagraph.SetProperty(TextLabel::Property::ELLIPSIS, false);
3021 labelMultiLineParagraph.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3023 application.GetScene().Add(label);
3024 application.GetScene().Add(labelSingleLineParagraph);
3025 application.GetScene().Add(labelMultiLineParagraph);
3026 application.SendNotification();
3027 application.Render();
3029 Vector3 naturalSize = label.GetNaturalSize();
3030 Vector3 relativeSingleNaturalSize = labelSingleLineParagraph.GetNaturalSize();
3031 Vector3 relativeMultiNaturalSize = labelMultiLineParagraph.GetNaturalSize();
3033 float lineSize = naturalSize.y / 5.0f; //total size/number of lines
3035 //no effect of relative line size for paragraph with single line
3036 DALI_TEST_EQUALS(naturalSize.y, relativeSingleNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3038 DALI_TEST_EQUALS(lineSize * 8.5f, relativeMultiNaturalSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3043 int UtcDaliToolkitTextLabelRelativeLineHeight(void)
3045 ToolkitTestApplication application;
3046 tet_infoline(" UtcDaliToolkitTextLabelRelativeLineHeight");
3048 TextLabel label = TextLabel::New();
3049 label.SetProperty(Actor::Property::SIZE, Vector2(200.0f, 300.f));
3050 label.SetProperty(TextLabel::Property::POINT_SIZE, 10);
3051 label.SetProperty(TextLabel::Property::TEXT, "Hello\nWorld");
3053 application.GetScene().Add(label);
3054 application.SendNotification();
3055 application.Render();
3057 Vector3 naturalSize = label.GetNaturalSize();
3059 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 0.5f);
3061 application.SendNotification();
3062 application.Render();
3064 Vector3 relativeNaturalSize = label.GetNaturalSize();
3066 DALI_TEST_EQUALS(naturalSize.y, relativeNaturalSize.y, TEST_LOCATION);
3068 label.SetProperty(DevelTextLabel::Property::RELATIVE_LINE_SIZE, 2.0f);
3070 application.SendNotification();
3071 application.Render();
3073 relativeNaturalSize = label.GetNaturalSize();
3075 DALI_TEST_EQUALS(naturalSize.y * 2, relativeNaturalSize.y, TEST_LOCATION);
3079 int UtcDaliTextLabelCharacterSpacing(void)
3081 ToolkitTestApplication application;
3082 tet_infoline(" UtcDaliTextLabelCharacterSpacing ");
3084 TextLabel textLabel = TextLabel::New();
3086 textLabel.SetProperty(Actor::Property::SIZE, Vector2(150.0f, 300.f));
3088 application.GetScene().Add(textLabel);
3089 application.SendNotification();
3090 application.Render();
3092 textLabel.SetProperty(TextLabel::Property::TEXT, "Hi Experiment");
3093 textLabel.SetProperty(DevelTextLabel::Property::CHARACTER_SPACING, 10.f);
3094 DALI_TEST_EQUALS(textLabel.GetProperty<float>(DevelTextLabel::Property::CHARACTER_SPACING), 10.f, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3096 application.SendNotification();
3097 application.Render();
3102 int UtcDaliTextTextLabelSizeNegativeLineSpacing(void)
3104 ToolkitTestApplication application;
3105 tet_infoline("UtcDaliTextTextLabelSizeNegativeLineSpacing");
3107 TextLabel label = TextLabel::New();
3109 float lineSpacing = -20.f;
3111 label.SetProperty(Actor::Property::SIZE, Vector2(450.0f, 300.f));
3112 label.SetProperty(TextLabel::Property::POINT_SIZE, 10.f);
3113 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3114 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3115 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3117 application.GetScene().Add(label);
3118 application.SendNotification();
3119 application.Render();
3121 Vector<Vector2> positionsList = DevelTextLabel::GetTextPosition(label, 0, 123);
3122 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3124 Vector2 lastLinePos = positionsList[positionsList.Size() - 1];
3125 Vector2 lastLineSize = sizeList[sizeList.Size() - 1];
3127 DALI_TEST_EQUALS(sizeList[0].y * (sizeList.Size() - 1), lastLinePos.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3128 DALI_TEST_EQUALS(sizeList[0].y - lineSpacing, lastLineSize.y, Math::MACHINE_EPSILON_1000, TEST_LOCATION);
3130 application.SendNotification();
3131 application.Render();
3136 int UtcDaliTextLabelNegativeLineSpacingWithEllipsis(void)
3138 ToolkitTestApplication application;
3139 tet_infoline("UtcDaliTextLabelNegativeLineSpacingWithEllipsis");
3141 TextLabel label = TextLabel::New();
3143 float lineSpacing = -20.f;
3145 label.SetProperty(Actor::Property::SIZE, Vector2(480.0f, 100.f));
3146 label.SetProperty(TextLabel::Property::POINT_SIZE, 11.0f);
3147 label.SetProperty(DevelTextLabel::Property::LINE_SPACING, lineSpacing);
3148 label.SetProperty(TextLabel::Property::MULTI_LINE, true);
3149 label.SetProperty(TextLabel::Property::TEXT, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
3150 label.SetProperty(TextLabel::Property::ELLIPSIS, true);
3152 application.GetScene().Add(label);
3153 application.SendNotification();
3154 application.Render();
3156 Vector<Vector2> sizeList = DevelTextLabel::GetTextSize(label, 0, 123);
3158 int lineCount = sizeList.Size();
3159 DALI_TEST_EQUALS(4, lineCount, TEST_LOCATION);
3161 application.SendNotification();
3162 application.Render();
3167 int UtcDaliToolkitTextlabelParagraphTag(void)
3169 ToolkitTestApplication application;
3170 tet_infoline(" UtcDaliToolkitTextlabelParagraphTag");
3171 TextLabel labelNewlineSeparator = TextLabel::New();
3172 TextLabel labelParagraphTag = TextLabel::New();
3173 DALI_TEST_CHECK(labelNewlineSeparator);
3174 DALI_TEST_CHECK(labelParagraphTag);
3176 application.GetScene().Add(labelNewlineSeparator);
3177 application.GetScene().Add(labelParagraphTag);
3179 //Same utterance uses new-line to split paragraphs should give similar results for paragraph tag.
3180 labelNewlineSeparator.SetProperty(TextLabel::Property::MULTI_LINE, true);
3181 labelNewlineSeparator.SetProperty(TextLabel::Property::ELLIPSIS, false);
3182 labelNewlineSeparator.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3183 labelNewlineSeparator.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3184 labelNewlineSeparator.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3185 labelNewlineSeparator.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3186 labelNewlineSeparator.SetProperty(TextLabel::Property::TEXT, "test paragraph tag \ntest paragraph tag \ntest paragraph tag ");
3188 labelParagraphTag.SetProperty(TextLabel::Property::MULTI_LINE, true);
3189 labelParagraphTag.SetProperty(TextLabel::Property::ELLIPSIS, false);
3190 labelParagraphTag.SetProperty(TextLabel::Property::ENABLE_MARKUP, true);
3191 labelParagraphTag.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3192 labelParagraphTag.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3193 labelParagraphTag.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3194 labelParagraphTag.SetProperty(TextLabel::Property::TEXT, "test paragraph tag <p>test paragraph tag </p>test paragraph tag ");
3196 application.SendNotification();
3197 application.Render();
3199 Vector3 textNaturalSizeNewlineSeparator = labelNewlineSeparator.GetNaturalSize();
3200 Vector3 textNaturalSizeParagraphTag = labelParagraphTag.GetNaturalSize();
3202 DALI_TEST_EQUALS(textNaturalSizeNewlineSeparator, textNaturalSizeParagraphTag, TEST_LOCATION);
3204 application.SendNotification();
3205 application.Render();
3210 int utcDaliTextLabelGetTextBoundingRectangle(void)
3212 ToolkitTestApplication application;
3213 tet_infoline(" utcDaliTextLabelGeometryEllipsisMiddle");
3215 TextLabel label = TextLabel::New();
3216 DALI_TEST_CHECK(label);
3218 application.GetScene().Add(label);
3220 label.SetProperty(TextLabel::Property::POINT_SIZE, 7.f);
3221 label.SetProperty(Actor::Property::SIZE, Vector2(100.f, 50.f));
3222 label.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT);
3223 label.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT);
3224 label.SetProperty(TextLabel::Property::TEXT, "Hello this is the Text Bounding Rectangle TC");
3226 // Avoid a crash when core load gl resources.
3227 application.GetGlAbstraction().SetCheckFramebufferStatusResult(GL_FRAMEBUFFER_COMPLETE);
3229 // Render and notify
3230 application.SendNotification();
3231 application.Render();
3233 unsigned int startIndex = 0;
3234 unsigned int endIndex = 15;
3236 Rect<> textBoundingRectangle = DevelTextLabel::GetTextBoundingRectangle(label, startIndex, endIndex);
3237 Rect<> expectedTextBoundingRectangle = {0, 0, 100, 25};
3239 TestTextGeometryUtils::CheckRectGeometryResult(textBoundingRectangle, expectedTextBoundingRectangle);